forked from tsoding/nothing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
241 lines (230 loc) · 6.81 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
cmake_minimum_required(VERSION 3.13)
project(nothing)
set(NOTHING_CI OFF CACHE BOOL "Indicates whether the build is running on CI or not")
if(WIN32)
# do the flags thing first.
if(MINGW)
add_compile_definitions(SDL_MAIN_HANDLED) # https://stackoverflow.com/a/25089610
add_compile_definitions(__USE_MINGW_ANSI_STDIO) # https://github.com/trink/symtseries/issues/49#issuecomment-160843756
endif()
# then try to find SDL2 using normal means (eg. the user may have installed SDL2 using pacman on msys2)
# note we don't use REQUIRED here, because it can fail -- in which case we fall back to looking for the
# library "directly" using local files.
find_package(SDL2 QUIET)
if(NOT SDL2_FOUND)
if(MINGW)
# Support both 32 and 64 bit builds
if (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
set(SDL2_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/SDL2/x86_64-w64-mingw32/include/SDL2")
set(SDL2_LIBRARIES "${CMAKE_SOURCE_DIR}/SDL2/x86_64-w64-mingw32/lib/libSDL2.a;${CMAKE_SOURCE_DIR}/SDL2/x86_64-w64-mingw32/lib/libSDL2main.a")
else()
set(SDL2_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/SDL2/i686-w64-mingw32/include/SDL2")
set(SDL2_LIBRARIES "${CMAKE_SOURCE_DIR}/SDL2/i686-w64-mingw32/lib/libSDL2.a;${CMAKE_SOURCE_DIR}/SDL2/i686-w64-mingw32/lib/libSDL2main.a")
endif()
else()
set(SDL2_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/SDL2/include")
# Support both 32 and 64 bit builds
if (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
set(SDL2_LIBRARIES "${CMAKE_SOURCE_DIR}/SDL2/lib/x64/SDL2.lib;${CMAKE_SOURCE_DIR}/SDL2/lib/x64/SDL2main.lib")
else()
set(SDL2_LIBRARIES "${CMAKE_SOURCE_DIR}/SDL2/lib/x86/SDL2.lib;${CMAKE_SOURCE_DIR}/SDL2/lib/x86/SDL2main.lib")
endif()
endif()
string(STRIP "${SDL2_LIBRARIES}" SDL2_LIBRARIES)
endif()
else()
find_package(SDL2 REQUIRED)
endif()
if("${SDL2_LIBRARIES}" STREQUAL "")
message(WARNING "SDL2_LIBRARIES wasn't set, manually setting to SDL2::SDL2")
set(SDL2_LIBRARIES "SDL2::SDL2")
endif()
include_directories(${CMAKE_BINARY_DIR})
include_directories(src/)
include_directories(${SDL2_INCLUDE_DIRS})
add_library(system STATIC
src/system/line_stream.h
src/system/line_stream.c
src/system/log.h
src/system/log.c
src/system/lt.h
src/system/lt_adapters.h
src/system/lt_adapters.c
src/system/nth_alloc.h
src/system/nth_alloc.c
src/system/stacktrace.h
src/system/stacktrace.c
src/system/str.h
src/system/str.c
src/dynarray.h
src/dynarray.c
src/hashset.h
src/hashset.c
src/system/file.h
src/system/file.c
)
add_executable(nothing
src/color.h
src/color.c
src/game.h
src/game.c
src/game/camera.h
src/game/camera.c
src/game/level.h
src/game/level.c
src/game/level/background.h
src/game/level/background.c
src/game/level/boxes.h
src/game/level/boxes.c
src/game/level/goals.h
src/game/level/goals.c
src/game/level/labels.h
src/game/level/labels.c
src/game/level/lava.h
src/game/level/lava.c
src/game/level/lava/wavy_rect.h
src/game/level/lava/wavy_rect.c
src/game/level/platforms.h
src/game/level/platforms.c
src/game/level/player.h
src/game/level/player.c
src/game/level/explosion.h
src/game/level/explosion.c
src/game/level/regions.h
src/game/level/regions.c
src/game/level/rigid_bodies.h
src/game/level/rigid_bodies.c
src/game/level/action.h
src/game/level_picker.h
src/game/level_picker.c
src/game/settings.h
src/game/settings.c
src/game/level_folder.c
src/game/level_folder.h
src/game/sound_samples.h
src/game/sound_samples.c
src/game/sprite_font.h
src/game/sprite_font.c
src/main.c
src/math/extrema.h
src/math/mat3x3.h
src/math/pi.h
src/math/vec.h
src/math/rand.h
src/math/rand.c
src/math/rect.h
src/math/rect.c
src/math/triangle.h
src/math/triangle.c
src/sdl/renderer.h
src/sdl/renderer.c
src/sdl/texture.h
src/sdl/texture.c
src/ui/cursor.c
src/ui/cursor.h
src/ui/console.h
src/ui/console.c
src/ui/console_log.h
src/ui/console_log.c
src/ui/edit_field.h
src/ui/edit_field.c
src/ui/history.h
src/ui/history.c
src/ui/list_selector.h
src/ui/list_selector.c
src/ui/wiggly_text.h
src/ui/wiggly_text.c
src/ui/slider.h
src/ui/slider.c
src/ui/grid.h
src/ui/grid.c
src/game/level_metadata.h
src/game/level_metadata.c
src/game/level/level_editor.h
src/game/level/level_editor.c
src/game/level/level_editor/color_picker.h
src/game/level/level_editor/color_picker.c
src/game/level/level_editor/rect_layer.h
src/game/level/level_editor/rect_layer.c
src/game/level/level_editor/layer_picker.h
src/game/level/level_editor/layer_picker.c
src/game/level/level_editor/point_layer.h
src/game/level/level_editor/point_layer.c
src/game/level/level_editor/player_layer.h
src/game/level/level_editor/player_layer.c
src/game/level/level_editor/layer.h
src/game/level/level_editor/layer.c
src/game/level/level_editor/label_layer.h
src/game/level/level_editor/label_layer.c
src/game/level/level_editor/background_layer.h
src/game/level/level_editor/background_layer.c
src/game/level/level_editor/undo_history.h
src/game/level/level_editor/undo_history.c
src/game/level/level_editor/action_picker.h
src/game/level/level_editor/action_picker.c
)
target_link_libraries(nothing ${SDL2_LIBRARIES} system)
ADD_CUSTOM_TARGET(link_assets ALL
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_SOURCE_DIR}/assets ${CMAKE_BINARY_DIR}/assets)
if(("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang"))
set(CMAKE_C_FLAGS
"${CMAKE_C_FLAGS} \
-Wall \
-Wextra \
-Wconversion \
-Wunused \
-Wunused-function \
-Wunused-label \
-Wunused-macros \
-Wunused-parameter \
-Wunused-value \
-Wunused-variable \
-Wcast-align \
-Wcast-qual \
-Wmissing-declarations \
-Wredundant-decls \
-Wmissing-prototypes \
-Wnested-externs \
-Wpointer-arith \
-Wshadow \
-Wstrict-prototypes \
-Wwrite-strings \
-Wswitch \
-Wmissing-field-initializers \
-fno-common \
-fno-strict-aliasing \
-pedantic \
-std=c11 \
-ggdb \
-O3")
if (${NOTHING_CI})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
endif()
target_link_libraries(nothing m)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(CMAKE_C_FLAGS
"${CMAKE_C_FLAGS} \
/Wall \
/wd4127 \
/wd4201 \
/wd4204 \
/wd4255 \
/wd4389 \
/wd4668 \
/wd4702 \
/wd4710 \
/wd4777 \
/wd4820 \
/wd5045 \
/wd4200 \
/wd4706 \
/D \"_CRT_SECURE_NO_WARNINGS\"")
if (${NOTHING_CI})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
endif()
endif()
if(MINGW)
target_link_libraries(nothing hid setupapi Imm32 Version winmm)
elseif(WIN32)
target_link_libraries(nothing Imm32 Version winmm)
endif()