]> git.lizzy.rs Git - nothing.git/blob - CMakeLists.txt
Merge pull request #1089 from tsoding/vec
[nothing.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 3.2)
2 project(nothing)
3
4 if(WIN32)
5   if(MINGW)
6     add_compile_definitions(SDL_MAIN_HANDLED) # https://stackoverflow.com/a/25089610
7     add_compile_definitions(__USE_MINGW_ANSI_STDIO) # https://github.com/trink/symtseries/issues/49#issuecomment-160843756
8     # Support both 32 and 64 bit builds
9     if (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
10       set(SDL2_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/SDL2/x86_64-w64-mingw32/include/SDL2")
11       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")
12     else()
13       set(SDL2_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/SDL2/i686-w64-mingw32/include/SDL2")
14       set(SDL2_LIBRARIES "${CMAKE_SOURCE_DIR}/SDL2/i686-w64-mingw32/lib/libSDL2.a;${CMAKE_SOURCE_DIR}/SDL2/i686-w64-mingw32/lib/libSDL2main.a")
15     endif()
16           
17   else()
18     set(SDL2_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/SDL2/include")
19
20     # Support both 32 and 64 bit builds
21     if (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
22       set(SDL2_LIBRARIES "${CMAKE_SOURCE_DIR}/SDL2/lib/x64/SDL2.lib;${CMAKE_SOURCE_DIR}/SDL2/lib/x64/SDL2main.lib")
23     else()
24       set(SDL2_LIBRARIES "${CMAKE_SOURCE_DIR}/SDL2/lib/x86/SDL2.lib;${CMAKE_SOURCE_DIR}/SDL2/lib/x86/SDL2main.lib")
25     endif()
26
27   endif()
28   string(STRIP "${SDL2_LIBRARIES}" SDL2_LIBRARIES)
29   
30 else()
31   find_package(SDL2 REQUIRED)
32 endif()
33
34 if("${SDL2_LIBRARIES}" STREQUAL "")
35     message(WARNING "SDL2_LIBRARIES wasn't set, manually setting to SDL2::SDL2")
36     set(SDL2_LIBRARIES "SDL2::SDL2")
37 endif()
38
39 include_directories(${CMAKE_BINARY_DIR})
40 include_directories(src/)
41
42 include_directories(${SDL2_INCLUDE_DIRS})
43
44 add_library(system STATIC
45   src/system/line_stream.c
46   src/system/line_stream.h
47   src/system/log.c
48   src/system/log.h
49   src/system/log_script.c
50   src/system/log_script.h
51   src/system/lt.h
52   src/system/lt_adapters.h
53   src/system/lt_adapters.c
54   src/system/nth_alloc.c
55   src/system/nth_alloc.h
56   src/system/stacktrace.c
57   src/system/stacktrace.h
58   src/system/str.c
59   src/system/str.h
60   src/dynarray.h
61   src/dynarray.c
62   src/hashset.h
63   src/hashset.c
64   src/system/file.h
65   src/system/file.c
66   )
67
68 add_library(ebisp STATIC
69   src/ebisp/builtins.c
70   src/ebisp/builtins.h
71   src/ebisp/expr.c
72   src/ebisp/expr.h
73   src/ebisp/gc.c
74   src/ebisp/gc.h
75   src/ebisp/interpreter.c
76   src/ebisp/interpreter.h
77   src/ebisp/parser.c
78   src/ebisp/parser.h
79   src/ebisp/scope.c
80   src/ebisp/scope.h
81   src/ebisp/std.c
82   src/ebisp/std.h
83   src/ebisp/tokenizer.c
84   src/ebisp/tokenizer.h
85   )
86 target_link_libraries(ebisp system)
87
88 add_executable(nothing 
89   src/broadcast.c
90   src/broadcast.h
91   src/color.c
92   src/color.h
93   src/game.c
94   src/game.h
95   src/game/camera.c
96   src/game/camera.h
97   src/game/level.c
98   src/game/level.h
99   src/game/level/background.c
100   src/game/level/background.h
101   src/game/level/boxes.c
102   src/game/level/boxes.h
103   src/game/level/goals.c
104   src/game/level/goals.h
105   src/game/level/labels.c
106   src/game/level/labels.h
107   src/game/level/lava.c
108   src/game/level/lava.h
109   src/game/level/lava/wavy_rect.c
110   src/game/level/lava/wavy_rect.h
111   src/game/level/platforms.c
112   src/game/level/platforms.h
113   src/game/level/player.c
114   src/game/level/player.h
115   src/game/level/explosion.c
116   src/game/level/explosion.h
117   src/game/level/regions.c
118   src/game/level/regions.h
119   src/game/level/rigid_bodies.c
120   src/game/level/rigid_bodies.h
121   src/game/level/script.c
122   src/game/level/script.h
123   src/game/level_picker.c
124   src/game/level_picker.h
125   src/game/level_folder.h
126   src/game/level_folder.c
127   src/game/sound_samples.c
128   src/game/sound_samples.h
129   src/game/sprite_font.c
130   src/game/sprite_font.h
131   src/main.c
132   src/math/extrema.h
133   src/math/mat3x3.h
134   src/math/pi.h
135   src/math/vec.h
136   src/math/rand.c
137   src/math/rand.h
138   src/math/rect.c
139   src/math/rect.h
140   src/math/triangle.c
141   src/math/triangle.h
142   src/sdl/renderer.c
143   src/sdl/renderer.h
144   src/sdl/texture.h
145   src/sdl/texture.c
146   src/ui/console.c
147   src/ui/console.h
148   src/ui/console_log.c
149   src/ui/console_log.h
150   src/ui/edit_field.c
151   src/ui/edit_field.h
152   src/ui/history.c
153   src/ui/history.h
154   src/ui/list_selector.h
155   src/ui/list_selector.c
156   src/ui/wiggly_text.h
157   src/ui/wiggly_text.c
158   src/ui/slider.h
159   src/ui/slider.c
160   src/game/level_metadata.h
161   src/game/level_metadata.c
162   src/game/level/level_editor.h
163   src/game/level/level_editor.c
164   src/game/level/level_editor/color_picker.h
165   src/game/level/level_editor/color_picker.c
166   src/game/level/level_editor/rect_layer.h
167   src/game/level/level_editor/rect_layer.c
168   src/game/level/level_editor/layer_picker.h
169   src/game/level/level_editor/layer_picker.c
170   src/game/level/level_editor/point_layer.h
171   src/game/level/level_editor/point_layer.c
172   src/game/level/level_editor/player_layer.h
173   src/game/level/level_editor/player_layer.c
174   src/game/level/level_editor/layer.h
175   src/game/level/level_editor/layer.c
176   src/game/level/level_editor/label_layer.c
177   src/game/level/level_editor/label_layer.h
178   src/game/level/level_editor/background_layer.c
179   src/game/level/level_editor/background_layer.h
180   src/game/level/level_editor/undo_history.h
181   src/game/level/level_editor/undo_history.c
182 )
183 target_link_libraries(nothing ${SDL2_LIBRARIES} system ebisp)
184
185 add_executable(repl
186   src/ebisp/repl.c
187   src/ebisp/repl_runtime.c
188   )
189 target_link_libraries(repl ${SDL2_LIBRARIES} system ebisp)
190
191 add_executable(nothing_test
192   test/main.c
193   test/test.h
194   test/tokenizer_suite.h
195   )
196 target_link_libraries(nothing_test ${SDL2_LIBRARIES} system ebisp)
197
198 if(("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang"))
199   set(CMAKE_C_FLAGS
200     "${CMAKE_C_FLAGS} \
201      -Wall \
202      -Werror \
203      -Wextra \
204      -Wconversion \
205      -Wunused \
206      -Wunused-function \
207      -Wunused-label \
208      -Wunused-macros \
209      -Wunused-parameter \
210      -Wunused-value \
211      -Wunused-variable \
212      -Wcast-align \
213      -Wcast-qual \
214      -Wmissing-declarations \
215      -Wredundant-decls \
216      -Wmissing-prototypes \
217      -Wnested-externs \
218      -Wpointer-arith \
219      -Wshadow \
220      -Wstrict-prototypes \
221      -Wwrite-strings \
222      -Wswitch \
223      -Wmissing-field-initializers \
224      -fno-common \
225            -fno-strict-aliasing \
226      -pedantic \
227      -std=c11 \
228      -ggdb \
229      -O3")
230   target_link_libraries(nothing m)
231 elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
232   set(CMAKE_C_FLAGS
233     "${CMAKE_C_FLAGS} \
234     /Wall \
235     /WX \
236     /wd4127 \
237     /wd4201 \
238     /wd4204 \
239     /wd4255 \
240     /wd4389 \
241     /wd4668 \
242     /wd4702 \
243     /wd4710 \
244     /wd4777 \
245     /wd4820 \
246     /wd5045 \
247     /D \"_CRT_SECURE_NO_WARNINGS\"")
248 endif()
249 if(MINGW)
250   target_link_libraries(nothing hid setupapi Imm32 Version winmm)
251 elseif(WIN32)
252   target_link_libraries(nothing Imm32 Version winmm)
253 endif()
254
255 file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/test-data DESTINATION ${CMAKE_CURRENT_BINARY_DIR})