2023-10-29 16:54:29 +01:00
|
|
|
#CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12 FATAL_ERROR)
|
|
|
|
CMAKE_MINIMUM_REQUIRED(VERSION 3.5 FATAL_ERROR)
|
2010-02-28 10:04:35 +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)
|
|
|
|
|
2024-12-28 14:13:38 +01:00
|
|
|
set(data_version 2.4.0)
|
|
|
|
find_package(speed-dreams-data ${data_version})
|
|
|
|
|
|
|
|
if(NOT SD_DATADIR)
|
|
|
|
message(WARNING "Data directory not found or incompatible with version "
|
|
|
|
"${data_version}. Speed Dreams should still "
|
|
|
|
"be able to build, but it might not run successfully. "
|
|
|
|
"If speed-dreams-data has been installed to a non-standard location, "
|
|
|
|
"please add -DCMAKE_PREFIX_PATH=<data-dir> to the command line to "
|
|
|
|
"find it.")
|
|
|
|
else()
|
2024-12-31 08:20:24 +01:00
|
|
|
message(STATUS "Data directory: ${SD_DATADIR_ABS}")
|
2024-12-30 08:42:08 +01:00
|
|
|
set(SD_HAS_DATADIR true)
|
2024-12-28 14:13:38 +01:00
|
|
|
endif()
|
|
|
|
|
2024-12-31 06:25:57 +01:00
|
|
|
# Speed Dreams project
|
|
|
|
PROJECT(speed-dreams-2 VERSION 2.4.0)
|
2010-07-10 23:24:18 +02:00
|
|
|
|
2010-02-28 10:04:35 +01:00
|
|
|
INCLUDE(cmake/macros.cmake)
|
|
|
|
INCLUDE(cmake/checks.cmake)
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
# PROJECT_VERSION_METADATA is used by NSIS packagers
|
|
|
|
# its what comes after the '-' sign (if anything)
|
|
|
|
# ie: in tag '2.2.2-rc1' PROJECT_VERSION_METADATA should be '-rc1'
|
|
|
|
STRING(FIND "${VERSION}" "-" _METADATA_INDEX)
|
|
|
|
IF(NOT ${_METADATA_INDEX} EQUAL -1)
|
|
|
|
STRING(SUBSTRING ${VERSION} ${_METADATA_INDEX} -1 PROJECT_VERSION_METADATA)
|
|
|
|
ELSE(NOT ${_METADATA_INDEX} EQUAL -1)
|
|
|
|
SET(PROJECT_VERSION_METADATA )
|
|
|
|
ENDIF(NOT ${_METADATA_INDEX} EQUAL -1)
|
|
|
|
#MESSAGE(STATUS "PROJECT_VERSION_METADATA ${PROJECT_VERSION_METADATA}")
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
2021-05-25 19:15:54 +02:00
|
|
|
# Useful for using an installation of SD as a robot development framework without building it.
|
2021-06-06 15:38:54 +02:00
|
|
|
# Only do for an in source tree build as INSTALL_SD_CMAKE() doesn't seem to use CMAKE_INSTALL_PREFIX
|
|
|
|
IF("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}")
|
2021-05-25 19:15:54 +02:00
|
|
|
INSTALL_SD_CMAKE()
|
2021-06-06 15:38:54 +02:00
|
|
|
ENDIF("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}")
|
2010-02-28 10:04:35 +01:00
|
|
|
|
2020-03-30 07:21:39 +02:00
|
|
|
# Must be the last ADD_SUBDIRECTORY for FIXUP_BUNDLE to work
|
|
|
|
ADD_SUBDIRECTORY(packaging)
|
|
|
|
|
2010-09-07 23:34:19 +02:00
|
|
|
# Generate a 'make clobber'-like clobber.sh/.bat script in case of an in-source build.
|
2012-08-08 19:38:39 +02:00
|
|
|
IF("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}")
|
|
|
|
SD_GENERATE_CLOBBER_SCRIPT()
|
|
|
|
ENDIF("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}")
|
2010-09-07 23:34:19 +02:00
|
|
|
|
|
|
|
# Add an unistall target.
|
2024-07-30 23:45:07 +02:00
|
|
|
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/cmake/uninstall.cmake"
|
2010-09-07 23:34:19 +02:00
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake" IMMEDIATE @ONLY)
|
2012-08-08 19:38:39 +02:00
|
|
|
IF(MSVC)
|
|
|
|
SET(_UNINST_TGT_NAME "UNINSTALL")
|
|
|
|
ELSE(MSVC)
|
|
|
|
SET(_UNINST_TGT_NAME "uninstall")
|
|
|
|
ENDIF(MSVC)
|
|
|
|
ADD_CUSTOM_TARGET(${_UNINST_TGT_NAME} "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake" )
|
2011-01-12 20:32:40 +01:00
|
|
|
|
2021-06-16 18:18:54 +02:00
|
|
|
IF(OPTION_CHECK_CONTENTS)
|
|
|
|
INCLUDE(cmake/prerelease.cmake)
|
|
|
|
ENDIF(OPTION_CHECK_CONTENTS)
|
|
|
|
|
2022-07-19 01:55:34 +02:00
|
|
|
IF(OPTION_PACKAGING OR OPTION_ALL_IN_ONE_PACKAGING)
|
2020-04-20 04:34:33 +02:00
|
|
|
INCLUDE(cmake/packagemaker.cmake)
|
2022-07-19 01:55:34 +02:00
|
|
|
ENDIF(OPTION_PACKAGING OR OPTION_ALL_IN_ONE_PACKAGING)
|
|
|
|
IF(OPTION_PACKAGING)
|
2019-06-04 02:55:22 +02:00
|
|
|
IF(MSVC)
|
|
|
|
INCLUDE(cmake/packagemaker-nsis.cmake)
|
|
|
|
ENDIF(MSVC)
|
2020-04-20 04:34:33 +02:00
|
|
|
IF(APPLE)
|
|
|
|
INCLUDE(cmake/packagemaker-dmg.cmake)
|
|
|
|
ENDIF(APPLE)
|
2020-12-03 19:35:19 +01:00
|
|
|
ENDIF(OPTION_PACKAGING)
|
2022-07-19 01:55:34 +02:00
|
|
|
|
|
|
|
IF(OPTION_ALL_IN_ONE_PACKAGING)
|
2022-07-20 05:23:27 +02:00
|
|
|
IF(MSVC AND ${CMAKE_VERSION} VERSION_LESS "3.17")
|
|
|
|
MESSAGE(SEND_ERROR "OPTION_ALL_IN_ONE_PACKAGING requires CMake 3.17 or greater on Windows")
|
|
|
|
ENDIF(MSVC AND ${CMAKE_VERSION} VERSION_LESS "3.17")
|
2022-07-19 01:55:34 +02:00
|
|
|
INCLUDE(CPack)
|
|
|
|
ENDIF(OPTION_ALL_IN_ONE_PACKAGING)
|
2023-11-05 23:25:58 +01:00
|
|
|
|
|
|
|
IF(OPTION_PORTABLE_PACKAGING)
|
|
|
|
IF(NOT ${CMAKE_VERSION} VERSION_LESS "3.0")
|
|
|
|
#[[
|
|
|
|
This section adds a batch file for running speed-dreams-2.exe with a local settings directory.
|
|
|
|
This is similar to how 'Portable Apps' work.
|
|
|
|
It also adds projects to build a self-extracting 7-zip file (if 7-zip is installed)
|
|
|
|
]]
|
|
|
|
ENDIF(NOT ${CMAKE_VERSION} VERSION_LESS "3.0")
|
|
|
|
IF(WIN32)
|
|
|
|
|
|
|
|
find_program(7ZIP_EXE 7z.exe PATH_SUFFIXES 7-Zip)
|
|
|
|
find_file(7ZIP_WIN 7z.sfx PATH_SUFFIXES 7-Zip)
|
|
|
|
|
|
|
|
set(SD_EXE_NAME "speed-dreams-2.exe")
|
2024-12-31 06:50:42 +01:00
|
|
|
SET(PORTABLE_PACKAGE_FILE_NAME "speed-dreams-2-${VERSION_LONG}-portable-setup" CACHE STRING "Name for portable package file")
|
|
|
|
SET(PORTABLE_BATCH_FILE_NAME "speed-dreams-2-${VERSION_LONG}-portable.bat" CACHE STRING "Name for portable batch file")
|
2023-11-05 23:25:58 +01:00
|
|
|
|
2024-07-30 23:45:07 +02:00
|
|
|
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/packaging/portable/sd-portable.bat.in"
|
2023-11-05 23:25:58 +01:00
|
|
|
"${CMAKE_BINARY_DIR}/${PORTABLE_BATCH_FILE_NAME}" @ONLY)
|
2024-07-30 23:45:07 +02:00
|
|
|
|
2023-11-05 23:25:58 +01:00
|
|
|
INSTALL(PROGRAMS "${CMAKE_BINARY_DIR}/${PORTABLE_BATCH_FILE_NAME}" DESTINATION .)
|
|
|
|
|
|
|
|
# NOTE this WILL pick up changes and additions!
|
|
|
|
# just re-build INSTALL no need to rerun CMake configure!
|
|
|
|
INSTALL(DIRECTORY packaging/portable/settings DESTINATION . )
|
|
|
|
|
|
|
|
if(7ZIP_EXE AND 7ZIP_WIN)
|
|
|
|
|
|
|
|
ADD_CUSTOM_TARGET(PORTABLE_INSTALL)
|
|
|
|
ADD_CUSTOM_TARGET(PORTABLE_PACKAGE DEPENDS PORTABLE_INSTALL)
|
|
|
|
|
|
|
|
ADD_CUSTOM_COMMAND(TARGET PORTABLE_INSTALL
|
|
|
|
COMMAND "${CMAKE_COMMAND}" --build . --target INSTALL --config $<CONFIG>
|
|
|
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
|
|
|
COMMENT "Building INSTALL...")
|
|
|
|
|
|
|
|
ADD_CUSTOM_COMMAND(TARGET PORTABLE_PACKAGE
|
|
|
|
COMMAND ${7ZIP_EXE} a -sfx7z.sfx ${CMAKE_BINARY_DIR}/${PORTABLE_PACKAGE_FILE_NAME} *
|
|
|
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_PREFIX}
|
|
|
|
COMMENT "Building portable package...")
|
|
|
|
|
|
|
|
else(7ZIP_EXE AND 7ZIP_WIN)
|
|
|
|
message(STATUS "Could not find 7-ZIP. Portable build disabled.")
|
|
|
|
endif(7ZIP_EXE AND 7ZIP_WIN)
|
|
|
|
ENDIF(WIN32)
|
2024-11-27 08:12:13 +01:00
|
|
|
ENDIF(OPTION_PORTABLE_PACKAGING)
|