]> git.lizzy.rs Git - nothing.git/blob - CMakeLists.txt
(#532) Proper SDL2 includes
[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 include_directories(${CMAKE_BINARY_DIR})
20 include_directories(src/)
21
22 include_directories(${SDL2_INCLUDE_DIRS})
23
24 add_library(system STATIC
25   src/system/line_stream.c
26   src/system/line_stream.h
27   src/system/log.c
28   src/system/log.h
29   src/system/log_script.c
30   src/system/log_script.h
31   src/system/lt.h
32   src/system/nth_alloc.c
33   src/system/nth_alloc.h
34   src/system/stacktrace.c
35   src/system/stacktrace.h
36   src/system/str.c
37   src/system/str.h
38   src/dynarray.h
39   src/dynarray.c
40   src/hashset.h
41   src/hashset.c
42   )
43
44 add_library(ebisp STATIC
45   src/ebisp/builtins.c
46   src/ebisp/builtins.h
47   src/ebisp/expr.c
48   src/ebisp/expr.h
49   src/ebisp/gc.c
50   src/ebisp/gc.h
51   src/ebisp/interpreter.c
52   src/ebisp/interpreter.h
53   src/ebisp/parser.c
54   src/ebisp/parser.h
55   src/ebisp/scope.c
56   src/ebisp/scope.h
57   src/ebisp/std.c
58   src/ebisp/std.h
59   src/ebisp/tokenizer.c
60   src/ebisp/tokenizer.h
61   )
62 target_link_libraries(ebisp system)
63
64 add_executable(nothing 
65   src/broadcast.c
66   src/broadcast.h
67   src/color.c
68   src/color.h
69   src/game.c
70   src/game.h
71   src/game/camera.c
72   src/game/camera.h
73   src/game/level.c
74   src/game/level.h
75   src/game/level/background.c
76   src/game/level/background.h
77   src/game/level/boxes.c
78   src/game/level/boxes.h
79   src/game/level/goals.c
80   src/game/level/goals.h
81   src/game/level/labels.c
82   src/game/level/labels.h
83   src/game/level/lava.c
84   src/game/level/lava.h
85   src/game/level/lava/wavy_rect.c
86   src/game/level/lava/wavy_rect.h
87   src/game/level/platforms.c
88   src/game/level/platforms.h
89   src/game/level/player.c
90   src/game/level/player.h
91   src/game/level/explosion.c
92   src/game/level/explosion.h
93   src/game/level/regions.c
94   src/game/level/regions.h
95   src/game/level/rigid_bodies.c
96   src/game/level/rigid_bodies.h
97   src/game/level/script.c
98   src/game/level/script.h
99   src/game/level_picker.c
100   src/game/level_picker.h
101   src/game/level_folder.h
102   src/game/level_folder.c
103   src/game/sound_samples.c
104   src/game/sound_samples.h
105   src/game/sprite_font.c
106   src/game/sprite_font.h
107   src/main.c
108   src/math/extrema.c
109   src/math/extrema.h
110   src/math/mat3x3.c
111   src/math/mat3x3.h
112   src/math/pi.h
113   src/math/point.c
114   src/math/point.h
115   src/math/rand.c
116   src/math/rand.h
117   src/math/rect.c
118   src/math/rect.h
119   src/math/triangle.c
120   src/math/triangle.h
121   src/sdl/renderer.c
122   src/sdl/renderer.h
123   src/sdl/texture.h
124   src/sdl/texture.c
125   src/ui/console.c
126   src/ui/console.h
127   src/ui/console_log.c
128   src/ui/console_log.h
129   src/ui/edit_field.c
130   src/ui/edit_field.h
131   src/ui/history.c
132   src/ui/history.h
133   src/ui/list_selector.h
134   src/ui/list_selector.c
135   src/ui/menu_title.h
136   src/ui/menu_title.c
137   src/game/level_metadata.h
138   src/game/level_metadata.c
139   src/game/level/level_editor/proto_rect.h
140   src/game/level/level_editor/proto_rect.c
141   src/game/level/level_editor.h
142   src/game/level/level_editor.c
143   src/game/level/level_editor/color_picker.h
144   src/game/level/level_editor/color_picker.c
145   src/game/level/level_editor/rect_layer.h
146   src/game/level/level_editor/rect_layer.c
147   src/game/level/level_editor/layer_picker.h
148   src/game/level/level_editor/layer_picker.c
149   src/game/level/level_editor/point_layer.h
150   src/game/level/level_editor/point_layer.c
151   src/game/level/level_editor/player_layer.h
152   src/game/level/level_editor/player_layer.c
153   src/game/level/level_editor/layer.h
154   src/game/level/level_editor/layer.c
155 )
156 target_link_libraries(nothing ${SDL2_LIBRARIES} system ebisp)
157
158 add_executable(repl
159   src/ebisp/repl.c
160   src/ebisp/repl_runtime.c
161   )
162 target_link_libraries(repl ${SDL2_LIBRARIES} system ebisp)
163
164 add_executable(nothing_test
165   test/main.c
166   test/test.h
167   test/tokenizer_suite.h
168   )
169 target_link_libraries(nothing_test ${SDL2_LIBRARIES} system ebisp)
170
171 if (UNIX)
172   add_subdirectory(devtools/svg2level)
173 endif()
174
175 if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "CLANG"))
176   set(CMAKE_C_FLAGS
177     "${CMAKE_C_FLAGS} \
178      -Wall \
179      -Werror \
180      -Wextra \
181      -Wconversion \
182      -Wunused \
183      -Wunused-function \
184      -Wunused-label \
185      -Wunused-macros \
186      -Wunused-parameter \
187      -Wunused-value \
188      -Wunused-variable \
189      -Wcast-align \
190      -Wcast-qual \
191      -Wmissing-declarations \
192      -Wredundant-decls \
193      -Wmissing-prototypes \
194      -Wnested-externs \
195      -Wpointer-arith \
196      -Wshadow \
197      -Wstrict-prototypes \
198      -Wwrite-strings \
199      -Wswitch \
200      -Wmissing-field-initializers \
201      -fno-common \
202      -pedantic \
203      -std=c11 \
204      -ggdb \
205      -O3")
206   target_link_libraries(nothing m)
207 endif()
208 if(WIN32)
209   target_link_libraries(nothing Imm32 Version winmm)
210 endif()
211
212 file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/sounds DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
213 file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/images DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
214 file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/test-data DESTINATION ${CMAKE_CURRENT_BINARY_DIR})