-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
CMakeLists.txt
282 lines (218 loc) · 11 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
#====================================
# @file : CMakeLists.txt
# @brief : cmake configuration file for vsUTCS
#====================================
# Copyright (C) 2020-2022 Evert Vorster, Stephen G. Tuggy, Roy Falk,
# and other vsUTCS contributors.
#
# This file is part of Vega Strike: Upon the Coldest Sea ("vsUTCS").
#
# vsUTCS is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# vsUTCS is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with vsUTCS. If not, see <https://www.gnu.org/licenses/>.
CMAKE_MINIMUM_REQUIRED(VERSION 3.16 FATAL_ERROR)
SET(vsUTCS_VERSION_MAJOR "0")
SET(vsUTCS_VERSION_MINOR "10")
SET(vsUTCS_VERSION_PATCH "0")
# Auto-populate with the git hash of the build
IF (DEFINED ENV{SHORT_SHA} AND NOT "$ENV{SHORT_SHA}" STREQUAL "")
SET (vsUTCS_VERSION_TWEAK "$ENV{SHORT_SHA}")
ELSE ()
SET (GIT_ROOT_DIR "${CMAKE_SOURCE_DIR}")
MESSAGE(STATUS "CMAKE_SOURCE_DIR = ${CMAKE_SOURCE_DIR}")
MESSAGE(STATUS "GIT_ROOT_DIR = ${GIT_ROOT_DIR}")
EXECUTE_PROCESS(
COMMAND git rev-parse --short HEAD
WORKING_DIRECTORY ${GIT_ROOT_DIR}
OUTPUT_VARIABLE vsUTCS_VERSION_TWEAK
OUTPUT_STRIP_TRAILING_WHITESPACE
)
ENDIF ()
SET(vsUTCS_VERSION_LONG_STR "${vsUTCS_VERSION_MAJOR}.${vsUTCS_VERSION_MINOR}.${vsUTCS_VERSION_PATCH}-${vsUTCS_VERSION_TWEAK}")
SET(vsUTCS_VERSION_SHORT_STR "${vsUTCS_VERSION_MAJOR}.${vsUTCS_VERSION_MINOR}.${vsUTCS_VERSION_PATCH}")
SET(vsUTCS_PKG_VERSION_STR "${vsUTCS_VERSION_MAJOR}.${vsUTCS_VERSION_MINOR}.${vsUTCS_VERSION_PATCH}")
IF (DEFINED ENV{TAG_NAME} AND NOT "$ENV{TAG_NAME}" STREQUAL "")
STRING(REGEX REPLACE "^v([0-9]+)\\..*" "\\1" TAG_VERSION_MAJOR "$ENV{TAG_NAME}")
STRING(REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" TAG_VERSION_MINOR "$ENV{TAG_NAME}")
STRING(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" TAG_VERSION_PATCH "$ENV{TAG_NAME}")
STRING(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+(.*)" "\\1" TAG_VERSION_TWEAK "$ENV{TAG_NAME}")
SET(TAG_VERSION_SHORT_STR "${TAG_VERSION_MAJOR}.${TAG_VERSION_MINOR}.${TAG_VERSION_PATCH}")
IF (NOT "${vsUTCS_VERSION_SHORT_STR}" VERSION_EQUAL "${TAG_VERSION_SHORT_STR}")
MESSAGE(FATAL_ERROR "Project version spelled out in CMake file does not match project version from TAG_NAME environment variable")
ENDIF ()
IF (NOT "${TAG_VERSION_TWEAK}" STREQUAL "")
SET(vsUTCS_VERSION_LONG_STR "${vsUTCS_VERSION_MAJOR}.${vsUTCS_VERSION_MINOR}.${vsUTCS_VERSION_PATCH}${TAG_VERSION_TWEAK}-${vsUTCS_VERSION_TWEAK}")
SET(vsUTCS_PKG_VERSION_STR "${vsUTCS_VERSION_MAJOR}.${vsUTCS_VERSION_MINOR}.${vsUTCS_VERSION_PATCH}${TAG_VERSION_TWEAK}")
ENDIF ()
ENDIF ()
PROJECT(vsUTCS
VERSION
"${vsUTCS_VERSION_MAJOR}.${vsUTCS_VERSION_MINOR}.${vsUTCS_VERSION_PATCH}" #.${vsUTCS_VERSION_TWEAK} # CMake only allows numeric version components, unfortunately.
)
MESSAGE("== Vega Strike: Upon the Coldest Sea Version: ${vsUTCS_VERSION_LONG_STR}")
# Let cmake find our in-tree modules
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${vsUTCS_SOURCE_DIR})
# Detect available Linux Distros that can be built for
FIND_PACKAGE(LinuxDistro REQUIRED)
SET(CPACK_IGNORE_FILES
build/
packages/
\\\\.git/
\\\\.vs/
\\\\.vscode/
".*\\\\.pyc"
)
SET(CPACK_SOURCE_IGNORE_FILES
build/
packages/
\\\\.git/
\\\\.vs/
\\\\.vscode/
".*\\\\.pyc"
)
INSTALL(DIRECTORY .vegastrike/ DESTINATION share/vegastrike/.vegastrike)
INSTALL(DIRECTORY ai/ DESTINATION share/vegastrike/ai
PATTERN "*.am" EXCLUDE)
INSTALL(DIRECTORY animations/ DESTINATION share/vegastrike/animations
PATTERN "*.am" EXCLUDE)
INSTALL(DIRECTORY bases/ DESTINATION share/vegastrike/bases)
INSTALL(DIRECTORY cgi-accountserver/ DESTINATION share/vegastrike/cgi-accountserver)
INSTALL(DIRECTORY cockpits/ DESTINATION share/vegastrike/cockpits
PATTERN "*.am" EXCLUDE)
INSTALL(DIRECTORY communications/ DESTINATION share/vegastrike/communications)
INSTALL(DIRECTORY documentation/ DESTINATION share/vegastrike/documentation)
INSTALL(DIRECTORY history/ DESTINATION share/vegastrike/history)
INSTALL(DIRECTORY meshes/ DESTINATION share/vegastrike/meshes
PATTERN "*.am" EXCLUDE)
INSTALL(DIRECTORY mission/ DESTINATION share/vegastrike/mission)
INSTALL(DIRECTORY modules/ DESTINATION share/vegastrike/modules)
INSTALL(DIRECTORY music/ DESTINATION share/vegastrike/music)
INSTALL(DIRECTORY programs/ DESTINATION share/vegastrike/programs)
INSTALL(DIRECTORY sectors/ DESTINATION share/vegastrike/sectors)
INSTALL(DIRECTORY sounds/ DESTINATION share/vegastrike/sounds
PATTERN "*.am" EXCLUDE)
INSTALL(DIRECTORY sprites/ DESTINATION share/vegastrike/sprites
PATTERN "*.am" EXCLUDE)
INSTALL(DIRECTORY techniques/ DESTINATION share/vegastrike/techniques)
INSTALL(DIRECTORY textures/ DESTINATION share/vegastrike/textures
PATTERN "*.am" EXCLUDE)
INSTALL(DIRECTORY units/ DESTINATION share/vegastrike/units
PATTERN "*.am" EXCLUDE)
INSTALL(DIRECTORY universe/ DESTINATION share/vegastrike/universe)
INSTALL(DIRECTORY python/ DESTINATION share/vegastrike/python)
INSTALL(FILES New_Game DESTINATION share/vegastrike)
INSTALL(FILES Version.txt DESTINATION share/vegastrike)
INSTALL(FILES factions.xml DESTINATION share/vegastrike)
#INSTALL(FILES units.json DESTINATION share/vegastrike)
#INSTALL(FILES ships.json DESTINATION share/vegastrike)
INSTALL(FILES master_part_list.csv DESTINATION share/vegastrike)
INSTALL(FILES master_part_list.json DESTINATION share/vegastrike)
INSTALL(FILES master_asteroid_list.json DESTINATION share/vegastrike)
INSTALL(FILES master_component_list.json DESTINATION share/vegastrike)
INSTALL(FILES master_ship_list.json DESTINATION share/vegastrike)
INSTALL(FILES controls.json DESTINATION share/vegastrike)
INSTALL(FILES py27_modules.7z DESTINATION share/vegastrike)
INSTALL(FILES py3_modules.7z DESTINATION share/vegastrike)
INSTALL(FILES setup.config DESTINATION share/vegastrike)
INSTALL(FILES vega-license.txt DESTINATION share/vegastrike)
INSTALL(FILES weapon_list.xml DESTINATION share/vegastrike)
INSTALL(FILES weapons.json DESTINATION share/vegastrike)
# Linux specific locations from here on out.
INSTALL(FILES vegastrike.config DESTINATION share/vegastrike)
INSTALL(FILES config.json DESTINATION share/vegastrike)
INSTALL(FILES vegastrike.desktop DESTINATION share/applications)
INSTALL(FILES vegasettings.desktop DESTINATION share/applications)
INSTALL(FILES vegastrike.png DESTINATION share/pixmaps)
INSTALL(FILES vegastrike_settings.png DESTINATION share/pixmaps)
INSTALL(FILES vegastrike.xpm DESTINATION share/pixmaps)
INSTALL(FILES vs DESTINATION bin PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE)
INSTALL(FILES vsettings DESTINATION bin PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE)
# CPack stuff
SET(CPACK_PACKAGE_NAME "vsUTCS")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "3D space combat and trading game")
SET(CPACK_PACKAGE_VENDOR "Vega Strike")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/documentation/readme.txt")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/vega-license.txt")
SET(CPACK_PACKAGE_VERSION_MAJOR "${vsUTCS_VERSION_MAJOR}")
SET(CPACK_PACKAGE_VERSION_MINOR "${vsUTCS_VERSION_MINOR}")
SET(CPACK_PACKAGE_VERSION_PATCH "${vsUTCS_VERSION_PATCH}")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "vsUTCS-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
SET(CPACK_CONTACT "[email protected]")
# Source package filename
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}_${vsUTCS_PKG_VERSION_STR}-Source")
SET(CPACK_SOURCE_GENERATOR "TXZ")
IF (WIN32 AND NOT UNIX)
MESSAGE(STATUS "Configuring Packaging for Windows (not fully implemented)")
# NSIS - See https://cmake.org/cmake/help/v3.3/module/CPackNSIS.html
# NSI bug requires at least 1 set of 4 forwards slashes??
SET(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\favicon.ico")
SET(CPACK_NSIS_DISPLAY_NAME "Vega Strike Upon the Coldest Sea")
SET(CPACK_NSIS_HELP_LINK "https:\\\\vega-strike.org")
SET(CPACK_NSIS_URL_INFO_ABOUT "https:\\\\vega-strike.org/about")
SET(CPACK_NSIS_CONTACT "[email protected]")
SET(CPACK_NSIS_MODIFY_PATH ON)
# NSIS, Wix, and compressed archives (7z, Zip)
SET(CPACK_GENERATOR "NSIS" "NSIS64" "WIX" "7Z" "ZIP")
# SET(CPACK_PACKAGE_EXECUTABLES "vegastrike.exe" "mesh_tool.exe" "vegasettings.exe")
ELSEIF (CMAKE_SYSTEM_NAME STREQUAL Darwin)
MESSAGE(STATUS "Configuring Packaging for macOS (not fully implemented)")
# There's a few options for MacOSX; not sure what we want to use
# DragNDrop -> DMG
# See https://cmake.org/cmake/help/v3.3/module/CPackDMG.html
# Bundle -> Compressed Disk Image
# PackageMaker - see https://cmake.org/cmake/help/v3.3/module/CPackPackageMaker.html
SET(CPACK_GENERATOR "DragNDrop" "BUNDLE" "TXZ")
ELSEIF (CMAKE_SYSTEM_NAME STREQUAL Linux)
MESSAGE(STATUS "Configuring Packaging for Linux")
SET(CPACK_GENERATOR "TXZ")
# "DEB"
IF (VS_CAN_BUILD_DEB)
MESSAGE(STATUS "Configuring Debian Packaging")
# See https://cmake.org/cmake/help/v3.3/module/CPackDeb.html
SET(CPACK_DEBIAN_PACKAGE_NAME "vsUTCS")
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "[email protected]")
SET(CPACK_DEBIAN_COMPRESSION_TYPE "bzip2")
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "vega-strike")
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_DEBIAN_PACKAGE_NAME}_${vsUTCS_PKG_VERSION_STR}")
SET(CPACK_DEBIAN_PACKAGE_SECTION "Amusements/Games")
SET(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://www.vega-strike.org")
SET(CPACK_GENERATOR "DEB")
ENDIF ()
# "RPM"
IF (VS_CAN_BUILD_RPM)
MESSAGE(STATUS "Configuring RPM Packaging")
# See https://cmake.org/cmake/help/v3.3/module/CPackRPM.html
SET(CPACK_RPM_PACKAGE_LICENSE "GPLv3") # See ../LICENSE
SET(CPACK_RPM_PACKAGE_URL "https://www.vega-strike.org")
SET(CPACK_RPM_PACKAGE_NAME "vsUTCS")
SET(CPACK_RPM_PACKAGE_REQUIRES "Vega-Strike")
# Figure out the filename
IF (LINUX_CODENAME)
SET(vsUTCS_LINUX_VERSION_STR "${LINUX_CODENAME}")
ELSE (LINUX_CODENAME)
SET(vsUTCS_LINUX_VERSION_STR "${LINUX_VERSION_ID}")
ENDIF (LINUX_CODENAME)
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_RPM_PACKAGE_NAME}_${vsUTCS_PKG_VERSION_STR}-${LINUX_ID}-${vsUTCS_LINUX_VERSION_STR}")
SET(CPACK_GENERATOR "RPM")
ENDIF ()
ELSE ()
MESSAGE(STATUS "Configuring Packaging for Unknown Platform - \"${CMAKE_SYSTEM_NAME}\"")
# Unknown Platform --> Just do compressed tarball
SET(CPACK_GENERATOR "TXZ")
ENDIF ()
INCLUDE(CPack)