forked from orbitersim/orbiter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
156 lines (124 loc) · 4.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
cmake_minimum_required(VERSION 3.15)
# 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)
# 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/Module)
set(ORBITER_SOURCE_SDK_DIR ${ORBITER_SOURCE_ROOT_DIR}/Orbitersdk)
set(ORBITER_SOURCE_SDK_INCLUDE_DIR ${ORBITER_SOURCE_SDK_DIR}/include)
set(ORBITER_BINARY_ROOT_DIR ${CMAKE_BINARY_DIR})
set(ORBITER_BINARY_MODULE_DIR ${ORBITER_BINARY_ROOT_DIR}/Modules)
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_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(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)
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
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/Html/ ${CMAKE_BINARY_DIR}/Html
)
set_target_properties(CopyData
PROPERTIES
FOLDER Data
)
# =====================================================================================
# Create symbolic links 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}")
configure_file(${ORBITER_SOURCE_DIR}/Orbiter.cfg.in ${ORBITER_BINARY_ROOT_DIR}/Orbiter.cfg)
endif()
# =====================================================================================
# Find required and optional build tools
option(ORBITER_MAKE_DOC
"Create documentation"
ON
)
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"
)
option(ORBITER_MAKE_TECHNOTES
"Create Orbiter Technical Notes"
ON
)
if(ORBITER_MAKE_TECHNOTES)
find_package(LATEX)
endif()
endif()
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()
# Sub-projects
add_subdirectory(Src)
add_subdirectory(Core)
add_subdirectory(Utils)
if(ORBITER_MAKE_DOC)
add_subdirectory(Doc)
endif()