-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
52 lines (35 loc) · 1.51 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
cmake_minimum_required(VERSION 3.25)
# Setting a variable to use for both the project name and the resulting binary executable
set(REPO timer)
project(${REPO})
set(PROJECT_NAME ${REPO})
# Set the C standard to C99
set(CMAKE_C_STANDARD 99)
# Compiler flags
set(CPP_FLAGS "-Wall -Wextra -pedantic")
# Add the src directory to the include path
include_directories(${PROJECT_SOURCE_DIR}/include)
# Add all the source files in the src directory to the project
file(GLOB SOURCES ${PROJECT_SOURCE_DIR}/src/*.c)
# Create the executable from the source files
add_executable(${PROJECT_NAME} ${PROJECT_SOURCE_DIR}/driver.c ${SOURCES})
# Set the output directory to the build/bin directory
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/build/bin)
set_target_properties(${PROJECT_NAME}
PROPERTIES
COMPILE_FLAGS ${CPP_FLAGS}
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/build/bin
)
# Set the object directory to the build/obj directory
set_property(
TARGET ${PROJECT_NAME}
PROPERTY
CMAKE_OBJECT_PATH_PREFIX ${PROJECT_SOURCE_DIR}/build/obj/
)
# Set the cmake binary directory to the build/cmake directory
set(CMAKE_BINARY_DIR ${PROJECT_SOURCE_DIR}/build/cmake)
# Add the build/cmake directory to the include path
include_directories(${PROJECT_SOURCE_DIR}/build/cmake)
# Add any other dependencies here, such as libraries or additional build options
target_link_libraries(${PROJECT_NAME} PRIVATE ao) # -lao
target_link_libraries(${PROJECT_NAME} PRIVATE mpg123) # -lmpg123