]> git.lizzy.rs Git - nothing.git/blob - CMakeLists.txt
(#1109) Add region actions to level format
[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/lt.h
50   src/system/lt_adapters.h
51   src/system/lt_adapters.c
52   src/system/nth_alloc.c
53   src/system/nth_alloc.h
54   src/system/stacktrace.c
55   src/system/stacktrace.h
56   src/system/str.c
57   src/system/str.h
58   src/dynarray.h
59   src/dynarray.c
60   src/hashset.h
61   src/hashset.c
62   src/system/file.h
63   src/system/file.c
64   )
65
66 add_executable(nothing 
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/action.h
98   src/game/level_picker.c
99   src/game/level_picker.h
100   src/game/level_folder.h
101   src/game/level_folder.c
102   src/game/sound_samples.c
103   src/game/sound_samples.h
104   src/game/sprite_font.c
105   src/game/sprite_font.h
106   src/main.c
107   src/math/extrema.h
108   src/math/mat3x3.h
109   src/math/pi.h
110   src/math/vec.h
111   src/math/rand.c
112   src/math/rand.h
113   src/math/rect.c
114   src/math/rect.h
115   src/math/triangle.c
116   src/math/triangle.h
117   src/sdl/renderer.c
118   src/sdl/renderer.h
119   src/sdl/texture.h
120   src/sdl/texture.c
121   src/ui/console.c
122   src/ui/console.h
123   src/ui/console_log.c
124   src/ui/console_log.h
125   src/ui/edit_field.c
126   src/ui/edit_field.h
127   src/ui/history.c
128   src/ui/history.h
129   src/ui/list_selector.h
130   src/ui/list_selector.c
131   src/ui/wiggly_text.h
132   src/ui/wiggly_text.c
133   src/ui/slider.h
134   src/ui/slider.c
135   src/game/level_metadata.h
136   src/game/level_metadata.c
137   src/game/level/level_editor.h
138   src/game/level/level_editor.c
139   src/game/level/level_editor/color_picker.h
140   src/game/level/level_editor/color_picker.c
141   src/game/level/level_editor/rect_layer.h
142   src/game/level/level_editor/rect_layer.c
143   src/game/level/level_editor/layer_picker.h
144   src/game/level/level_editor/layer_picker.c
145   src/game/level/level_editor/point_layer.h
146   src/game/level/level_editor/point_layer.c
147   src/game/level/level_editor/player_layer.h
148   src/game/level/level_editor/player_layer.c
149   src/game/level/level_editor/layer.h
150   src/game/level/level_editor/layer.c
151   src/game/level/level_editor/label_layer.c
152   src/game/level/level_editor/label_layer.h
153   src/game/level/level_editor/background_layer.c
154   src/game/level/level_editor/background_layer.h
155   src/game/level/level_editor/undo_history.h
156   src/game/level/level_editor/undo_history.c
157 )
158 target_link_libraries(nothing ${SDL2_LIBRARIES} system)
159
160 if(("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang"))
161   set(CMAKE_C_FLAGS
162     "${CMAKE_C_FLAGS} \
163      -Wall \
164      -Werror \
165      -Wextra \
166      -Wconversion \
167      -Wunused \
168      -Wunused-function \
169      -Wunused-label \
170      -Wunused-macros \
171      -Wunused-parameter \
172      -Wunused-value \
173      -Wunused-variable \
174      -Wcast-align \
175      -Wcast-qual \
176      -Wmissing-declarations \
177      -Wredundant-decls \
178      -Wmissing-prototypes \
179      -Wnested-externs \
180      -Wpointer-arith \
181      -Wshadow \
182      -Wstrict-prototypes \
183      -Wwrite-strings \
184      -Wswitch \
185      -Wmissing-field-initializers \
186      -fno-common \
187            -fno-strict-aliasing \
188      -pedantic \
189      -std=c11 \
190      -ggdb \
191      -O3")
192   target_link_libraries(nothing m)
193 elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
194   set(CMAKE_C_FLAGS
195     "${CMAKE_C_FLAGS} \
196     /Wall \
197     /WX \
198     /wd4127 \
199     /wd4201 \
200     /wd4204 \
201     /wd4255 \
202     /wd4389 \
203     /wd4668 \
204     /wd4702 \
205     /wd4710 \
206     /wd4777 \
207     /wd4820 \
208     /wd5045 \
209     /D \"_CRT_SECURE_NO_WARNINGS\"")
210 endif()
211 if(MINGW)
212   target_link_libraries(nothing hid setupapi Imm32 Version winmm)
213 elseif(WIN32)
214   target_link_libraries(nothing Imm32 Version winmm)
215 endif()