-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
67 lines (51 loc) · 1.83 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
cmake_minimum_required(VERSION 3.18.4)
# Setting a variable to use for both the project name and the resulting binary executable
set(REPO lle)
project(${REPO})
set(PROJECT_NAME ${REPO})
# Set the C standard to C99
set(CMAKE_C_STANDARD 99)
# Compiler pre-processing flags
set(CPP_FLAGS
"-Wall"
"-Wextra"
"-pedantic"
"-Wno-builtin-declaration-mismatch"
)
# Set anti-lib flags
set(NOLIB
-static-libgcc
-static-libstdc++
-static-libasan
-nostartfiles
-nostdlib
)
# 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} ${NOLIB}
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 link options
target_link_options(${PROJECT_NAME} PRIVATE ${CPP_FLAGS} ${NOLIB} -g)
# Set compiler flags for the target
target_compile_options(${PROJECT_NAME} PRIVATE ${CPP_FLAGS} ${NOLIB} -g)
# 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
#13/44