forked from speed-dreams/speed-dreams-code
Find speed-dreams-data submodule by default
Now that speed-dreams-data is available as a submodule, this allows the build system to choose it for in-tree builds. Therefore, CMake will perform in the following order: 1. Do not search the speed-dreams-data package if SD_ASSUME_DATADIR is set. 2. Otherwise, do an in-tree build if the submodule has been updated. 3. Otherwise, search for the speed-dreams-data package on standard locations and CMAKE_PREFIX_PATH and/or CMAKE_FIND_ROOT_PATH. 4. Otherwise, return an error message. SD_HAS_DATADIR was rendered redundant, so it has been removed. However, SD_DATADIR_INSTALL_PREFIX was introduced because it would not equal SD_DATADIR_ABS for in-tree builds, where an installed version of the speed-dreams-data package is not required. In-tree builds now allow to generate NSIS installers with both code and data.
This commit is contained in:
parent
2c45379403
commit
880d53d88a
6 changed files with 43 additions and 34 deletions
|
@ -33,30 +33,43 @@ IF(APPLE)
|
||||||
SET(CMAKE_CXX_STANDARD_REQUIRED True)
|
SET(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||||
ENDIF(APPLE)
|
ENDIF(APPLE)
|
||||||
|
|
||||||
option(SD_ASSUME_DATADIR "Assume default directory for speed-dreams-data if not found")
|
option(SD_ASSUME_DATADIR "Assume default directory for speed-dreams-data")
|
||||||
|
include(GNUInstallDirs)
|
||||||
set(data_version 2.3.0)
|
|
||||||
find_package(speed-dreams-data ${data_version})
|
|
||||||
|
|
||||||
if(NOT SD_DATADIR)
|
|
||||||
if(SD_ASSUME_DATADIR)
|
|
||||||
include(GNUInstallDirs)
|
|
||||||
|
|
||||||
|
if(SD_ASSUME_DATADIR)
|
||||||
set(SD_DATADIR ${CMAKE_INSTALL_DATADIR}/games/speed-dreams-2)
|
set(SD_DATADIR ${CMAKE_INSTALL_DATADIR}/games/speed-dreams-2)
|
||||||
set(SD_DATADIR_ABS ${CMAKE_INSTALL_PREFIX}/${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)")
|
message(STATUS "Data directory: ${SD_DATADIR_ABS} (assumed)")
|
||||||
set(SD_HAS_DATADIR true)
|
elseif(EXISTS speed-dreams-data/CMakeLists.txt)
|
||||||
else()
|
add_subdirectory(speed-dreams-data)
|
||||||
message(WARNING "Data directory not found or incompatible with version "
|
set(SD_DATADIR ${CMAKE_INSTALL_DATADIR}/games/speed-dreams-2)
|
||||||
"${data_version}. Speed Dreams should still "
|
set(SD_DATADIR_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/games/speed-dreams-2)
|
||||||
"be able to build, but it might not run successfully. "
|
set(SD_DATADIR_ABS ${CMAKE_CURRENT_SOURCE_DIR}/speed-dreams-data/data)
|
||||||
"If speed-dreams-data has been installed to a non-standard location, "
|
message(STATUS "Data directory: ${SD_DATADIR_ABS} (in-tree)")
|
||||||
"please add -DCMAKE_PREFIX_PATH=<data-dir> to the command line to "
|
|
||||||
"find it.")
|
|
||||||
endif()
|
|
||||||
else()
|
else()
|
||||||
|
set(data_version 2.3.0)
|
||||||
|
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()
|
||||||
|
|
||||||
message(STATUS "Data directory: ${SD_DATADIR_ABS}")
|
message(STATUS "Data directory: ${SD_DATADIR_ABS}")
|
||||||
set(SD_HAS_DATADIR true)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
INCLUDE(cmake/macros.cmake)
|
INCLUDE(cmake/macros.cmake)
|
||||||
|
|
|
@ -174,15 +174,9 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Run-time directories */
|
/* Run-time directories */
|
||||||
#cmakedefine SD_HAS_DATADIR
|
#define SD_DATADIR "${SD_DATADIR}/"
|
||||||
|
#define SD_DATADIR_ABS "${SD_DATADIR_ABS}/"
|
||||||
#if defined(SD_HAS_DATADIR)
|
#define SD_DATADIR_INSTALL_PREFIX "${SD_DATADIR_INSTALL_PREFIX}/"
|
||||||
# define SD_DATADIR "${SD_DATADIR}/"
|
|
||||||
# define SD_DATADIR_ABS "${SD_DATADIR_ABS}/"
|
|
||||||
#else
|
|
||||||
# define SD_DATADIR ""
|
|
||||||
# define SD_DATADIR_ABS ""
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define SD_LIBDIR "${SD_LIBDIR}/"
|
#define SD_LIBDIR "${SD_LIBDIR}/"
|
||||||
#define SD_BINDIR "${SD_BINDIR}/"
|
#define SD_BINDIR "${SD_BINDIR}/"
|
||||||
|
|
|
@ -27,7 +27,7 @@ computer-controlled driver implementations, flexible race configuration
|
||||||
master server to compare your best lap times against other players."
|
master server to compare your best lap times against other players."
|
||||||
)
|
)
|
||||||
|
|
||||||
if(SD_HAS_DATADIR AND NOT SD_ASSUME_DATADIR)
|
if(NOT SD_ASSUME_DATADIR)
|
||||||
set(CPACK_PACKAGE_ICON "${SD_DATADIR_ABS}/data/img/header.bmp")
|
set(CPACK_PACKAGE_ICON "${SD_DATADIR_ABS}/data/img/header.bmp")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
set(CPACK_NSIS_INSTALLED_ICON_NAME ${PROJECT_NAME})
|
set(CPACK_NSIS_INSTALLED_ICON_NAME ${PROJECT_NAME})
|
||||||
set(CPACK_NSIS_MUI_FINISHPAGE_RUN ${PROJECT_NAME})
|
set(CPACK_NSIS_MUI_FINISHPAGE_RUN ${PROJECT_NAME})
|
||||||
set(CPACK_NSIS_DISPLAY_NAME "Speed Dreams ${CPACK_PACKAGE_VERSION} (engine and tools)")
|
set(CPACK_NSIS_DISPLAY_NAME "Speed Dreams ${CPACK_PACKAGE_VERSION}")
|
||||||
set(CPACK_NSIS_URL_INFO_ABOUT "${CMAKE_PROJECT_HOMEPAGE_URL}")
|
set(CPACK_NSIS_URL_INFO_ABOUT "${CMAKE_PROJECT_HOMEPAGE_URL}")
|
||||||
set(CPACK_NSIS_HELP_LINK "https://forge.a-lec.org/speed-dreams/")
|
set(CPACK_NSIS_HELP_LINK "https://forge.a-lec.org/speed-dreams/")
|
||||||
set(CPACK_PACKAGE_EXECUTABLES
|
set(CPACK_PACKAGE_EXECUTABLES
|
||||||
|
@ -23,7 +23,7 @@ set(CPACK_NSIS_MENU_LINKS
|
||||||
"https://forge.a-lec.org/speed-dreams/" "Project source repositories"
|
"https://forge.a-lec.org/speed-dreams/" "Project source repositories"
|
||||||
"/doc/userman/how_to_drive.html" "User manual")
|
"/doc/userman/how_to_drive.html" "User manual")
|
||||||
|
|
||||||
if(SD_HAS_DATADIR AND NOT SD_ASSUME_DATADIR)
|
if(NOT SD_ASSUME_DATADIR)
|
||||||
set(CPACK_NSIS_MUI_ICON "${SD_DATADIR_ABS}/data/icons/icon.ico")
|
set(CPACK_NSIS_MUI_ICON "${SD_DATADIR_ABS}/data/icons/icon.ico")
|
||||||
set(CPACK_NSIS_MUI_UNIICON "${SD_DATADIR_ABS}/data/icons/icon.ico")
|
set(CPACK_NSIS_MUI_UNIICON "${SD_DATADIR_ABS}/data/icons/icon.ico")
|
||||||
set(CPACK_NSIS_MUI_WELCOMEFINISHPAGE_BITMAP "${SD_DATADIR_ABS}/data/img/header-vert.bmp")
|
set(CPACK_NSIS_MUI_WELCOMEFINISHPAGE_BITMAP "${SD_DATADIR_ABS}/data/img/header-vert.bmp")
|
||||||
|
|
|
@ -449,6 +449,8 @@ bool GfApplication::parseOptions()
|
||||||
strDataDir = GfSetDataDir(SD_DATADIR);
|
strDataDir = GfSetDataDir(SD_DATADIR);
|
||||||
if (strDataDir.empty() || !GfDirExists(strDataDir.c_str()))
|
if (strDataDir.empty() || !GfDirExists(strDataDir.c_str()))
|
||||||
strDataDir = GfSetDataDir(SD_DATADIR_ABS);
|
strDataDir = GfSetDataDir(SD_DATADIR_ABS);
|
||||||
|
if (strDataDir.empty() || !GfDirExists(strDataDir.c_str()))
|
||||||
|
strDataDir = GfSetDataDir(SD_DATADIR_INSTALL_PREFIX);
|
||||||
|
|
||||||
// Check if ALL the Speed-dreams dirs have a usable value, and exit if not.
|
// Check if ALL the Speed-dreams dirs have a usable value, and exit if not.
|
||||||
if (strLocalDir.empty() || strLibDir.empty() || strBinDir.empty() || strDataDir.empty())
|
if (strLocalDir.empty() || strLibDir.empty() || strBinDir.empty() || strDataDir.empty())
|
||||||
|
|
|
@ -9,7 +9,7 @@ IF(MSVC)
|
||||||
SET(_SOURCES ${_SOURCES} main.rc resource.h ../../data/data/icons/icon.ico)
|
SET(_SOURCES ${_SOURCES} main.rc resource.h ../../data/data/icons/icon.ico)
|
||||||
ENDIF(MSVC)
|
ENDIF(MSVC)
|
||||||
|
|
||||||
IF(SD_HAS_DATADIR AND NOT SD_ASSUME_DATADIR)
|
IF(NOT SD_ASSUME_DATADIR)
|
||||||
configure_file(${CMAKE_SOURCE_DIR}/cmake/${PROJECT_NAME}.rc.in.cmake
|
configure_file(${CMAKE_SOURCE_DIR}/cmake/${PROJECT_NAME}.rc.in.cmake
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.rc)
|
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.rc)
|
||||||
SET(_SOURCES ${_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.rc)
|
SET(_SOURCES ${_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.rc)
|
||||||
|
|
Loading…
Reference in a new issue