2023-10-29 16:54:29 +01:00
|
|
|
#CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12 FATAL_ERROR)
|
2025-01-06 23:25:55 +01:00
|
|
|
CMAKE_MINIMUM_REQUIRED(VERSION 3.12 FATAL_ERROR)
|
2010-02-28 10:04:35 +01:00
|
|
|
|
2025-01-04 11:51:37 +01:00
|
|
|
# Speed Dreams project
|
2025-01-06 23:25:55 +01:00
|
|
|
PROJECT(speed-dreams-2 VERSION 2.3.0
|
|
|
|
HOMEPAGE_URL "https://www.speed-dreams.net/"
|
|
|
|
)
|
2025-01-04 11:51:37 +01:00
|
|
|
|
2020-04-01 21:01:27 +02:00
|
|
|
MESSAGE(STATUS CMAKE_VERSION = "${CMAKE_VERSION}")
|
|
|
|
|
2018-11-28 06:06:03 +01:00
|
|
|
IF(POLICY CMP0003)
|
|
|
|
CMAKE_POLICY(SET CMP0003 NEW)
|
|
|
|
ENDIF(POLICY CMP0003)
|
|
|
|
|
2021-04-30 17:44:43 +02:00
|
|
|
IF(POLICY CMP0048)
|
|
|
|
CMAKE_POLICY(SET CMP0048 NEW)
|
|
|
|
ENDIF(POLICY CMP0048)
|
|
|
|
|
2018-11-28 06:06:03 +01:00
|
|
|
IF(POLICY CMP0056)
|
|
|
|
CMAKE_POLICY(SET CMP0056 NEW)
|
|
|
|
ENDIF(POLICY CMP0056)
|
|
|
|
|
|
|
|
IF(POLICY CMP0066)
|
|
|
|
CMAKE_POLICY(SET CMP0066 NEW)
|
|
|
|
ENDIF(POLICY CMP0066)
|
|
|
|
|
2020-12-03 19:35:19 +01:00
|
|
|
IF(POLICY CMP0072)
|
|
|
|
CMAKE_POLICY(SET CMP0072 NEW)
|
|
|
|
ENDIF(POLICY CMP0072)
|
|
|
|
|
2023-04-17 15:40:26 +02:00
|
|
|
IF(APPLE)
|
|
|
|
SET(CMAKE_CXX_STANDARD 11)
|
|
|
|
SET(CMAKE_CXX_STANDARD_REQUIRED True)
|
|
|
|
ENDIF(APPLE)
|
|
|
|
|
2025-01-13 21:58:08 +01:00
|
|
|
option(SD_ASSUME_DATADIR "Assume default directory for speed-dreams-data")
|
2025-01-17 06:25:33 +01:00
|
|
|
set(data_version 2.3.0)
|
2025-01-13 21:58:08 +01:00
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
2025-01-17 06:39:44 +01:00
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_LIST_DIR}/cmake)
|
|
|
|
|
2025-01-13 21:58:08 +01:00
|
|
|
if(SD_ASSUME_DATADIR)
|
|
|
|
set(SD_DATADIR ${CMAKE_INSTALL_DATADIR}/games/speed-dreams-2)
|
|
|
|
set(SD_DATADIR_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/games/speed-dreams-2)
|
|
|
|
set(SD_DATADIR_ABS ${SD_DATADIR_INSTALL_PREFIX})
|
|
|
|
message(STATUS "Data directory: ${SD_DATADIR_ABS} (assumed)")
|
2025-01-19 06:20:05 +01:00
|
|
|
elseif(EXISTS ${CMAKE_CURRENT_LIST_DIR}/speed-dreams-data/CMakeLists.txt)
|
2025-01-13 21:58:08 +01:00
|
|
|
add_subdirectory(speed-dreams-data)
|
|
|
|
set(SD_DATADIR ${CMAKE_INSTALL_DATADIR}/games/speed-dreams-2)
|
|
|
|
set(SD_DATADIR_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/games/speed-dreams-2)
|
|
|
|
set(SD_DATADIR_ABS ${CMAKE_CURRENT_SOURCE_DIR}/speed-dreams-data/data)
|
|
|
|
message(STATUS "Data directory: ${SD_DATADIR_ABS} (in-tree)")
|
2024-12-28 14:13:38 +01:00
|
|
|
else()
|
2025-01-13 21:58:08 +01:00
|
|
|
find_package(speed-dreams-data ${data_version} QUIET)
|
|
|
|
|
|
|
|
if(NOT SD_DATADIR)
|
|
|
|
message(FATAL_ERROR
|
|
|
|
"Data directory not found or incompatible with version "
|
|
|
|
"${data_version}. Please perform one of the following actions:\n"
|
|
|
|
"- Update the data git submodule to do an in-tree build with the "
|
|
|
|
" command below, and then configure the project again:\n"
|
|
|
|
"git submodule update --init --recursive\n"
|
|
|
|
"- If speed-dreams-data has been installed to a non-standard "
|
|
|
|
"location, configure the project with "
|
|
|
|
"-DCMAKE_PREFIX_PATH=<data-dir>.\n"
|
|
|
|
"- Configure the project with -DSD_ASSUME_DATADIR=1 to assume "
|
|
|
|
"speed-dreams-data was installed into a standard location. "
|
|
|
|
"Speed Dreams should then still be able to build, but it might "
|
|
|
|
"not run successfully. This option is usually only recommended "
|
|
|
|
"for CI/CD and packagers."
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2024-12-31 08:20:24 +01:00
|
|
|
message(STATUS "Data directory: ${SD_DATADIR_ABS}")
|
2024-12-28 14:13:38 +01:00
|
|
|
endif()
|
|
|
|
|
2025-01-17 06:39:58 +01:00
|
|
|
if(CMAKE_CXX_COMPILER_ID)
|
|
|
|
set(SD_BUILD_INFO_COMPILER_NAME ${CMAKE_CXX_COMPILER_ID})
|
|
|
|
else()
|
|
|
|
set(SD_BUILD_INFO_COMPILER_NAME "Unknown")
|
|
|
|
endif()
|
|
|
|
|
2010-02-28 10:04:35 +01:00
|
|
|
INCLUDE(cmake/macros.cmake)
|
|
|
|
INCLUDE(cmake/checks.cmake)
|
|
|
|
|
2025-01-17 06:29:10 +01:00
|
|
|
set(CMAKE_INSTALL_RPATH
|
|
|
|
${CMAKE_INSTALL_RPATH}
|
|
|
|
${CMAKE_INSTALL_PREFIX}/${SD_LIBDIR}/lib
|
2025-01-17 06:41:04 +01:00
|
|
|
/usr/${SD_LIBDIR}/lib
|
2025-01-17 06:29:10 +01:00
|
|
|
)
|
|
|
|
|
2025-01-17 06:30:03 +01:00
|
|
|
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
|
|
|
|
2010-02-28 10:04:35 +01:00
|
|
|
CHECK_HEADERS_H()
|
|
|
|
CHECK_FUNCTIONS()
|
|
|
|
CHECK_LIBRARIES()
|
|
|
|
|
2024-12-31 06:50:42 +01:00
|
|
|
execute_process(
|
|
|
|
COMMAND git describe --tags --dirty
|
|
|
|
RESULT_VARIABLE result
|
|
|
|
OUTPUT_VARIABLE VERSION
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
)
|
|
|
|
|
|
|
|
if(NOT result EQUAL 0)
|
|
|
|
set(VERSION "undefined-version")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(VERSION_LONG ${VERSION})
|
2021-04-30 17:44:43 +02:00
|
|
|
|
Revamp Debian and NSIS packaging
The existing scripts for Debian and NSIS packaging were too complex and
dealt unnecessarily with lower level details that should be already
handled by CMake and CPack.
- Packaging-related scripts have been moved to the new cpack/ directory.
There, CPack variables common to all generators are defined in
cpack/common.cmake, and then generator-specific variables are defined
independently (e.g.: cpack/debian.cmake and cpack/nsis.cmake).
- Packaging is now optionally done at a second stage, by running
`cpack -G <generator>` on the build directory. This removes the
requirement to branch based on the system name, and instead all CPack
variables are assigned unconditionally.
- Since now only one version of the game is packaged, there is no need
to maintain the complex scripts in packaging/ and packaging/windows that
used to deal with all variants (e.g.: "wip-cars-and-tracks",
"hq-cars-and-tracks", etc.).
- The use of CPACK_NSIS_EXTRA_INSTALL_COMMANDS,
CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS and CPACK_NSIS_CREATE_ICONS_EXTRA
should not be required, let alone modifying the HKLM registry manually,
since CPack already provides everything required to set up the
installer, the uninstaller and shortcuts.
- $INSTDIR is not required, since NSIS would already prepend the
target installation directory.
- PROJECT_VERSION_METADATA is not a standard CMake variable.
CMAKE_PROJECT_VERSION_TWEAK is instead meant for this purpose. [1]
- OPTION_PACKAGING and OPTION_ALL_IN_ONE_PACKAGING were removed since
packaging will always be available, yet optional. Packagers must then
run CPack on a second stage, as described above.
- Outdated comments were removed to avoid confusion.
TODO:
- Add shortcut to track editor on NSIS.
- dmg packaging was not revamped because of lacking compatible
hardware, but still it has been moved to cpack/dmg.cmake.
- Windows portable packaging (OPTION_PORTABLE_PACKAGING) has been left
out since it required 7z and relied on several hacks to work.
Furthermore, portable versions of the game were already not released on
the latest release, either. [2]
[1]: https://cmake.org/cmake/help/latest/variable/CMAKE_PROJECT_VERSION_TWEAK.html
[2]: https://sourceforge.net/projects/speed-dreams/files/2.3.0/
2025-01-06 23:30:07 +01:00
|
|
|
# CMAKE_PROJECT_VERSION_TWEAK is used by NSIS packagers
|
2021-04-30 17:44:43 +02:00
|
|
|
# its what comes after the '-' sign (if anything)
|
Revamp Debian and NSIS packaging
The existing scripts for Debian and NSIS packaging were too complex and
dealt unnecessarily with lower level details that should be already
handled by CMake and CPack.
- Packaging-related scripts have been moved to the new cpack/ directory.
There, CPack variables common to all generators are defined in
cpack/common.cmake, and then generator-specific variables are defined
independently (e.g.: cpack/debian.cmake and cpack/nsis.cmake).
- Packaging is now optionally done at a second stage, by running
`cpack -G <generator>` on the build directory. This removes the
requirement to branch based on the system name, and instead all CPack
variables are assigned unconditionally.
- Since now only one version of the game is packaged, there is no need
to maintain the complex scripts in packaging/ and packaging/windows that
used to deal with all variants (e.g.: "wip-cars-and-tracks",
"hq-cars-and-tracks", etc.).
- The use of CPACK_NSIS_EXTRA_INSTALL_COMMANDS,
CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS and CPACK_NSIS_CREATE_ICONS_EXTRA
should not be required, let alone modifying the HKLM registry manually,
since CPack already provides everything required to set up the
installer, the uninstaller and shortcuts.
- $INSTDIR is not required, since NSIS would already prepend the
target installation directory.
- PROJECT_VERSION_METADATA is not a standard CMake variable.
CMAKE_PROJECT_VERSION_TWEAK is instead meant for this purpose. [1]
- OPTION_PACKAGING and OPTION_ALL_IN_ONE_PACKAGING were removed since
packaging will always be available, yet optional. Packagers must then
run CPack on a second stage, as described above.
- Outdated comments were removed to avoid confusion.
TODO:
- Add shortcut to track editor on NSIS.
- dmg packaging was not revamped because of lacking compatible
hardware, but still it has been moved to cpack/dmg.cmake.
- Windows portable packaging (OPTION_PORTABLE_PACKAGING) has been left
out since it required 7z and relied on several hacks to work.
Furthermore, portable versions of the game were already not released on
the latest release, either. [2]
[1]: https://cmake.org/cmake/help/latest/variable/CMAKE_PROJECT_VERSION_TWEAK.html
[2]: https://sourceforge.net/projects/speed-dreams/files/2.3.0/
2025-01-06 23:30:07 +01:00
|
|
|
# ie: in tag '2.2.2-rc1' CMAKE_PROJECT_VERSION_TWEAK should be '-rc1'
|
2021-04-30 17:44:43 +02:00
|
|
|
STRING(FIND "${VERSION}" "-" _METADATA_INDEX)
|
|
|
|
IF(NOT ${_METADATA_INDEX} EQUAL -1)
|
Revamp Debian and NSIS packaging
The existing scripts for Debian and NSIS packaging were too complex and
dealt unnecessarily with lower level details that should be already
handled by CMake and CPack.
- Packaging-related scripts have been moved to the new cpack/ directory.
There, CPack variables common to all generators are defined in
cpack/common.cmake, and then generator-specific variables are defined
independently (e.g.: cpack/debian.cmake and cpack/nsis.cmake).
- Packaging is now optionally done at a second stage, by running
`cpack -G <generator>` on the build directory. This removes the
requirement to branch based on the system name, and instead all CPack
variables are assigned unconditionally.
- Since now only one version of the game is packaged, there is no need
to maintain the complex scripts in packaging/ and packaging/windows that
used to deal with all variants (e.g.: "wip-cars-and-tracks",
"hq-cars-and-tracks", etc.).
- The use of CPACK_NSIS_EXTRA_INSTALL_COMMANDS,
CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS and CPACK_NSIS_CREATE_ICONS_EXTRA
should not be required, let alone modifying the HKLM registry manually,
since CPack already provides everything required to set up the
installer, the uninstaller and shortcuts.
- $INSTDIR is not required, since NSIS would already prepend the
target installation directory.
- PROJECT_VERSION_METADATA is not a standard CMake variable.
CMAKE_PROJECT_VERSION_TWEAK is instead meant for this purpose. [1]
- OPTION_PACKAGING and OPTION_ALL_IN_ONE_PACKAGING were removed since
packaging will always be available, yet optional. Packagers must then
run CPack on a second stage, as described above.
- Outdated comments were removed to avoid confusion.
TODO:
- Add shortcut to track editor on NSIS.
- dmg packaging was not revamped because of lacking compatible
hardware, but still it has been moved to cpack/dmg.cmake.
- Windows portable packaging (OPTION_PORTABLE_PACKAGING) has been left
out since it required 7z and relied on several hacks to work.
Furthermore, portable versions of the game were already not released on
the latest release, either. [2]
[1]: https://cmake.org/cmake/help/latest/variable/CMAKE_PROJECT_VERSION_TWEAK.html
[2]: https://sourceforge.net/projects/speed-dreams/files/2.3.0/
2025-01-06 23:30:07 +01:00
|
|
|
STRING(SUBSTRING ${VERSION} ${_METADATA_INDEX} -1 CMAKE_PROJECT_VERSION_TWEAK)
|
|
|
|
ELSE()
|
|
|
|
SET(CMAKE_PROJECT_VERSION_TWEAK)
|
|
|
|
ENDIF()
|
|
|
|
#MESSAGE(STATUS "CMAKE_PROJECT_VERSION_TWEAK ${CMAKE_PROJECT_VERSION_TWEAK}")
|
2021-04-30 17:44:43 +02:00
|
|
|
|
2012-01-10 19:18:32 +01:00
|
|
|
# Generate config.h
|
2012-09-14 20:39:40 +02:00
|
|
|
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.h.in.cmake
|
2010-02-28 10:04:35 +01:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
|
|
|
|
2012-01-10 19:18:32 +01:00
|
|
|
# Generate DOxygen configuration file
|
2012-09-14 20:39:40 +02:00
|
|
|
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/doxygenconfig.in.cmake
|
2013-03-23 18:59:22 +01:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/doxygen_config @ONLY)
|
2010-02-28 10:04:35 +01:00
|
|
|
|
2019-12-06 20:40:01 +01:00
|
|
|
# Setup empty GLOBAL lists for robots and modules
|
|
|
|
SET_PROPERTY(GLOBAL PROPERTY SD_MODULE_LIST "")
|
2021-06-16 18:18:54 +02:00
|
|
|
SET_PROPERTY(GLOBAL PROPERTY SD_CAR_LIST "")
|
|
|
|
SET_PROPERTY(GLOBAL PROPERTY SD_TRACK_LIST "")
|
2019-12-06 20:40:01 +01:00
|
|
|
SET_PROPERTY(GLOBAL PROPERTY SD_ROBOT_LIST "")
|
|
|
|
SET_PROPERTY(GLOBAL PROPERTY SD_OSG_PLUGIN_LIST "")
|
2020-03-30 07:21:39 +02:00
|
|
|
SET_PROPERTY(GLOBAL PROPERTY SD_EXE_LIST "")
|
2019-12-06 20:40:01 +01:00
|
|
|
|
|
|
|
# Sub-dirs to build ...
|
2010-02-28 10:04:35 +01:00
|
|
|
ADD_SUBDIRECTORY(src)
|
|
|
|
|
2020-07-13 14:09:48 +02:00
|
|
|
IF(MSVC)
|
|
|
|
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/doc/faq/faq.html DESTINATION ./doc)
|
|
|
|
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/doc/userman/how_to_drive.html DESTINATION ./doc)
|
|
|
|
INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/doc/userman/images/ DESTINATION ./doc/images/)
|
|
|
|
ENDIF(MSVC)
|
|
|
|
|
2020-03-30 07:21:39 +02:00
|
|
|
# Must be the last ADD_SUBDIRECTORY for FIXUP_BUNDLE to work
|
|
|
|
ADD_SUBDIRECTORY(packaging)
|
|
|
|
|
2021-06-16 18:18:54 +02:00
|
|
|
IF(OPTION_CHECK_CONTENTS)
|
|
|
|
INCLUDE(cmake/prerelease.cmake)
|
|
|
|
ENDIF(OPTION_CHECK_CONTENTS)
|
|
|
|
|
Revamp Debian and NSIS packaging
The existing scripts for Debian and NSIS packaging were too complex and
dealt unnecessarily with lower level details that should be already
handled by CMake and CPack.
- Packaging-related scripts have been moved to the new cpack/ directory.
There, CPack variables common to all generators are defined in
cpack/common.cmake, and then generator-specific variables are defined
independently (e.g.: cpack/debian.cmake and cpack/nsis.cmake).
- Packaging is now optionally done at a second stage, by running
`cpack -G <generator>` on the build directory. This removes the
requirement to branch based on the system name, and instead all CPack
variables are assigned unconditionally.
- Since now only one version of the game is packaged, there is no need
to maintain the complex scripts in packaging/ and packaging/windows that
used to deal with all variants (e.g.: "wip-cars-and-tracks",
"hq-cars-and-tracks", etc.).
- The use of CPACK_NSIS_EXTRA_INSTALL_COMMANDS,
CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS and CPACK_NSIS_CREATE_ICONS_EXTRA
should not be required, let alone modifying the HKLM registry manually,
since CPack already provides everything required to set up the
installer, the uninstaller and shortcuts.
- $INSTDIR is not required, since NSIS would already prepend the
target installation directory.
- PROJECT_VERSION_METADATA is not a standard CMake variable.
CMAKE_PROJECT_VERSION_TWEAK is instead meant for this purpose. [1]
- OPTION_PACKAGING and OPTION_ALL_IN_ONE_PACKAGING were removed since
packaging will always be available, yet optional. Packagers must then
run CPack on a second stage, as described above.
- Outdated comments were removed to avoid confusion.
TODO:
- Add shortcut to track editor on NSIS.
- dmg packaging was not revamped because of lacking compatible
hardware, but still it has been moved to cpack/dmg.cmake.
- Windows portable packaging (OPTION_PORTABLE_PACKAGING) has been left
out since it required 7z and relied on several hacks to work.
Furthermore, portable versions of the game were already not released on
the latest release, either. [2]
[1]: https://cmake.org/cmake/help/latest/variable/CMAKE_PROJECT_VERSION_TWEAK.html
[2]: https://sourceforge.net/projects/speed-dreams/files/2.3.0/
2025-01-06 23:30:07 +01:00
|
|
|
INCLUDE(cpack/common.cmake)
|
|
|
|
INCLUDE(CPack)
|