forked from orbitersim/orbiter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
278 lines (226 loc) · 9.06 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
# Copyright (c) Martin Schweiger
# Licensed under the MIT License
cmake_minimum_required(VERSION 3.15)
include(ExternalProject)
# Set the project name
project (Orbiter VERSION 2021.1)
# Set the pools for compilers that can't run concurrently
set_property(GLOBAL PROPERTY JOB_POOLS latex=1 soffice=1 htmlhelp=1)
# Group projects in VS
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Define directories and file paths for some common binaries
set(OVP_DIR "${CMAKE_SOURCE_DIR}/OVP")
set(GDICLIENT_DIR "${OVP_DIR}/GDIClient")
set(ORBITER_SOURCE_ROOT_DIR ${CMAKE_SOURCE_DIR})
set(ORBITER_SOURCE_DIR ${ORBITER_SOURCE_ROOT_DIR}/Src/Orbiter)
set(ORBITER_SOURCE_MODULE_DIR ${ORBITER_SOURCE_ROOT_DIR}/Src/Plugin)
set(ORBITER_SOURCE_SDK_DIR ${ORBITER_SOURCE_ROOT_DIR}/Orbitersdk)
set(ORBITER_SOURCE_SDK_INCLUDE_DIR ${ORBITER_SOURCE_SDK_DIR}/include)
set(ORBITER_SOURCE_HTML_DIR ${ORBITER_SOURCE_ROOT_DIR}/Html)
set(ORBITER_SOURCE_SDK_DIR ${ORBITER_SOURCE_ROOT_DIR}/Orbitersdk)
set(ORBITER_BINARY_ROOT_DIR ${CMAKE_BINARY_DIR})
set(ORBITER_BINARY_CONFIG_DIR ${ORBITER_BINARY_ROOT_DIR}/Config)
set(ORBITER_BINARY_MESH_DIR ${ORBITER_BINARY_ROOT_DIR}/Meshes)
set(ORBITER_BINARY_MODULE_DIR ${ORBITER_BINARY_ROOT_DIR}/Modules)
set(ORBITER_BINARY_STARTUP_DIR ${ORBITER_BINARY_MODULE_DIR}/Startup)
set(ORBITER_BINARY_CELBODY_DIR ${ORBITER_BINARY_MODULE_DIR}/Celbody)
set(ORBITER_BINARY_PLUGIN_DIR ${ORBITER_BINARY_MODULE_DIR}/Plugin)
set(ORBITER_BINARY_VESSEL_DIR ${ORBITER_BINARY_MODULE_DIR})
set(ORBITER_BINARY_TEXTURES_DIR ${ORBITER_BINARY_ROOT_DIR}/Textures)
set(ORBITER_BINARY_HTML_DIR ${ORBITER_BINARY_ROOT_DIR}/Html)
set(ORBITER_BINARY_DOC_DIR ${ORBITER_BINARY_ROOT_DIR}/Doc)
set(ORBITER_BINARY_SDK_DIR ${ORBITER_BINARY_ROOT_DIR}/Orbitersdk)
set(ORBITER_INSTALL_ROOT_DIR ${CMAKE_INSTALL_PREFIX})
set(ORBITER_INSTALL_MODULE_DIR ${ORBITER_INSTALL_ROOT_DIR}/Modules)
set(ORBITER_INSTALL_CELBODY_DIR ${ORBITER_INSTALL_MODULE_DIR}/Celbody)
set(ORBITER_INSTALL_PLUGIN_DIR ${ORBITER_INSTALL_MODULE_DIR}/Plugin)
set(ORBITER_INSTALL_TEXTURES_DIR ${ORBITER_INSTALL_ROOT_DIR}/Textures)
set(ORBITER_INSTALL_HTML_DIR ${ORBITER_INSTALL_ROOT_DIR}/Html)
set(ORBITER_INSTALL_DOC_DIR ${ORBITER_INSTALL_ROOT_DIR}/Doc)
set(ORBITER_INSTALL_UTILS_DIR ${ORBITER_INSTALL_ROOT_DIR}/Utils)
set(ORBITER_INSTALL_SDK_DIR ${ORBITER_INSTALL_ROOT_DIR}/Orbitersdk)
set(ORBITER_LIB $<TARGET_LINKER_FILE:Orbiter>)
set(ORBITER_SDK_LIB $<TARGET_FILE:Orbitersdk>)
set(ORBITER_DLGCTRL_LIB $<TARGET_FILE:DlgCtrl>)
set(LUAINTERPRETER_LIB $<TARGET_LINKER_FILE:LuaInterpreter>)
set(GDICLIENT_LIB $<TARGET_LINKER_FILE:GDIClient>)
set(EXTERN_DIR "${CMAKE_SOURCE_DIR}/Extern")
set(DX7SDK_PATH "${EXTERN_DIR}/mssdk_dx7")
set(DX7SDK_INCLUDE_DIR "${DX7SDK_PATH}/include")
set(DX7SDK_LIB_DIR "${DX7SDK_PATH}/lib")
set(ZLIB_PATH "${EXTERN_DIR}/Zlib")
set(ZLIB_INCLUDE_DIR "${ZLIB_PATH}/include")
set(ZLIB_LIB_DIR "${ZLIB_PATH}/lib")
set(ZLIB_BIN_DIR "${ZLIB_PATH}/bin")
set(ZLIB_LIBRARIES "${ZLIB_LIB_DIR}/zlibstatic.lib")
set(LUA_DIR "${EXTERN_DIR}/Lua")
set(LUA_INCLUDE_DIR "${LUA_DIR}/include")
set(LUA_LIB_DIR "${LUA_DIR}/lib")
set(LUA_DLL_DIR "${LUA_DIR}/dll")
set(LUA_LIB "${LUA_DLL_DIR}/lua5.1.lib")
#set(ORBITER_TOOL_MESHC ${ORBITER_BINARY_ROOT_DIR}/Utils/meshc/meshc.exe)
set(ORBITER_TOOL_MESHC "$<TARGET_FILE:meshc>")
find_package(HTMLHelp)
find_package(Doxygen)
set(ldoc ${CMAKE_SOURCE_DIR}/Extern/Lua/bin/lua ${CMAKE_SOURCE_DIR}/Extern/Lua/packages/LDoc/ldoc.lua)
if(MSVC)
set(CMAKE_EXE_LINKER_FLAGS
"${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:\"LIBCMTD\"")
endif()
add_custom_target(CopyData ALL
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/BinAssets/ ${CMAKE_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/Scenarios/ ${CMAKE_BINARY_DIR}/Scenarios
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/Textures/ ${ORBITER_BINARY_TEXTURES_DIR}
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/Meshes/ ${CMAKE_BINARY_DIR}/Meshes
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/Script/ ${CMAKE_BINARY_DIR}/Script
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/Config/ ${CMAKE_BINARY_DIR}/Config
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/Flights/ ${CMAKE_BINARY_DIR}/Flights
)
set_target_properties(CopyData
PROPERTIES
FOLDER Data
)
# =====================================================================================
# Configure Orbiter.cfg for externally installed planet textures
set(ORBITER_PLANET_TEXTURE_INSTALL_DIR
${ORBITER_BINARY_ROOT_DIR}/Textures
CACHE
PATH
"Planet texture installation directory (e.g. C:/Orbiter2016/Textures)"
)
string(COMPARE NOTEQUAL ${ORBITER_PLANET_TEXTURE_INSTALL_DIR} "${ORBITER_BINARY_ROOT_DIR}/Textures" CUSTOM_PLANET_TEXTURE_DIR)
if (${CUSTOM_PLANET_TEXTURE_DIR})
string(REPLACE "/" "\\" ORBITER_PLANET_TEXTURE_INSTALL_DIR_W "${ORBITER_PLANET_TEXTURE_INSTALL_DIR}")
if(ORBITER_BUILD_WITH_DX7)
configure_file(${ORBITER_SOURCE_DIR}/Orbiter.cfg.in ${ORBITER_BINARY_ROOT_DIR}/Orbiter.cfg)
install(FILES ${ORBITER_BINARY_ROOT_DIR}/Orbiter.cfg
DESTINATION ${ORBITER_INSTALL_ROOT_DIR}
)
else()
configure_file(${ORBITER_SOURCE_DIR}/Orbiter.cfg.in ${ORBITER_BINARY_ROOT_DIR}/Orbiter_NG.cfg)
install(FILES ${ORBITER_BINARY_ROOT_DIR}/Orbiter_NG.cfg
DESTINATION ${ORBITER_INSTALL_ROOT_DIR}
)
endif()
endif()
# =====================================================================================
# Find required and optional build tools
option(ORBITER_BUILD_WITH_DX7
"Compile Orbiter with built-in DX7 graphics. If off, the server version for external graphics clients will be built."
ON
)
option(ORBITER_MAKE_DOC
"Create documentation"
ON
)
option(ORBITER_MAKE_SDK_SAMPLES
"Build the SDK sample projects"
OFF
)
if (ORBITER_MAKE_DOC)
find_program(ODT_TO_PDF_COMPILER
soffice
HINTS "/Program Files/LibreOffice/program"
)
set(ODT_TO_PDF_FLAGS
"--headless --convert-to pdf --outdir <outdir> <infile>"
CACHE
STRING
"Compiler options for the OdtToPdfCompiler"
)
find_program(DOC_TO_PDF_COMPILER
soffice
HINTS "/Program Files/LibreOffice/program"
)
set(DOC_TO_PDF_FLAGS
"--headless --convert-to pdf --outdir <outdir> <infile>"
CACHE
STRING
"Compiler options for the DocToPdfCompiler"
)
option(ORBITER_MAKE_TECHNOTES
"Create Orbiter Technical Notes"
ON
)
if(ORBITER_MAKE_TECHNOTES)
find_package(LATEX)
endif()
endif()
# Convert a CMake path to a Windows path by turning all / into \
function(windows_path inpath outpath)
string(REPLACE "/" "\\" outp "${inpath}")
set(${outpath} ${outp} PARENT_SCOPE)
endfunction()
# For a given argument string template (odt_to_pdf_arglist) and source file name (infile)
# return the explicit argument string (arglist), full source path (source_path) and full target path (target_path)
# to invoke the ODT to PDF conversion tool
function(odt_to_pdf_arglist infile arglist source_path target_path)
string(REPLACE
"<outdir>" "${CMAKE_CURRENT_BINARY_DIR}"
tmp1_string
${ODT_TO_PDF_FLAGS}
)
string(REPLACE
"<infile>" "${CMAKE_CURRENT_SOURCE_DIR}/${infile}.odt"
tmp2_string
${tmp1_string}
)
separate_arguments(odt_arg
WINDOWS_COMMAND
${tmp2_string}
)
set(${arglist} ${odt_arg} PARENT_SCOPE)
set(${source_path} "${CMAKE_CURRENT_SOURCE_DIR}/${infile}.odt" PARENT_SCOPE)
set(${target_path} "${CMAKE_CURRENT_BINARY_DIR}/${infile}.pdf" PARENT_SCOPE)
endfunction()
# For a given argument string template (odt_to_pdf_arglist) and source file name (infile)
# return the explicit argument string (arglist), full source path (source_path) and full target path (target_path)
# to invoke the DOC to PDF conversion tool
function(doc_to_pdf_arglist infile arglist source_path target_path)
string(REPLACE
"<outdir>" "${CMAKE_CURRENT_BINARY_DIR}"
tmp1_string
${DOC_TO_PDF_FLAGS}
)
string(REPLACE
"<infile>" "${CMAKE_CURRENT_SOURCE_DIR}/${infile}.doc"
tmp2_string
${tmp1_string}
)
separate_arguments(doc_arg
WINDOWS_COMMAND
${tmp2_string}
)
set(${arglist} ${doc_arg} PARENT_SCOPE)
set(${source_path} "${CMAKE_CURRENT_SOURCE_DIR}/${infile}.doc" PARENT_SCOPE)
set(${target_path} "${CMAKE_CURRENT_BINARY_DIR}/${infile}.pdf" PARENT_SCOPE)
endfunction()
# Given a source directory (srcdir) and a target root directory (tgtroot),
# generate a list of all files found in srcdir (srclist) and a list of output files
# when the source directory is copied to the target root (tgtlist)
# For a copy_directory command, srclist can be used as dependencies, and tgtlist as output
function(srcdir_to_tgtlist srcdir tgtroot srclist tgtlist)
file(GLOB_RECURSE infiles
RELATIVE ${srcdir}
${srcdir}/*
)
set(local_srclist ${infiles})
list(TRANSFORM local_srclist PREPEND "${srcdir}/")
set(local_tgtlist ${infiles})
list(TRANSFORM local_tgtlist PREPEND "${tgtroot}/")
set(srclist ${local_srclist} PARENT_SCOPE)
set(tgtlist ${local_tgtlist} PARENT_SCOPE)
endfunction()
# Installation
install(DIRECTORY Scenarios Textures Meshes Config Script Flights BinAssets/
DESTINATION ${ORBITER_INSTALL_ROOT_DIR}
)
# Sub-projects
add_subdirectory(Src)
add_subdirectory(Utils)
add_subdirectory(Orbitersdk)
add_subdirectory(OVP)
if(ORBITER_MAKE_DOC)
add_subdirectory(Doc)
add_subdirectory(Html)
endif()