-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCMakeLists.txt
288 lines (250 loc) · 9.1 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
278
279
280
281
282
283
284
285
286
287
288
cmake_minimum_required(VERSION 3.2)
project(OrbitEngine C CXX)
# Options
option(OE_EDITOR_INTERNAL OFF)
include(CMake/Config.cmake)
include(CMake/Tools.cmake)
# Workaround with clang
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND NOT("${CMAKE_SYSTEM_NAME}" STREQUAL "Android"))
set(CMAKE_CXX_FLAGS "-stdlib=libc++")
endif()
# This fixes some Emscripten cross-compilation problem with zlibstatic of Assimp
include(CheckTypeSize)
check_type_size(off64_t OFF64_T)
set(INC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Code/include)
set(SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Code/src)
set(BIN_DIR ${CMAKE_CURRENT_BINARY_DIR})
set(BIN_INC_DIR ${BIN_DIR}/include)
# Configure macros file
configure_file(${INC_DIR}/OE/Config.hpp.in
${BIN_INC_DIR}/OE/Config.hpp)
# - Dependencies -
add_subdirectory(Dependencies/FreeType)
add_subdirectory(Dependencies/FreeImage)
add_subdirectory(Dependencies/glsl-optimizer)
# msdfgen
file(GLOB_RECURSE msdfgen_HEADERS "Dependencies/msdfgen/core/*.h" "Dependencies/msdfgen/core/*.hpp")
file(GLOB_RECURSE msdfgen_SOURCES "Dependencies/msdfgen/core/*.cpp")
add_library(lib_msdfgen ${msdfgen_SOURCES} ${msdfgen_HEADERS})
target_include_directories(lib_msdfgen PUBLIC ${freetype_SOURCE_DIR}/include "Dependencies/msdfgen")
target_link_libraries(lib_msdfgen freetype)
# imgui
add_library(imgui
"Dependencies/imgui/imconfig.h"
"Dependencies/imgui/imgui.h"
"Dependencies/imgui/imgui_internal.h"
"Dependencies/imgui/misc/cpp/imgui_stdlib.h"
"Dependencies/imgui/imgui.cpp"
"Dependencies/imgui/imgui_demo.cpp"
"Dependencies/imgui/imgui_draw.cpp"
"Dependencies/imgui/imgui_widgets.cpp"
"Dependencies/imgui/misc/cpp/imgui_stdlib.cpp"
)
target_include_directories(imgui PUBLIC "Dependencies/imgui")
option(XSC_BUILD_SHELL "" OFF) # Don't build XSC shell
add_subdirectory(Dependencies/XShaderCompiler)
option(ASSIMP_BUILD_ASSIMP_TOOLS "" OFF) # Don't build Assimp tools
option(BUILD_SHARED_LIBS "" OFF) # Build Assimp as a static lib
option(ASSIMP_BUILD_TESTS "" OFF) # Don't build Assimp tests
option(ASSIMP_NO_EXPORT "" ON) # Disable Assimp export feature
option(ASSIMP_BUILD_ALL_IMPORTERS_BY_DEFAULT "" OFF) # Disable all import formats by default
option(ASSIMP_BUILD_OBJ_IMPORTER "" ON)
option(ASSIMP_BUILD_FBX_IMPORTER "" ON)
add_subdirectory(Dependencies/Assimp)
# yoga
file(GLOB_RECURSE yogacore_SRC Dependencies/yoga/yoga/*.cpp)
add_library(yogacore STATIC ${yogacore_SRC})
target_include_directories(yogacore PUBLIC Dependencies/yoga)
set_target_properties(yogacore PROPERTIES CXX_STANDARD 11)
# Reset some flags that some libraries modify
set(CMAKE_DEBUG_POSTFIX "" CACHE STRING "" FORCE)
# - Code -
# General code
file(GLOB_RECURSE SRC ${INC_DIR}/OE/Misc/*.hpp
${INC_DIR}/OE/Misc/*.inl
${SRC_DIR}/OE/Misc/*.cpp
${SRC_DIR}/OE/Misc/*.hpp
${INC_DIR}/OE/Math/*.hpp
${INC_DIR}/OE/Math/*.inl
${SRC_DIR}/OE/Math/*.cpp
${INC_DIR}/OE/Graphics/*.hpp
${SRC_DIR}/OE/Graphics/*.hpp
${SRC_DIR}/OE/Graphics/*.cpp
${INC_DIR}/OE/Memory/*.hpp
${INC_DIR}/OE/Memory/*.inl
${SRC_DIR}/OE/Memory/*.cpp
#${INC_DIR}/OE/Meta/*.hpp
#${SRC_DIR}/OE/Meta/*.cpp
${INC_DIR}/OE/Application/*.hpp
${SRC_DIR}/OE/Application/*.cpp
#${INC_DIR}/OE/Engine/*.hpp
#${INC_DIR}/OE/Engine/*.inl
#${SRC_DIR}/OE/Engine/*.cpp
#${INC_DIR}/OE/Scripting/*.hpp
#${SRC_DIR}/OE/Scripting/*.cpp
${INC_DIR}/OE/System/*.hpp
${SRC_DIR}/OE/System/*.hpp
${SRC_DIR}/OE/System/*.cpp
${INC_DIR}/OE/UI/*.hpp
${SRC_DIR}/OE/UI/*.cpp
)
list(REMOVE_ITEM SRC
${INC_DIR}/OE/Misc/FrameDebugger.hpp
${SRC_DIR}/OE/Misc/FrameDebugger.cpp
)
set(SRC
${SRC}
${BIN_INC_DIR}/OE/Config.hpp
)
# Platform code
if(OE_WINDOWS)
file(GLOB PLATFORM_SRC ${SRC_DIR}/OE/Platform/Windows/*.*
${INC_DIR}/OE/Platform/Windows/*.*)
elseif(OE_EMSCRIPTEN)
file(GLOB PLATFORM_SRC ${SRC_DIR}/OE/Platform/Emscripten/*.*
${INC_DIR}/OE/Platform/Emscripten/*.*)
elseif(OE_ANDROID)
# App Glue
set(ANDROID_NATIVE_APP_GLUE ${ANDROID_NDK}/sources/android/native_app_glue)
file(GLOB PLATFORM_SRC ${SRC_DIR}/OE/Platform/Android/*.*
${INC_DIR}/OE/Platform/Android/*.*
${ANDROID_NATIVE_APP_GLUE}/android_native_app_glue.c
)
elseif(OE_UNIX)
file(GLOB PLATFORM_SRC ${SRC_DIR}/OE/Platform/X11/*.*
${INC_DIR}/OE/Platform/X11/*.*)
endif()
# Contexts code (GL, D3D, VK)
if(OE_D3D)
# Assume Windows...
file(GLOB D3D_SRC ${SRC_DIR}/OE/Platform/Direct3D/*.*
${INC_DIR}/OE/Platform/Direct3D/*.*)
set(PLATFORM_SRC ${PLATFORM_SRC} ${D3D_SRC})
endif()
if(OE_OPENGL OR OE_OPENGL_ES)
file(GLOB OPENGL_SRC ${SRC_DIR}/OE/Platform/OpenGL/*.*
${INC_DIR}/OE/Platform/OpenGL/*.*
${INC_DIR}/OE/Platform/OpenGL/Shaders/*.glsl)
# We don't want specific implementations
file(GLOB SPECIFIC_OPENGL_SRC ${SRC_DIR}/OE/Platform/OpenGL/*Context.*)
# Except this, which is not an specific implementation
list(REMOVE_ITEM SPECIFIC_OPENGL_SRC ${SRC_DIR}/OE/Platform/OpenGL/GLContext.cpp)
list(REMOVE_ITEM OPENGL_SRC ${SPECIFIC_OPENGL_SRC})
set(PLATFORM_SRC ${PLATFORM_SRC} ${OPENGL_SRC})
endif()
if(OE_OPENGL)
if(OE_WINDOWS)
set(PLATFORM_SRC ${PLATFORM_SRC}
${SRC_DIR}/OE/Platform/OpenGL/WGLContext.hpp
${SRC_DIR}/OE/Platform/OpenGL/WGLContext.cpp)
elseif(OE_LINUX)
set(PLATFORM_SRC ${PLATFORM_SRC}
${SRC_DIR}/OE/Platform/OpenGL/GLXContext.hpp
${SRC_DIR}/OE/Platform/OpenGL/GLXContext.cpp)
endif()
endif()
if(OE_OPENGL_ES)
# If Emscripten, we use the WebGLContext located in Platform/Emscripten/
if(NOT OE_EMSCRIPTEN)
set(PLATFORM_SRC ${PLATFORM_SRC}
${SRC_DIR}/OE/Platform/OpenGL/EGLContext.hpp
${SRC_DIR}/OE/Platform/OpenGL/EGLContext.cpp)
endif()
endif()
if(OE_VULKAN)
file(GLOB VULKAN_SRC ${SRC_DIR}/OE/Platform/Vulkan/*.*
${INC_DIR}/OE/Platform/Vulkan/*.*)
set(PLATFORM_SRC ${PLATFORM_SRC} ${VULKAN_SRC})
endif()
# Add the main library
add_library(OrbitEngine ${SRC} ${PLATFORM_SRC})
#add_definitions("-E")
# Include
include_directories(${SRC_DIR})
target_include_directories(OrbitEngine PUBLIC
${INC_DIR}
${BIN_INC_DIR}
)
if(OE_ANDROID)
# Include privatly? the Android native app glue
target_include_directories(OrbitEngine PUBLIC ${ANDROID_NATIVE_APP_GLUE})
endif()
# - Libraries -
list(APPEND OE_LIBRARIES
freetype
FreeImage
xsc_core
glsl_optimizer
assimp
lib_msdfgen
imgui
yogacore
#${MONO_LIBRARIES}
)
list(APPEND OE_LIBRARIES_INC
${freetype_SOURCE_DIR}/include
${FreeImage_SOURCE_DIR}/Source
${XShaderCompiler_SOURCE_DIR}/inc
${Assimp_SOURCE_DIR}/include
${Assimp_BINARY_DIR}/include
Dependencies/glsl-optimizer/src/glsl
Dependencies/rapidjson/include
Dependencies/imgui
${msdfgen_SOURCE_DIR}
#${MONO_INCLUDE_DIR}
)
target_compile_definitions(freetype PUBLIC FT_CONFIG_OPTION_ERROR_STRINGS)
target_compile_definitions(FreeImage PUBLIC FREEIMAGE_LIB FREEIMAGE_COLORORDER=1)
target_compile_definitions(OrbitEngine PUBLIC FREEIMAGE_LIB FREEIMAGE_COLORORDER=1)
# Platform specific
if(OE_WINDOWS)
elseif(OE_EMSCRIPTEN)
target_link_libraries(OrbitEngine PUBLIC "-Oz --no-heap-copy -s USE_WEBGL2=1 -s FULL_ES3=1 -s ALLOW_MEMORY_GROWTH=1 -s MODULARIZE=1 -s EXIT_RUNTIME=1 --closure 1 -s WASM_OBJECT_FILES=0 --llvm-lto 1 -s ENVIRONMENT=web -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1")
elseif(OE_ANDROID)
list(APPEND OE_LIBRARIES android log)
elseif(OE_LINUX)
find_package(X11 REQUIRED)
find_package(DL REQUIRED)
list(APPEND OE_LIBRARIES ${X11_LIBRARIES} ${DL_LIBRARIES})
list(APPEND OE_LIBRARIES_INC ${X11_INCLUDE_DIR} ${DL_INCLUDES})
endif()
# Contexts
if(OE_OPENGL)
list(APPEND OE_LIBRARIES ${OPENGL_LIBRARIES})
list(APPEND OE_LIBRARIES_INC ${OPENGL_INCLUDE_DIR})
endif()
if(OE_OPENGL_ES)
# Emscripten provides it's own libraries
if(NOT OE_EMSCRIPTEN)
list(APPEND OE_LIBRARIES ${GLES_LIBRARIES} ${EGL_LIBRARIES})
list(APPEND OE_LIBRARIES_INC ${GLES_INCLUDE_DIR} ${EGL_INCLUDE_DIRS})
endif()
endif()
if(OE_D3D)
list(APPEND OE_LIBRARIES ${DirectX_LIBRARIES})
list(APPEND OE_LIBRARIES_INC ${DirectX_INCLUDE_DIR})
endif()
if(OE_VULKAN)
list(APPEND OE_LIBRARIES ${Vulkan_LIBRARIES})
list(APPEND OE_LIBRARIES_INC ${Vulkan_INCLUDE_DIRS})
endif()
target_link_libraries(OrbitEngine PUBLIC ${OE_LIBRARIES})
target_include_directories(OrbitEngine PUBLIC ${OE_LIBRARIES_INC})
# Resources
OE_add_resources(Resources OrbitEngine)
if(EMSCRIPTEN)
target_link_libraries(OrbitEngine PUBLIC "--preload-file vfs@/")
# TODO Make this an option
target_link_libraries(OrbitEngine PUBLIC "--shell-file \"${CMAKE_CURRENT_SOURCE_DIR}\"/CMake/Emscripten/template.html")
endif()
# - Binaries -
if(OE_WINDOWS)
#list(APPEND OE_BINARIES
# "${MONO_PATH}/bin/${MONO_N}.dll"
#)
set(OE_BINARIES "${OE_BINARIES}" CACHE STRING "")
endif()
# C++11
useCXX11(OrbitEngine)
# Editor
add_subdirectory(Editor)