-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
256 lines (200 loc) · 7.27 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
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
#
cmake_minimum_required(VERSION 3.20)
project(wish)
#set(CMAKE_VERBOSE_MAKEFILE on)
#include(cmake/wish.cmake) # Normal include would be this
include(cmake/wish/wish_core.cmake)
# --------------------------------------------------------------------------------------------------
wish_configurations(debug optdebug dev DEFAULT release package)
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
message(STATUS "Processor count: ${WISH_PROCESSOR_COUNT}")
message(STATUS "CXX compiler id: ${CMAKE_CXX_COMPILER_ID}")
message(STATUS "CXX compiler version: ${CMAKE_CXX_COMPILER_VERSION}")
#message(STATUS "Git branch: ${WISH_GIT_BRANCH}")
#message(STATUS "Git commit: ${WISH_GIT_COMMIT_HASH}")
# Paths --------------------------------------------------------------------------------------------
set(PATH_EXT_IDE ext)
set(PATH_EXT ${CMAKE_SOURCE_DIR}/${PATH_EXT_IDE})
set(PATH_EXT_SRC ${CMAKE_SOURCE_DIR}/ext_src)
# --- Options --------------------------------------------------------------------------------------
option(MY_PROJECT_FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GNU/Clang only)." FALSE)
wish_force_colored_output(${MY_PROJECT_FORCE_COLORED_OUTPUT})
option(MY_PROJECT_SKIP_EXTERNAL_CONFIGURES "Do not configure external projects only use the fake interface targets" FALSE)
wish_skip_external_configures(${MY_PROJECT_SKIP_EXTERNAL_CONFIGURES})
option(MY_PROJECT_ALTERNATIVE_LINKER "Use an alternative linker. Leave empty for system default; alternatives are 'gold', 'lld', 'bfd', 'mold'" "")
wish_alternative_linker(${MY_PROJECT_ALTERNATIVE_LINKER})
option(MY_PROJECT_ENABLE_IPO "Enable (LTO) interprocedural optimization" FALSE)
wish_enable_ipo(${MY_PROJECT_ENABLE_IPO})
option(MY_PROJECT_WERROR "Specify whether to treat warnings on compile as errors." FALSE)
wish_werror(${MY_PROJECT_WERROR})
# --- Flags ----------------------------------------------------------------------------------------
wish_warning(
MSVC /Wall
Clang -Weverything
Clang -Wmissing-override
Clang -Wconversion
GNU -Wall
GNU -Warray-bounds
GNU -Wcast-align=strict
GNU -Wcast-qual
GNU -Wconversion
GNU -Wdelete-non-virtual-dtor
GNU -Wdouble-promotion
GNU -Wduplicated-branches
GNU -Wduplicated-cond
GNU -Wextra
GNU -Wlogical-op
GNU -Wmultistatement-macros
GNU -Wnon-virtual-dtor # Causes some false positives with efsw (suppressed)
GNU -Wold-style-cast
GNU -Wpedantic
GNU -Wrestrict
GNU -Wshadow-compatible-local
GNU -Wsuggest-override
GNU -Wundef
# more warning:
# GNU -Wmissing-include-dirs
# GNU -Wdisabled-optimization,
# GNU -Wpadded,
# GNU -Wzero-as-null-pointer-constant,
# maybe even:
# GNU -Wswitch-enum, and take a look at:
# GNU -Wunsafe-loop-optimizations,
# GNU -Wdangling-else
# Enablement in progress:
# GNU -Wuseless-cast # in vec_base_t has some false positive issue with this one, but otherwise clear
# GNU -Wfloat-equal # some in tests, and some in ui might be true positive, ui got some true positive with ratio
# Only enable time-to-time to check on what is going on:
# GNU -Winline
# GNU -Wsuggest-final-methods # in signal 50+ function
# GNU -Wsuggest-final-types # in signal 1 type
# With GCC 12.1 some false positives warnings appeared and some do ignore the system header includes
GNU VERSION_GREATER 12.0 -Wno-array-bounds
GNU VERSION_GREATER 12.0 -Wno-stringop-overread
GNU VERSION_GREATER 12.0 -Wno-stringop-overflow
# Warnings that I don't care about
Clang -Wno-comment
GNU -Wno-comment
# GNU -Wnull-dereference # Causes too many false positives as of GCC 11.2
# GNU -Werror
)
wish_compiler_flags(
GNU -fcoroutines
GNU -m64
GNU -std=c++23
)
#wish_linker_flags(
# Release GNU -mwindows # It specifies that a GUI application is to be generated by instructing the linker to set the PE header subsystem type appropriately.
## GNU -municode # It causes the UNICODE preprocessor macro to be predefined, and chooses Unicode-capable runtime startup code.
#)
wish_optimization_flags()
# Includes Directories -----------------------------------------------------------------------------
include_directories(app)
include_directories(src)
# === External ====================================================================================
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
find_package(OpenGL REQUIRED)
wish_group(group_external ext) # --- External -----------------------------------------------------
wish_create_external(
NAME catch
GIT_REPOSITORY https://github.com/catchorg/Catch2
GIT_TAG v3.3.2
CMAKE_ARGS
-DCATCH_INSTALL_DOCS=OFF
-DCATCH_INSTALL_EXTRAS=OFF
LINK Catch2Main Catch2
)
wish_create_external(
NAME fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
GIT_TAG 8.1.1
CMAKE_ARGS
-DFMT_DOC=OFF
-DFMT_TEST=OFF
-DBUILD_SHARED_LIBS=OFF
LINK fmt
)
wish_create_external(
NAME lua
GIT_REPOSITORY https://github.com/walterschell/Lua.git
GIT_TAG 14f98e5fdcde3ccd7ea9188181dd7e50660a2999 # v5.4.4
CMAKE_ARGS
-DLUA_ENABLE_SHARED=OFF
-DLUA_BUILD_BINARY=OFF
-DLUA_BUILD_COMPILER=OFF
-DLUA_SUPPORT_DL=OFF
LINK lua_static
)
wish_create_external(
NAME sol2
GIT_REPOSITORY https://github.com/ThePhD/sol2.git
GIT_TAG v3.3.0
CMAKE_ARGS
# -DSOL2_BUILD_LUA=ON
# -DSOL2_LUA_VERSION="5.4.4"
-DSOL2_DOCS=OFF
LINK ext_lua
)
#wish_create_external(
# NAME vide
# GIT_REPOSITORY https://github.com/cpplibv/vide.git
# GIT_TAG 0a8204b7d4e2ae83540cb8418efd21157f8202ab
# CMAKE_ARGS
# -DJUST_INSTALL_VIDE=ON
#)
# === Targets =====================================================================================
wish_group(group_application app) # --- Application -----------------------------------------------
wish_create_executable(
TARGET codegen
SOURCE app/codegen/codegen_main.cpp
LINK ext_fmt ext_sol2
# LINK ext_fmt ext_range libv_lua libv_utility libv_algo
)
#wish_group(group_example example) # --- Example ---------------------------------------------------
wish_group(group_generator generator) # --- Generator ---------------------------------------------
wish_generator(
TARGET codegen
COMMAND codegen
# OUTPUT REPLACE ".in.lua" ".hpp"
OUTPUT REPLACE ".inh.lua" ".hpp"
OUTPUT REPLACE ".ins.lua" ".hpp"
OUTPUT REPLACE ".ins.lua" ".cpp"
)
wish_group(group_library lib) # --- Library -------------------------------------------------------
wish_create_library(
TARGET libA STATIC
SOURCE src/libA/*.cpp
GENERATE codegen src/libA/*.in?.lua
LINK Threads::Threads
)
wish_create_library(
TARGET libB STATIC
SOURCE src/libB/*.cpp
LINK Threads::Threads
)
wish_group(group_sandbox sandbox) # --- Sandbox ---------------------------------------------------
wish_create_executable(
TARGET sandboxA
SOURCE src/main.cpp
LINK libA Threads::Threads
)
wish_create_executable(
TARGET sandboxB
SOURCE src/main.cpp
LINK libA Threads::Threads
)
wish_group(group_test test) # --- Test ------------------------------------------------------------
wish_create_executable(
TARGET test_libA
SOURCE test/libA/*.cpp
LINK ext_catch libA
)
# -------------------------------------------------------------------------------------------------
include_directories(sandbox)
add_subdirectory(sandbox/aliases)
add_subdirectory(sandbox/smart_aliases)
add_subdirectory(sandbox/versions)
# -------------------------------------------------------------------------------------------------
wish_create_ide_target()