-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
269 lines (230 loc) · 7.68 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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
cmake_minimum_required(VERSION 3.12)
project(Birb2D)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
endif(CCACHE_FOUND)
option(SYSTEM_SDL "Link Birb2D dynamically against system SDL libraries instead of
compiling them from source" OFF)
option(STATIC_SDL "Use static linking for SDL" ON)
option(TESTS "Compile tests" OFF)
option(UTILS "Compile extra utilities" ON)
option(EXAMPLES "Compile examples" OFF)
option(RELEASE "Compile a release build" OFF)
option(JOYSTICK "Enable joystick support." OFF)
option(WINDOWS_BUILD "Enable some windows specific options" OFF)
option(PROFILER "Enable the profiler timers" OFF)
option(BUNDLED_ASSETS "Bundle game assets directly into the game binary" OFF)
option(DISTCC "Disable precompiled headers for better distcc performance" OFF)
option(MULTITHREAD "Enable multithreading. Mingw can have issues with this" ON)
if (BUNDLED_ASSETS)
add_definitions(-DBUNDLED_ASSETS)
endif()
if (DISTCC)
add_definitions(-DDISTCC)
endif()
if (RELEASE)
set(CMAKE_BUILD_TYPE Release)
set(STATIC_SDL ON)
else()
set(CMAKE_BUILD_TYPE Debug)
# Disable debug postfixes
set(DISABLE_FORCE_DEBUG_POSTFIX ON CACHE BOOL "Disable forced debug
postfixes")
set(SDL_CMAKE_DEBUG_POSTFIX "" CACHE STRING "Name suffix for debug builds")
set(SDL2IMAGE_DEBUG_POSTFIX "" CACHE STRING "Name suffix for debug builds")
set(SDL2MIXER_DEBUG_POSTFIX "" CACHE STRING "Name suffix for debug builds")
set(SDL2TTF_DEBUG_POSTFIX "" CACHE STRING "Name suffix for debug builds")
endif()
if (NOT JOYSTICK)
set(SDL_JOYSTICK OFF CACHE BOOL "Disable joystick support")
set(SDL_HAPTIC OFF CACHE BOOL "Disable haptic support")
endif()
if (WINDOWS_BUILD)
#add_definitions(-DWINDOWS)
set(UTILS OFF)
endif()
if (PROFILER)
# Enable microprofiler
add_compile_definitions(MICROPROFILE_ENABLED=1)
else()
# Disable microprofiler
add_compile_definitions(MICROPROFILE_ENABLED=0)
endif()
if (STATIC_SDL)
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build the library as a shared library")
endif()
if (MULTITHREAD)
add_compile_definitions(BIRB_MT)
endif()
# Include the microprofiler. It should get disabled by the
# MICROPROFILER_ENABLED variable if it is set to zero
add_subdirectory(vendor/microprofile)
# Include libzip and cppcodec if bunedled assets were enabled
if (BUNDLED_ASSETS)
find_package(ZLIB)
if (${ZLIB_FOUND})
set(ZLIB_USE_STATIC_LIBS "ON")
option(ENABLE_COMMONCRYPTO "Enable use of CommonCrypto" OFF)
option(ENABLE_GNUTLS "Enable use of GnuTLS" OFF)
option(ENABLE_MBEDTLS "Enable use of mbed TLS" OFF)
option(ENABLE_OPENSSL "Enable use of OpenSSL" OFF)
option(ENABLE_WINDOWS_CRYPTO "Enable use of Windows cryptography libraries" OFF)
option(ENABLE_BZIP2 "Enable use of BZip2" OFF)
option(ENABLE_LZMA "Enable use of LZMA" OFF)
option(ENABLE_ZSTD "Enable use of Zstandard" OFF)
option(BUILD_TOOLS "Build tools in the src directory (zipcmp, zipmerge,
ziptool)" OFF)
option(BUILD_REGRESS "Build regression tests" OFF)
option(BUILD_EXAMPLES "Build examples" OFF)
option(BUILD_DOC "Build documentation" OFF)
option(LIBZIP_DO_INSTALL "Install libzip and the related files" OFF)
option(SHARED_LIB_VERSIONNING "Add SO version in .so build" OFF)
add_subdirectory(vendor/libzip)
add_subdirectory(vendor/cppcodec)
include_directories(vendor/cppcodec)
endif()
endif()
if (SYSTEM_SDL)
add_definitions(-DSYSTEM_SDL)
else()
if (STATIC_SDL)
set(BUILD_STATIC ON CACHE BOOL "Build static libs")
set(SDL2IMAGE_VENDORED ON CACHE BOOL "Use vendored third-party libraries")
set(SDL2MIXER_VENDORED ON CACHE BOOL "Use vendored third-party libraries")
set(SDL2TTF_VENDORED ON CACHE BOOL "Use vendored third-party libraries")
add_definitions(-DSTATIC_SDL)
else()
set(BUILD_SHARED_LIBS ON CACHE BOOL "Build the library as a shared library")
endif()
# Disable some unnecessary SDL stuff
set(SDL2_DISABLE_SDL2MAIN OFF CACHE BOOL "Disable building/installation of
SDL2main")
set(SDL2IMAGE_INSTALL OFF CACHE BOOL "Enable SDL2_image install target")
set(SDL2IMAGE_SAMPLES OFF CACHE BOOL "Build the SDL2_image sample program(s)")
set(SDL2MIXER_INSTALL OFF CACHE BOOL "Enable SDL2mixer install target")
set(SDL2MIXER_SAMPLES OFF CACHE BOOL "Build the SDL2_mixer sample program(s)")
set(SDL2TTF_SAMPLES OFF CACHE BOOL "Build the SDL2_ttf sample program(s)")
set(SDL2TTF_INSTALL OFF CACHE BOOL "Enable SDL2_ttf install target")
# Toggle off some rare image formats
set(SDL2IMAGE_LBM OFF CACHE BOOL "Support loading LBM images")
set(SDL2IMAGE_PCX OFF CACHE BOOL "Support loading PCX images")
set(SDL2IMAGE_PNM OFF CACHE BOOL "Support loading PNM images")
set(SDL2IMAGE_QOI OFF CACHE BOOL "Support loading QOI images")
set(SDL2IMAGE_XCF OFF CACHE BOOL "Support loading XCF images")
set(SDL2IMAGE_XPM OFF CACHE BOOL "Support loading XPM images")
set(SDL2IMAGE_XV OFF CACHE BOOL "Support loading XV images")
add_subdirectory(vendor/SDL)
include_directories(vendor/SDL/include)
add_subdirectory(vendor/SDL_image)
add_subdirectory(vendor/SDL_mixer)
add_subdirectory(vendor/SDL_ttf)
add_subdirectory(vendor/SDL2_gfx)
endif()
include_directories(include/)
set(CORE_SRC
src/appinfo.cpp
src/assetmanager.cpp
src/audio.cpp
src/baseentity.cpp
src/circle.cpp
src/color.cpp
src/errorfuse.cpp
src/filesystem.cpp
src/font.cpp
src/frametimegraph.cpp
src/game.cpp
src/graphs.cpp
src/input.cpp
src/keep.cpp
src/level.cpp
src/line.cpp
src/logger.cpp
src/mainmenu.cpp
src/mainmenusettings.cpp
src/math.cpp
src/particlesource.cpp
src/physics.cpp
src/polygon.cpp
src/random.cpp
src/rect.cpp
src/render.cpp
src/renderwindow.cpp
src/resourcemonitor.cpp
src/resources.cpp
src/scene.cpp
src/sceneobject.cpp
src/splash.cpp
src/stopwatch.cpp
src/texture.cpp
src/timer.cpp
src/timestep.cpp
src/ui.cpp
src/utils.cpp
src/Vector/vector3.cpp
src/Vector/vector3int.cpp
src/Vector/vector2.cpp
src/Vector/vector2int.cpp
src/Entities/animation.cpp
src/Entities/button.cpp
src/Entities/empty.cpp
src/Entities/image.cpp
src/Entities/progressbar.cpp
src/Entities/text.cpp
src/particlepattern.cpp
src/ParticlePatterns/randomizedcircle.cpp
src/ParticlePatterns/randomizedsquare.cpp
src/ParticlePatterns/spiral.cpp
src/ParticlePatterns/stablecircle.cpp
src/ParticlePatterns/stablesquare.cpp
)
add_library(birb2d STATIC ${CORE_SRC})
target_include_directories(birb2d PUBLIC vendor/SDL2_gfx)
if (PROFILER)
# Compiler with less warnings when using microprofile. Microprofile
# doesn't compile with some warnings set as errors
target_compile_options(birb2d PRIVATE -pedantic -Wall -Wextra -Wcast-align
-Wcast-qual -Wdisabled-optimization -Wformat=2
-Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs
-Wnoexcept -Woverloaded-virtual -Wsign-promo -Wstrict-null-sentinel -Werror -Wno-unused)
else()
target_compile_options(birb2d PRIVATE -pedantic -Wall -Wextra -Wcast-align
-Wcast-qual -Wdisabled-optimization -Wformat=2
-Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs
-Wnoexcept -Woverloaded-virtual -Wsign-promo -Wstrict-null-sentinel -Wundef -Werror -Wno-unused)
endif()
target_link_libraries(birb2d
#SDL2
SDL2main
SDL2_image
SDL2_ttf
SDL2_mixer
SDL2_gfx
microprofile
)
if (${ZLIB_FOUND})
target_link_libraries(birb2d zip)
endif()
if (NOT DISTCC)
target_precompile_headers(birb2d PUBLIC
include/SDL.hpp
include/STD.hpp
include/json.hpp
vendor/microprofile/microprofile.h
vendor/cppcodec/cppcodec/base64_rfc4648.hpp)
endif()
# Compile tests if enabled
if (TESTS)
add_subdirectory(tests)
endif()
# Compile examples if enabled
if (EXAMPLES)
add_subdirectory(examples)
endif()
# Add utilities
if (UTILS)
add_subdirectory(utils)
endif()