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