-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
81 lines (64 loc) · 1.85 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
68
69
70
71
72
73
74
75
76
77
78
79
80
cmake_minimum_required(VERSION 3.10)
set(PROJECT conway)
project(${PROJECT})
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE release)
endif()
MESSAGE(STATUS "BUILDING FOR ${CMAKE_BUILD_TYPE} VERSION")
set(BIN_DIR ${PROJECT_SOURCE_DIR}/bin)
if(CMAKE_BUILD_TYPE MATCHES "Debug")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BIN_DIR}/debug)
else()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BIN_DIR})
endif()
set(MAIN_SOURCE_DIR ${PROJECT_SOURCE_DIR}/src)
if(CMAKE_BUILD_TYPE MATCHES "Debug")
add_executable(conway
${MAIN_SOURCE_DIR}/main.c
${MAIN_SOURCE_DIR}/game.c
${MAIN_SOURCE_DIR}/draw.c
)
# target_link_libraries(${PROJECT} SDL2)
set(PROGRAM_LIBS SDL2)
else()
add_executable(${PROJECT}
${MAIN_SOURCE_DIR}/main.c
${MAIN_SOURCE_DIR}/game.c
)
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
# target_link_libraries(${PROJECT} OpenMP)
# gcc and clang specific flags
MESSAGE(STATUS "CMAKE_C_COMPILER_ID : " ${CMAKE_C_COMPILER_ID})
if (${CMAKE_C_COMPILER_ID} MATCHES "GNU")
target_compile_options(${PROJECT} PUBLIC
"$<$<CONFIG:RELEASE>:-O3>"
"$<$<CONFIG:DEBUG>:-Og>"
"$<$<CONFIG:DEBUG>:-gdwarf>"
"$<$<CONFIG:DEBUG>:-DDEBUG>"
"-Wall"
"-Wextra"
"-Wshadow"
)
elseif (${CMAKE_C_COMPILER_ID} MATCHES "Clang")
target_compile_options(${PROJECT} PUBLIC
"$<$<CONFIG:RELEASE>:-O3>"
"$<$<CONFIG:DEBUG>:-O0>"
"$<$<CONFIG:DEBUG>:-Og>"
"$<$<CONFIG:DEBUG>:-gdwarf>"
"$<$<CONFIG:DEBUG>:-DDEBUG>"
"-Weverything"
"-Wno-gnu-zero-variadic-macro-arguments"
"-Wno-weak-vtables"
"-fno-omit-frame-pointer"
"-fsanitize=integer"
"-fsanitize=undefined"
"-fno-sanitize=vptr"
)
endif ()
target_link_libraries(${PROJECT}
${PROGRAM_LIBS}
"$<$<C_COMPILER_ID:Clang>:-fsanitize=integer>"
"$<$<C_COMPILER_ID:Clang>:-fsanitize=undefined>"
"$<$<C_COMPILER_ID:Clang>:-fsanitize=vptr>"
)