forked from msokalski/asciicker
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
241 lines (224 loc) · 4.37 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
cmake_minimum_required(VERSION 3.19...3.29)
project(asciicker LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 17)
# --- External libraries
find_package(OpenGL REQUIRED)
find_library(SDL_LIBRARY
NAMES SDL2 SDL
HINTS ${SDL_ROOT} ENV SDL_ROOT
PATH_SUFFIXES lib/x64
REQUIRED
)
find_path(SDL_INCLUDE_DIR
NAMES SDL.h
HINTS ${SDL_ROOT} ENV SDL_ROOT
PATH_SUFFIXES include SDL2
REQUIRED
)
if(APPLE)
find_library(V8_LIBRARY
NAMES v8
REQUIRED
)
find_library(V8_BASE_LIBRARY
NAMES v8_libbase
REQUIRED
)
find_library(V8_PLATFORM_LIBRARY
NAMES v8_libplatform
REQUIRED
)
set(V8_LIBRARIES ${V8_LIBRARY} ${V8_BASE_LIBRARY} ${V8_PLATFORM_LIBRARY})
else()
find_library(V8_LIBRARIES
NAMES v8_monolith
REQUIRED)
endif()
find_path(V8_INCLUDE_DIR
NAMES libplatform/libplatform.h
REQUIRED
)
message(STATUS "V8_INCLUDE_DIR: ${V8_INCLUDE_DIR}
V8_LIBRARIES: ${V8_LIBRARIES}")
find_library(GPM_LIBRARY NAMES gpm)
find_path(GPM_INCLUDE_DIR NAMES gpm.h)
if(GPM_LIBRARY AND GPM_INCLUDE_DIR)
set(GPM_FOUND true)
else()
message(STATUS "GPM not found")
endif()
if(WIN32)
set(WINSOCK_LIBRARIES ws2_32)
elseif(UNIX)
find_package(X11 REQUIRED)
find_package(Threads REQUIRED)
find_library(UTIL_LIBRARY NAMES util REQUIRED)
endif()
if(APPLE)
find_path(UTIL_INCLUDE_DIR NAMES util.h REQUIRED)
elseif(UNIx)
find_path(UTIL_INCLUDE_DIR NAMES pty.h REQUIRED)
endif()
# --- executables
add_executable(asciiid asciiid.cpp
audio.cpp
stb_vorbis.cpp
term.cpp
sdl.cpp
urdo.cpp
font1.cpp
gamepad.cpp
game.cpp
enemygen.cpp
render.cpp
terrain.cpp
world.cpp
inventory.cpp
physics.cpp
sprite.cpp
texheap.cpp
rgba8.cpp
upng.c
tinfl.c
gl.c
gl45_emu.cpp
imgui_impl_opengl3.cpp
imgui/imgui.cpp
imgui/imgui_demo.cpp
imgui/imgui_draw.cpp
imgui/imgui_widgets.cpp
$<$<BOOL:${UNIX}>:x11.cpp>
$<$<BOOL:${WIN32}>:mswin.cpp>
)
target_include_directories(asciiid PRIVATE
$<$<BOOL:${UNIX}>:${UTIL_INCLUDE_DIR}>
${SDL_INCLUDE_DIR}
)
target_link_libraries(asciiid PRIVATE OpenGL::GL
"$<$<BOOL:${UNIX}>:X11::Xinerama;X11::X11;${UTIL_LIBRARY}>"
${SDL_LIBRARY}
${CMAKE_DL_LIBS}
)
target_compile_definitions(asciiid PRIVATE EDITOR UNICODE
USE_SDL
$<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
)
if(APPLE)
target_link_libraries(asciiid PRIVATE "-framework AudioToolbox" "-framework Foundation")
endif()
add_executable(game
gl.c
gl45_emu.cpp
sdl.cpp
term.cpp
font1.cpp
game.cpp
gamepad.cpp
mainmenu.cpp
game_api.cpp
enemygen.cpp
game_app.cpp
network.cpp
render.cpp
terrain.cpp
world.cpp
inventory.cpp
physics.cpp
sprite.cpp
upng.c
tinfl.c
rgba8.cpp
audio.cpp
stb_vorbis.cpp
$<$<BOOL:${UNIX}>:x11.cpp>
$<$<BOOL:${WIN32}>:mswin.cpp>
)
target_compile_definitions(game PRIVATE GAME UNICODE USE_SDL
$<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
V8_ENABLE_SANDBOX
)
target_include_directories(game PRIVATE
${SDL_INCLUDE_DIR}
${V8_INCLUDE_DIR}
)
target_link_libraries(game PRIVATE
${SDL_LIBRARY}
${V8_LIBRARIES}
$<$<BOOL:${UNIX}>:X11::X11>
OpenGL::GL
$<$<BOOL:${UNIX}>:Threads::Threads> ${WINSOCK_LIBRARIES}
${CMAKE_DL_LIBS}
)
if(APPLE)
target_link_libraries(game PRIVATE "-framework AudioToolbox" "-framework Foundation")
endif()
add_executable(game_term
game.cpp
mainmenu.cpp
game_api.cpp
gamepad.cpp
font1.cpp
enemygen.cpp
game_app.cpp
network.cpp
render.cpp
terrain.cpp
world.cpp
inventory.cpp
physics.cpp
sprite.cpp
upng.c
tinfl.c
rgba8.cpp
audio.cpp
stb_vorbis.cpp
$<$<BOOL:${WIN32}>:mswin.cpp>
)
target_compile_definitions(game_term PRIVATE GAME PURE_TERM UNICODE
$<$<BOOL:${GPM_FOUND}>:USE_GPM>
V8_ENABLE_SANDBOX
)
if(MSVC)
target_compile_definitions(game_term PRIVATE _CRT_SECURE_NO_WARNINGS
STDIN_FILENO=0 STDOUT_FILENO=1
)
endif()
target_include_directories(game_term PRIVATE
$<$<BOOL:${UNIX}>:${UTIL_INCLUDE_DIR}>
${V8_INCLUDE_DIR}
)
target_link_libraries(game_term PRIVATE
${V8_LIBRARIES}
OpenGL::GL
"$<$<BOOL:${UNIX}>:${UTIL_LIBRARY};Threads::Threads>"
$<$<BOOL:${WIN32}>:${WINSOCK_LIBRARIES}>
${CMAKE_DL_LIBS}
)
if(APPLE)
target_link_libraries(game_term PRIVATE "-framework AudioToolbox" "-framework Foundation")
endif()
add_executable(game_server game_svr.cpp
audio.cpp
stb_vorbis.cpp
network.cpp
sha1.c
font1.cpp
gamepad.cpp
game.cpp
enemygen.cpp
render.cpp
terrain.cpp
world.cpp
inventory.cpp
physics.cpp
sprite.cpp
tinfl.c
)
target_compile_definitions(game_server PRIVATE SERVER)
target_link_libraries(game_server PRIVATE
${WINSOCK_LIBRARIES}
${CMAKE_DL_LIBS}
)
if(APPLE)
target_link_libraries(game_server PRIVATE "-framework AudioToolbox" "-framework Foundation")
endif()