-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathCMakeLists.txt
277 lines (240 loc) · 6.73 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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
cmake_minimum_required(VERSION 3.15)
project(SimpleGraphic C CXX)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 17)
if (APPLE)
enable_language(OBJCXX)
endif ()
if (MSVC)
add_compile_options("/Zi")
add_link_options("/DEBUG:FULL")
endif ()
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
include(${PROJECT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake)
set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION ".")
include(InstallRequiredSystemLibraries)
add_subdirectory(dep/glm)
set(SIMPLEGRAPHIC_SOURCES
"config.h"
"dep/stb/stb_image.h"
"dep/stb/stb_image_resize.h"
"dep/stb/stb_image_write.h"
"engine/common.h"
"engine/common/base64.c"
"engine/common/base64.h"
"engine/common/common.cpp"
"engine/common/console.cpp"
"engine/common/console.h"
"engine/common/keylist.h"
"engine/common/memtrak3.cpp"
"engine/common/memtrak3.h"
"engine/common/streams.cpp"
"engine/common/streams.h"
"engine/core/core_config.cpp"
"engine/core/core_config.h"
"engine/core/core_image.cpp"
"engine/core/core_image.h"
"engine/core/core_main.cpp"
"engine/core/core_main.h"
"engine/core/core_video.cpp"
"engine/core/core_video.h"
"engine/render/r_font.cpp"
"engine/render/r_font.h"
"engine/render/r_main.cpp"
"engine/render/r_main.h"
"engine/render/r_texture.cpp"
"engine/render/r_texture.h"
# "engine/system/win/sys_console.cpp"
"engine/system/win/sys_console_unix.cpp"
"engine/system/win/sys_local.h"
"engine/system/win/sys_main.cpp"
"engine/system/win/sys_opengl.cpp"
"engine/system/win/sys_video.cpp"
"engine/system/sys_console.h"
"engine/system/sys_main.h"
"engine/system/sys_opengl.h"
"engine/system/sys_video.h"
"win/entry.cpp"
"ui.h"
"ui_api.cpp"
"ui_console.cpp"
"ui_console.h"
"ui_debug.cpp"
"ui_debug.h"
"ui_local.h"
"ui_main.cpp"
"ui_main.h"
"ui_subscript.cpp"
"ui_subscript.h"
)
set (SIMPLEGRAPHIC_PLATFORM_SOURCES)
if (APPLE)
set (SIMPLEGRAPHIC_PLATFORM_SOURCES
"engine/system/win/sys_macos.mm"
)
endif()
add_library(SimpleGraphic SHARED
${SIMPLEGRAPHIC_SOURCES}
${SIMPLEGRAPHIC_PLATFORM_SOURCES}
)
target_compile_definitions(SimpleGraphic
PRIVATE
"UNICODE"
"_CRT_SECURE_NO_DEPRECATE"
"_CRT_SECURE_NO_WARNINGS"
"_SCL_SECURE_NO_DEPRECATE"
"_SCL_SECURE_NO_WARNINGS"
"GLFW_INCLUDE_NONE"
"GL_SILENCE_DEPRECATION"
"SIMPLEGRAPHIC_EXPORTS"
)
target_include_directories(SimpleGraphic
PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/engine"
)
find_package(unofficial-angle CONFIG REQUIRED)
find_package(CURL CONFIG REQUIRED)
find_package(fmt CONFIG REQUIRED)
find_package(glfw3 CONFIG REQUIRED)
find_package(LuaJIT REQUIRED)
find_package(re2 CONFIG REQUIRED)
find_package(Threads REQUIRED)
find_package(ZLIB REQUIRED)
add_library(imgui STATIC
dep/imgui/imconfig.h
dep/imgui/imgui.cpp
dep/imgui/imgui.h
dep/imgui/imgui_demo.cpp
dep/imgui/imgui_draw.cpp
dep/imgui/imgui_internal.h
dep/imgui/imgui_tables.cpp
dep/imgui/imgui_widgets.cpp
dep/imgui/imstb_rectpack.h
dep/imgui/imstb_textedit.h
dep/imgui/imstb_truetype.h
dep/imgui/backends/imgui_impl_glfw.cpp
dep/imgui/backends/imgui_impl_glfw.h
dep/imgui/backends/imgui_impl_opengl3.cpp
dep/imgui/backends/imgui_impl_opengl3.h
dep/imgui/backends/imgui_impl_opengl3_loader.h
dep/imgui/misc/cpp/imgui_stdlib.cpp
dep/imgui/misc/cpp/imgui_stdlib.h
)
target_compile_definitions(imgui PUBLIC
"IMGUI_IMPL_OPENGL_ES2"
)
target_include_directories(imgui PUBLIC
dep/imgui
dep/imgui/backends
dep/imgui/misc/cpp
)
target_link_libraries(imgui PUBLIC
unofficial::angle::libGLESv2
glfw
)
target_include_directories(SimpleGraphic
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/dep/glad/include
${CMAKE_CURRENT_SOURCE_DIR}/dep/stb
)
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
target_link_options(SimpleGraphic
PRIVATE
"-export-dynamic"
)
endif ()
if (WIN32)
target_compile_options(SimpleGraphic
PRIVATE
"/EHa"
)
target_compile_definitions(SimpleGraphic
PRIVATE
"_CRT_SECURE_NO_DEPRECATE=1"
"_CRT_SECURE_NO_WARNINGS=1"
"_SCL_SECURE_NO_DEPRECATE=1"
"_SCL_SECURE_NO_WARNINGS=1"
)
target_link_libraries(SimpleGraphic
PRIVATE
"winmm.lib"
)
endif ()
if (APPLE)
find_library(CORE_FOUNDATION_LIBRARY CoreFoundation)
find_library(APPLICATION_SERVICES_LIBRARY ApplicationServices)
target_link_libraries(SimpleGraphic
PRIVATE
${CORE_FOUNDATION_LIBRARY}
${APPLICATION_SERVICES_LIBRARY}
)
endif ()
target_link_libraries(SimpleGraphic
PRIVATE
unofficial::angle::libEGL
unofficial::angle::libGLESv2
fmt::fmt
glfw
glm::glm
imgui
LuaJIT::LuaJIT
re2::re2
Threads::Threads
ZLIB::ZLIB
)
install(FILES $<TARGET_RUNTIME_DLLS:SimpleGraphic> DESTINATION ".")
install(TARGETS SimpleGraphic RUNTIME DESTINATION ".")
if (WIN32)
set(DEPS_DIR "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}")
if (NOT VCPKG_TARGET_TRIPLET MATCHES "-release")
find_file(LuaJIT_DLL_DEBUG NAMES "lua51.dll"
PATHS "${DEPS_DIR}" PATH_SUFFIXES "debug/bin" REQUIRED NO_DEFAULT_PATH)
find_file(ZLIB_DLL_DEBUG NAMES "zlibd1.dll"
PATHS "${DEPS_DIR}" PATH_SUFFIXES "debug/bin" REQUIRED NO_DEFAULT_PATH)
install(FILES
${LuaJIT_DLL_DEBUG}
${ZLIB_DLL_DEBUG}
DESTINATION "."
CONFIGURATIONS Debug
)
endif ()
find_file(LuaJIT_DLL_RELEASE NAMES "lua51.dll"
PATHS "${DEPS_DIR}" PATH_SUFFIXES "bin" REQUIRED NO_DEFAULT_PATH)
find_file(ZLIB_DLL_RELEASE NAMES "zlib1.dll"
PATHS "${DEPS_DIR}" PATH_SUFFIXES "bin" REQUIRED NO_DEFAULT_PATH
)
install(FILES
${LuaJIT_DLL_RELEASE}
${ZLIB_DLL_RELEASE}
DESTINATION "."
CONFIGURATIONS Release MinSizeRel RelWithDebInfo
)
endif ()
# lcurl module
set(LCURL_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libs/Lua-cURLv3)
file(GLOB LCURL_SOURCES ${LCURL_SOURCE_DIR}/src/**.c)
add_library(lcurl SHARED ${LCURL_SOURCES})
target_include_directories(lcurl
PRIVATE
${LCURL_SOURCE_DIR}/src
)
target_link_libraries(lcurl
PRIVATE
CURL::libcurl
LuaJIT::LuaJIT
)
install(TARGETS lcurl RUNTIME DESTINATION ".")
install(FILES $<TARGET_RUNTIME_DLLS:lcurl> DESTINATION ".")
# lzip module
add_library(lzip SHARED libs/LZip/lzip.cpp)
target_include_directories(lzip
PRIVATE
)
target_link_libraries(lzip
PRIVATE
LuaJIT::LuaJIT
ZLIB::ZLIB
)
install(TARGETS lzip RUNTIME DESTINATION ".")
install(FILES $<TARGET_RUNTIME_DLLS:lzip> DESTINATION ".")