-
Notifications
You must be signed in to change notification settings - Fork 7
/
CMakeLists.txt
286 lines (232 loc) · 7.9 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
cmake_minimum_required(VERSION 3.2)
project(Skyscraper)
set(CMAKE_AUTORCC ON)
set (CMAKE_CXX_FLAGS "-DBT_USE_DOUBLE_PRECISION ${CMAKE_CXX_FLAGS}")
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/tools/cmake;${CMAKE_MODULE_PATH}")
if(NOT APPLE)
if(UNIX)
set(FRONTENDGLINC "-lGL")
endif()
#if (MSVC)
#add_link_options("/SUBSYSTEM:WINDOWS")
#endif()
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
if (CMAKE_BUILD_TYPE STREQUAL "")
# CMake defaults to leaving CMAKE_BUILD_TYPE empty. This screws up
# differentiation between debug and release builds.
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build, options are: None (CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif ()
if (UNIX AND NOT APPLE)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
endif ()
if (WIN32)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}$<0:>)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}$<0:>)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}$<0:>)
set(CMAKE_CXX_FLAGS "-D_OGREBULLET_DYNAMIC /MP ${CMAKE_CXX_FLAGS}")
endif ()
find_package(OGRE REQUIRED)
if(NOT OGRE_FOUND)
message(SEND_ERROR "Failed to find OGRE.")
endif()
set (OGRE_LIBRARIES ${OGRE_LIBRARIES} ${OGRE_Overlay_LIBRARIES} ${OGRE_RTShaderSystem_LIBRARIES} ${OGRE_Bites_LIBRARIES})
#find OgreProcedural
find_package(OgreProcedural REQUIRED)
#find wxWidgets
find_package(wxWidgets COMPONENTS core base REQUIRED)
#find FMOD
find_package(FMOD REQUIRED)
#find GTK
if(NOT APPLE)
if(UNIX)
find_package(GTK3 3.0 REQUIRED gtk)
endif ()
endif()
#find BULLET
find_package(Bullet REQUIRED)
#find Caelum
find_package(Caelum REQUIRED)
#find OpenXR
find_package(OpenXR)
if(WIN32)
file(GLOB FRONTEND_FILES
src/frontend/*.cpp
msvc/Skyscraper.rc
)
else()
file(GLOB FRONTEND_FILES
src/frontend/*.cpp
)
endif()
if(WIN32)
file(GLOB VM_FILES
src/vm/*.cpp
src/gui/*.cpp
)
else()
file(GLOB VM_FILES
src/vm/*.cpp
)
endif()
file(GLOB GUI_FILES
src/gui/*.cpp
)
file(GLOB SCRIPTPROC_FILES
src/script/*.cpp
)
file(GLOB SBS_FILES
src/sbs/*.cpp
msvc/SBS.rc
)
file(GLOB ALLOC_FILES
src/alloc/*.cpp
)
file(GLOB OPENXR_FILES
src/openxr/src/*.cpp
)
file(GLOB OGREBULLET_COLL_FILES
ogrebullet/Collisions/src/*.cpp
ogrebullet/Collisions/src/Debug/*.cpp
ogrebullet/Collisions/src/Shapes/*.cpp
ogrebullet/Collisions/src/Utils/*.cpp
)
file (GLOB OGREBULLET_DYN_FILES
ogrebullet/Dynamics/src/*.cpp
ogrebullet/Dynamics/src/Constraints/*.cpp
ogrebullet/Dynamics/src/Prefab/*.cpp
)
include_directories( ${OGRE_INCLUDE_DIRS}
${OGRE_Overlay_INCLUDE_DIRS}
${OGRE_RTShaderSystem_INCLUDE_DIRS}
${OGRE_Bites_INCLUDE_DIRS}
${FMOD_INCLUDE_DIR}
${GTK3_INCLUDE_DIRS}
${BULLET_INCLUDE_DIRS}
${Caelum_INCLUDE_DIRS}
${OpenXR_INCLUDE_DIR}
${OgreProcedural_INCLUDE_DIR}
src/frontend
src/vm
src/sbs
src/script
src/gui
src/alloc
src/openxr/include
src/openxr
ogrebullet/Collisions/include
ogrebullet/Collisions/include/Debug
ogrebullet/Collisions/include/Shapes
ogrebullet/Collisions/include/Utils
ogrebullet/Dynamics/include
ogrebullet/Dynamics/include/Constraints
ogrebullet/Dynamics/include/Prefab
)
include(${wxWidgets_USE_FILE})
#ogrebullet libraries
add_library(OgreBulletCol SHARED ${OGREBULLET_COLL_FILES})
add_library(OgreBulletDyn SHARED ${OGREBULLET_DYN_FILES})
#SBS library
add_library(SBS SHARED ${SBS_FILES})
#ScriptProc Library
if (NOT WIN32)
add_library(ScriptProc SHARED ${SCRIPTPROC_FILES})
endif ()
#GUI Library
if (NOT WIN32)
add_library(GUI SHARED ${GUI_FILES})
endif ()
#Alloc Library
add_library(Alloc SHARED ${ALLOC_FILES})
#OpenXR Library
if (WIN32)
add_library(OpenXR SHARED ${OPENXR_FILES})
endif ()
#frontend executable
if (WIN32)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /ENTRY:mainCRTStartup")
endif ()
add_executable(skyscraper WIN32 ${FRONTEND_FILES})
if (NOT WIN32)
add_library(VM SHARED ${VM_FILES})
else ()
add_library(VM SHARED ${VM_FILES} ${SCRIPTPROC_FILES})
target_compile_options(OgreBulletCol PRIVATE -D_OGREBULLET_EXPORTS "/MD")
target_compile_options(OgreBulletDyn PRIVATE -D_OGREBULLET_EXPORTS "/MD")
target_compile_options(OpenXR PRIVATE -DOGREOPENXRDLL_EXPORTS "/MD")
target_compile_options(SBS PRIVATE -DSBS_DLL "/MD")
target_compile_options(VM PRIVATE -DVM_EXPORTS "/MD")
target_compile_options(skyscraper PRIVATE "/MD")
endif ()
target_precompile_headers(OgreBulletCol PRIVATE ogrebullet/Collisions/include/OgreBulletCollisionsPreRequisites.h)
target_precompile_headers(OgreBulletDyn PRIVATE ogrebullet/Dynamics/include/OgreBulletDynamicsPreRequisites.h)
target_precompile_headers(SBS PRIVATE src/sbs/globals.h)
target_precompile_headers(VM PRIVATE src/sbs/globals.h)
if (NOT WIN32)
target_precompile_headers(ScriptProc PRIVATE src/sbs/globals.h)
target_precompile_headers(GUI PRIVATE src/sbs/globals.h)
endif ()
target_precompile_headers(skyscraper PRIVATE src/sbs/globals.h)
target_link_libraries(OgreBulletCol ${OGRE_LIBRARIES} ${BULLET_LIBRARIES})
target_link_libraries(OgreBulletDyn OgreBulletCol ${OGRE_LIBRARIES} ${BULLET_LIBRARIES})
if (WIN32)
set (OGRE_D3D11_LIB ${OGRE_DIR}/../../lib/RelWithDebInfo/RenderSystem_Direct3D11.lib)
target_link_libraries(OpenXR ${OGRE_LIBRARIES} ${OPENXR_loader_LIBRARY} ${OGRE_D3D11_LIB})
endif ()
target_link_libraries(SBS OgreBulletCol OgreBulletDyn ${OGRE_LIBRARIES} ${FMOD_LIBRARY} ${OgreProcedural_LIBRARIES})
if (NOT WIN32)
target_link_libraries(ScriptProc SBS ${OGRE_LIBRARIES} ${wxWidgets_LIBRARIES})
target_link_libraries(VM GUI SBS ${OGRE_LIBRARIES} ${Caelum_LIBRARIES} ${FMOD_LIBRARY} ${wxWidgets_LIBRARIES})
target_link_libraries(GUI SBS ${OGRE_LIBRARIES} ${wxWidgets_LIBRARIES})
target_link_libraries(skyscraper VM GUI ScriptProc SBS ${OGRE_LIBRARIES} ${wxWidgets_LIBRARIES} ${FMOD_LIBRARY} ${GTK3_LIBRARIES} ${FRONTENDGLINC})
else ()
target_link_libraries(VM SBS OpenXR ${OGRE_LIBRARIES} ${Caelum_LIBRARIES} ${FMOD_LIBRARY} ${wxWidgets_LIBRARIES} ${OPENXR_loader_LIBRARY})
target_link_libraries(skyscraper VM SBS ${OGRE_LIBRARIES} ${wxWidgets_LIBRARIES} ${GTK3_LIBRARIES} ${FRONTENDGLINC})
endif ()
if (APPLE)
set_target_properties(skyscraper PROPERTIES
MACOSX_BUNDLE ON
OUTPUT_NAME "Skyscraper"
BUILD_WITH_INSTALL_RPATH 1
INSTALL_RPATH "@executable_path/../Frameworks")
ADD_CUSTOM_COMMAND(TARGET skyscraper
POST_BUILD
COMMAND ${CMAKE_HOME_DIRECTORY}/tools/mac/copyframework.sh)
#install(CODE "execute_process(COMMAND bash \".macos_app.sh\" \"${OGRE_LIBRARY_DIRS}/macosx/release\")")
endif()
if (APPLE)
set(CMAKE_SHARED_LINKER_FLAGS "-undefined dynamic_lookup")
endif ()
if (NOT WIN32)
ADD_CUSTOM_COMMAND(TARGET OgreBulletDyn
POST_BUILD
COMMAND ${CMAKE_HOME_DIRECTORY}/gitrev.sh)
else ()
ADD_CUSTOM_COMMAND(TARGET OgreBulletDyn
POST_BUILD
COMMAND ${CMAKE_HOME_DIRECTORY}/gitrev.cmd)
endif ()
if (APPLE)
ADD_CUSTOM_COMMAND(TARGET VM
POST_BUILD
COMMAND install_name_tool -change libOgreProcedural.dylib "@rpath/libOgreProcedural.dylib" libVM.dylib)
ADD_CUSTOM_COMMAND(TARGET GUI
POST_BUILD
COMMAND install_name_tool -change libOgreProcedural.dylib "@rpath/libOgreProcedural.dylib" libGUI.dylib)
ADD_CUSTOM_COMMAND(TARGET SBS
POST_BUILD
COMMAND install_name_tool -change libOgreProcedural.dylib "@rpath/libOgreProcedural.dylib" libSBS.dylib)
ADD_CUSTOM_COMMAND(TARGET ScriptProc
POST_BUILD
COMMAND install_name_tool -change libOgreProcedural.dylib "@rpath/libOgreProcedural.dylib" libScriptProc.dylib)
ADD_CUSTOM_COMMAND(TARGET skyscraper
POST_BUILD
COMMAND install_name_tool -change libOgreProcedural.dylib "@rpath/libOgreProcedural.dylib" Skyscraper.app/Contents/MacOS/Skyscraper)
endif ()
if (UNIX AND NOT APPLE)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/tools/scripts/skyscraper
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
endif()