2020-06-18 16:34:19 +00:00
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
2019-04-07 10:00:36 +00:00
|
|
|
# If requested, use FHS layout; otherwise fall back to a flat layout.
|
2020-09-25 11:55:25 +00:00
|
|
|
if(OPTION_INSTALL_FHS)
|
2020-06-18 16:34:19 +00:00
|
|
|
set(BINARY_DESTINATION_DIR "${CMAKE_INSTALL_BINDIR}")
|
2020-06-11 19:57:14 +00:00
|
|
|
set(DATA_DESTINATION_DIR "${CMAKE_INSTALL_DATADIR}/${BINARY_NAME}")
|
2020-06-18 16:34:19 +00:00
|
|
|
set(DOCS_DESTINATION_DIR "${CMAKE_INSTALL_DOCDIR}")
|
|
|
|
set(MAN_DESTINATION_DIR "${CMAKE_INSTALL_MANDIR}")
|
2020-09-25 11:55:25 +00:00
|
|
|
else()
|
2020-12-12 15:29:09 +00:00
|
|
|
if(APPLE)
|
|
|
|
set(BINARY_DESTINATION_DIR "../MacOS")
|
|
|
|
else()
|
|
|
|
set(BINARY_DESTINATION_DIR ".")
|
|
|
|
endif()
|
2019-04-07 10:00:36 +00:00
|
|
|
set(DATA_DESTINATION_DIR ".")
|
|
|
|
set(DOCS_DESTINATION_DIR ".")
|
|
|
|
set(MAN_DESTINATION_DIR ".")
|
2020-09-25 11:55:25 +00:00
|
|
|
endif()
|
2019-04-07 10:00:36 +00:00
|
|
|
|
|
|
|
install(TARGETS openttd
|
|
|
|
RUNTIME
|
|
|
|
DESTINATION ${BINARY_DESTINATION_DIR}
|
|
|
|
COMPONENT Runtime
|
|
|
|
)
|
|
|
|
|
|
|
|
install(DIRECTORY
|
|
|
|
${CMAKE_BINARY_DIR}/lang
|
|
|
|
${CMAKE_BINARY_DIR}/baseset
|
|
|
|
${CMAKE_SOURCE_DIR}/bin/ai
|
|
|
|
${CMAKE_SOURCE_DIR}/bin/game
|
|
|
|
${CMAKE_SOURCE_DIR}/bin/scripts
|
|
|
|
DESTINATION ${DATA_DESTINATION_DIR}
|
|
|
|
COMPONENT language_files)
|
|
|
|
|
|
|
|
install(FILES
|
|
|
|
${CMAKE_SOURCE_DIR}/COPYING.md
|
|
|
|
${CMAKE_SOURCE_DIR}/README.md
|
|
|
|
${CMAKE_SOURCE_DIR}/changelog.txt
|
|
|
|
${CMAKE_SOURCE_DIR}/docs/multiplayer.md
|
|
|
|
${CMAKE_SOURCE_DIR}/known-bugs.txt
|
|
|
|
DESTINATION ${DOCS_DESTINATION_DIR}
|
|
|
|
COMPONENT docs)
|
|
|
|
|
|
|
|
# A Linux manual only makes sense when using FHS. Otherwise it is a very odd
|
|
|
|
# file with little context to what it is.
|
2020-09-25 11:55:25 +00:00
|
|
|
if(OPTION_INSTALL_FHS)
|
2020-06-11 19:57:14 +00:00
|
|
|
set(MAN_SOURCE_FILE ${CMAKE_SOURCE_DIR}/docs/openttd.6)
|
2020-06-11 19:57:14 +00:00
|
|
|
set(MAN_BINARY_FILE ${CMAKE_BINARY_DIR}/docs/${BINARY_NAME}.6)
|
2020-06-11 19:57:14 +00:00
|
|
|
install(CODE
|
|
|
|
"
|
|
|
|
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${MAN_SOURCE_FILE} ${MAN_BINARY_FILE})
|
2020-10-14 19:24:48 +00:00
|
|
|
execute_process(COMMAND gzip -9 -n -f ${MAN_BINARY_FILE})
|
2020-06-11 19:57:14 +00:00
|
|
|
"
|
|
|
|
COMPONENT manual)
|
2019-04-07 10:00:36 +00:00
|
|
|
install(FILES
|
2020-06-11 19:57:14 +00:00
|
|
|
${MAN_BINARY_FILE}.gz
|
2020-06-18 16:34:19 +00:00
|
|
|
DESTINATION ${MAN_DESTINATION_DIR}/man6
|
2019-04-07 10:00:36 +00:00
|
|
|
COMPONENT manual)
|
2020-09-25 11:55:25 +00:00
|
|
|
endif()
|
2019-04-07 10:00:36 +00:00
|
|
|
|
|
|
|
# TODO -- Media files
|
|
|
|
# TODO -- Menu files
|
|
|
|
|
2020-09-25 11:55:25 +00:00
|
|
|
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
|
2019-04-07 10:00:36 +00:00
|
|
|
set(ARCHITECTURE "amd64")
|
2020-09-25 11:55:25 +00:00
|
|
|
else()
|
2019-04-07 10:00:36 +00:00
|
|
|
string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" ARCHITECTURE)
|
2020-09-25 11:55:25 +00:00
|
|
|
endif()
|
2019-04-07 10:00:36 +00:00
|
|
|
|
|
|
|
# Windows is a bit more annoying to detect; using the size of void pointer
|
|
|
|
# seems to be the most robust.
|
2020-09-25 11:55:25 +00:00
|
|
|
if(WIN32)
|
|
|
|
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
2019-04-07 10:00:36 +00:00
|
|
|
set(ARCHITECTURE "win64")
|
2020-09-25 11:55:25 +00:00
|
|
|
else()
|
2019-04-07 10:00:36 +00:00
|
|
|
set(ARCHITECTURE "win32")
|
2020-09-25 11:55:25 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
2020-12-12 15:29:32 +00:00
|
|
|
if(APPLE AND CMAKE_OSX_ARCHITECTURES)
|
|
|
|
string(TOLOWER "${CMAKE_OSX_ARCHITECTURES}" ARCHITECTURE)
|
|
|
|
endif()
|
2019-04-07 10:00:36 +00:00
|
|
|
|
|
|
|
set(CPACK_SYSTEM_NAME "${ARCHITECTURE}")
|
|
|
|
|
|
|
|
set(CPACK_PACKAGE_NAME "openttd")
|
|
|
|
set(CPACK_PACKAGE_VENDOR "OpenTTD")
|
|
|
|
set(CPACK_PACKAGE_DESCRIPTION "OpenTTD")
|
|
|
|
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "OpenTTD")
|
|
|
|
set(CPACK_PACKAGE_HOMEPAGE_URL "https://www.openttd.org/")
|
|
|
|
set(CPACK_PACKAGE_CONTACT "OpenTTD <info@openttd.org>")
|
|
|
|
set(CPACK_PACKAGE_INSTALL_DIRECTORY "OpenTTD")
|
|
|
|
set(CPACK_PACKAGE_CHECKSUM "SHA256")
|
|
|
|
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING.md")
|
|
|
|
set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md")
|
|
|
|
set(CPACK_MONOLITHIC_INSTALL YES)
|
|
|
|
set(CPACK_PACKAGE_EXECUTABLES "openttd;OpenTTD")
|
|
|
|
set(CPACK_STRIP_FILES YES)
|
|
|
|
set(CPACK_OUTPUT_FILE_PREFIX "bundles")
|
|
|
|
|
2020-09-25 11:55:25 +00:00
|
|
|
if(APPLE)
|
2020-06-08 23:20:43 +00:00
|
|
|
set(CPACK_GENERATOR "Bundle")
|
2019-04-07 10:00:36 +00:00
|
|
|
include(PackageBundle)
|
|
|
|
|
2020-12-12 15:29:32 +00:00
|
|
|
set(CPACK_PACKAGE_FILE_NAME "openttd-#CPACK_PACKAGE_VERSION#-macosx-${CPACK_SYSTEM_NAME}")
|
2020-09-25 11:55:25 +00:00
|
|
|
elseif(WIN32)
|
2020-06-07 02:34:50 +00:00
|
|
|
set(CPACK_GENERATOR "ZIP")
|
2020-09-25 11:55:25 +00:00
|
|
|
if(OPTION_USE_NSIS)
|
2020-06-07 02:34:50 +00:00
|
|
|
list(APPEND CPACK_GENERATOR "NSIS")
|
|
|
|
include(PackageNSIS)
|
2020-09-25 11:55:25 +00:00
|
|
|
endif()
|
2019-04-07 10:00:36 +00:00
|
|
|
|
|
|
|
set(CPACK_PACKAGE_FILE_NAME "openttd-#CPACK_PACKAGE_VERSION#-windows-${CPACK_SYSTEM_NAME}")
|
2020-09-25 11:55:25 +00:00
|
|
|
elseif(UNIX)
|
2019-04-07 10:00:36 +00:00
|
|
|
# With FHS, we can create deb/rpm/... Without it, they would be horribly broken
|
|
|
|
# and not work. The other way around is also true; with FHS they are not
|
|
|
|
# usable, and only flat formats work.
|
2020-09-25 11:55:25 +00:00
|
|
|
if(OPTION_INSTALL_FHS)
|
2019-04-07 10:00:36 +00:00
|
|
|
set(CPACK_GENERATOR "DEB")
|
|
|
|
include(PackageDeb)
|
2020-09-25 11:55:25 +00:00
|
|
|
else()
|
2019-04-07 10:00:36 +00:00
|
|
|
set(CPACK_GENERATOR "TXZ")
|
2020-09-25 11:55:25 +00:00
|
|
|
endif()
|
2019-04-07 10:00:36 +00:00
|
|
|
|
2020-12-12 15:30:02 +00:00
|
|
|
find_program(LSB_RELEASE_EXEC lsb_release)
|
|
|
|
execute_process(COMMAND ${LSB_RELEASE_EXEC} -is
|
|
|
|
OUTPUT_VARIABLE LSB_RELEASE_ID
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
)
|
|
|
|
if(NOT LSB_RELEASE_ID)
|
|
|
|
set(PLATFORM "generic")
|
|
|
|
elseif(LSB_RELEASE_ID STREQUAL "Ubuntu" OR LSB_RELEASE_ID STREQUAL "Debian")
|
|
|
|
execute_process(COMMAND ${LSB_RELEASE_EXEC} -cs
|
|
|
|
OUTPUT_VARIABLE LSB_RELEASE_CODENAME
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
)
|
|
|
|
string(TOLOWER "${LSB_RELEASE_ID}-${LSB_RELEASE_CODENAME}" PLATFORM)
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Unknown Linux distribution found for packaging; please consider creating a Pull Request to add support for this distribution.")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(CPACK_PACKAGE_FILE_NAME "openttd-#CPACK_PACKAGE_VERSION#-linux-${PLATFORM}-${CPACK_SYSTEM_NAME}")
|
2020-09-25 11:55:25 +00:00
|
|
|
else()
|
2019-04-07 10:00:36 +00:00
|
|
|
message(FATAL_ERROR "Unknown OS found for packaging; please consider creating a Pull Request to add support for this OS.")
|
2020-09-25 11:55:25 +00:00
|
|
|
endif()
|
2019-04-07 10:00:36 +00:00
|
|
|
|
|
|
|
include(CPack)
|