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