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