-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
155 lines (126 loc) · 3.52 KB
/
CMakeLists.txt
File metadata and controls
155 lines (126 loc) · 3.52 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
cmake_minimum_required(VERSION 4.2.0 FATAL_ERROR)
######## Project information ########
set(Project_Title Pinkamena)
set(Project_Version 0.0.0)
set(Project_Author)
list(APPEND Project_Author "Clara")
#####################################
# Configure project
project(${Project_Title} LANGUAGES CXX VERSION ${Project_Version})
set(CMAKE_CXX_STANDARD 23 REQUIRED ON)
### Options ###
## OPTION: ENABLE_LTO
# Enable Link Time Optimizations (LTO) on Release build type. On by Default.
# This MAY cause problems on some systems.
# If it does, it can be disabled with -DENABLE_LTO=OFF.
option(ENABLE_LTO "Enable Link Time Optimizations" ON)
# Set the CMake Build Type to Release by default
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
# Define some flags for increased performance
set(SYSTEM_TUNING_FLAGS "-march=native -mtune=native -pipe -O3")
# Add LTO flags if enabled
if(ENABLE_LTO)
set(SYSTEM_TUNING_FLAGS "${SYSTEM_TUNING_FLAGS} -flto")
endif()
### Project Sources ###
set(PROJECT_HEADERS
include/Changeling.hpp
include/Game.hpp
include/Pony.hpp
include/Role.hpp
include/RoleResult.hpp
include/SuicideReason.hpp
include/roles/Bodyguard.hpp
include/roles/ChangelingConsort.hpp
include/roles/ChangelingDrone.hpp
include/roles/ChangelingForger.hpp
include/roles/ChangelingQueen.hpp
include/roles/Drunk.hpp
include/roles/Gumshoe.hpp
include/roles/Jailor.hpp
include/roles/Mule.hpp
include/roles/Nurse.hpp
include/roles/PartyPony.hpp
include/roles/Pinkamena.hpp
include/roles/Reporter.hpp
include/roles/Spellcaster.hpp
include/roles/Veteran.hpp
include/roles/Watchpony.hpp
)
set(PROJECT_SOURCES
src/main.cpp
src/Changeling.cpp
src/Game.cpp
src/Pony.cpp
src/RoleResult.cpp
src/roles/Bodyguard.cpp
src/roles/ChangelingConsort.cpp
src/roles/ChangelingDrone.cpp
src/roles/ChangelingForger.cpp
src/roles/ChangelingQueen.cpp
src/roles/Drunk.cpp
src/roles/Gumshoe.cpp
src/roles/Jailor.cpp
src/roles/Mule.cpp
src/roles/Nurse.cpp
src/roles/PartyPony.cpp
src/roles/Pinkamena.cpp
src/roles/Reporter.cpp
src/roles/Spellcaster.cpp
src/roles/Veteran.cpp
src/roles/Watchpony.cpp
)
set(COMPILER_FLAGS
-Wall
-Wextra
-Wpedantic
-Wshadow
-Wconversion
)
set(LINKER_FLAGS
"${COMPILER_FLAGS}"
)
# Target binary
add_executable(${PROJECT_NAME} ${PROJECT_HEADERS} ${PROJECT_SOURCES})
# Configure CXX properties
set_target_properties(${PROJECT_NAME} PROPERTIES
CXX_STANDARD ${CMAKE_CXX_STANDARD}
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
)
# Add diagnostic flags for Debug build type
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(COMPILER_FLAGS
${COMPILER_FLAGS}
-O0
-g
-fno-limit-debug-info
-fsanitize=address
-fsanitize=undefined
-fstack-protector-strong
)
set(LINKER_FLAGS
"${COMPILER_FLAGS}"
"${LINKER_FLAGS}"
)
endif()
# Add additional flags for performance to Release build type
if(CMAKE_BUILD_TYPE STREQUAL "Release")
set(COMPILER_FLAGS
"${COMPILER_FLAGS}"
"${SYSTEM_TUNING_FLAGS}"
-Werror
)
set(LINKER_FLAGS
"${COMPILER_FLAGS}"
"${LINKER_FLAGS}"
-s
)
endif()
# Add compiler and linker flags
target_compile_options(${PROJECT_NAME} PUBLIC "${COMPILER_FLAGS}")
target_link_libraries(${PROJECT_NAME} PUBLIC "${LINKER_FLAGS}")
# Project include directory
target_include_directories(${PROJECT_NAME} PUBLIC include/)