Skip to content

Commit

Permalink
📦 Add support for building different installers
Browse files Browse the repository at this point in the history
Possible values:
Off       - Do not build installer
Online    - Build fully online installer
Offline   - build installer without contentpack
Bundled   - build installer with contentpack bundled
  • Loading branch information
AnotherFoxGuy committed Sep 12, 2023
1 parent 3f4f411 commit 59ce704
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 21 deletions.
12 changes: 11 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,19 @@ option(ROR_BUILD_DEV_VERSION "Disable this for official releases" ON)
option(ROR_BUILD_DOC_DOXYGEN "Build documentation from sources with Doxygen" OFF)
option(ROR_USE_PCH "Use a Precompiled header for speeding up the build" ON)
option(ROR_CREATE_CONTENT_FOLDER "Create the base content folder" ON)
option(ROR_BUILD_INSTALLER "Build the Windows installer" OFF)
set(ROR_DEPENDENCY_DIR "${CMAKE_SOURCE_DIR}/dependencies" CACHE PATH "Path to the dependencies")

set(ROR_BUILD_INSTALLER "Off" CACHE STRING
"Build the Windows installer. Possible values:
Off - Do not build installer
Online - Build fully online installer
Offline - build installer without contentpack
Bundled - build installer with contentpack bundled"
)
set_property(CACHE ROR_BUILD_INSTALLER PROPERTY STRINGS Off Online Offline Bundled)

message("Create installer: ${ROR_BUILD_INSTALLER}")

set(ROR_FEAT_TIMING OFF)
set(FETCHCONTENT_QUIET OFF)

Expand Down
7 changes: 6 additions & 1 deletion cmake/Macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -166,5 +166,10 @@ macro(dl_contentpack url name hash)
)
FetchContent_MakeAvailable(${cname})
install(DIRECTORY "${CMAKE_BINARY_DIR}/ContentPack/${name}" DESTINATION "./content/" COMPONENT ${cname})
cpack_add_component(${cname} DISPLAY_NAME "${name}" GROUP "ContentPack" DISABLED TRUE DOWNLOADED TRUE)

if(ROR_BUILD_INSTALLER STREQUAL "Bundled")
cpack_add_component(${cname} DISPLAY_NAME "${name}" GROUP "ContentPack" REQUIRED TRUE)
else()
cpack_add_component(${cname} DISPLAY_NAME "${name}" GROUP "ContentPack" DISABLED TRUE DOWNLOADED TRUE)
endif ()
endmacro()
33 changes: 22 additions & 11 deletions source/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ endif ()
# CPack
# -----------------------
set(CPACK_PACKAGE_NAME "Rigs of Rods")
set(CPACK_PACKAGE_FILE_NAME "rigs-of-rods-${CMAKE_PROJECT_VERSION}")
set(CPACK_PACKAGE_FILE_NAME "rigs-of-rods-${CMAKE_PROJECT_VERSION}-${ROR_BUILD_INSTALLER}")
set(CPACK_PACKAGE_DESCRIPTION "Rigs of Rods soft-body physics simulator")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Rigs of Rods is an open source vehicle simulator based on soft-body physics.")
set(CPACK_PACKAGE_CONTACT "[email protected]")
Expand All @@ -544,7 +544,7 @@ set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/tools/windows/license.rtf")
set(CPACK_PACKAGE_EXECUTABLES "RoR" "Rigs of Rods")


if (WIN32 AND ROR_BUILD_INSTALLER)
if (WIN32 AND NOT ROR_BUILD_INSTALLER STREQUAL "Off")
set(CPACK_GENERATOR INNOSETUP)
set(CPACK_ADD_REMOVE TRUE)
set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/tools/windows/AfterInstall.txt")
Expand All @@ -559,17 +559,28 @@ if (WIN32 AND ROR_BUILD_INSTALLER)

set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}")

cpack_add_component("Base_Game" DISPLAY_NAME "Game" GROUP "Main" REQUIRED TRUE)
cpack_add_component("Base_Content" DISPLAY_NAME "Starter content" GROUP "Main")

cpack_configure_downloads("http://prdownloads.sourceforge.net/rigs-of-rods/")

if(ROR_BUILD_INSTALLER STREQUAL "Bundled")
set(CPACK_INNOSETUP_SETUP_DiskSpanning True)
endif()

if(ROR_BUILD_INSTALLER STREQUAL "Online")
cpack_add_component("Base_Game" DISPLAY_NAME "Game" GROUP "Main" REQUIRED TRUE DOWNLOADED TRUE)
cpack_add_component("Base_Content" DISPLAY_NAME "Starter content" GROUP "Main" DOWNLOADED TRUE)
else()
cpack_add_component("Base_Game" DISPLAY_NAME "Game" GROUP "Main" REQUIRED TRUE)
cpack_add_component("Base_Content" DISPLAY_NAME "Starter content" GROUP "Main")
endif ()

dl_contentpack("http://forum.rigsofrods.org/resources/content-pack-trucks-heavy-equipment.490/download" "HeavyEquipment" "ef25dc781ad148359cbcec7a67281747")
dl_contentpack("http://forum.rigsofrods.org/resources/content-pack-cars-light-vehicles.491/download" "LightVehicles" "583a3056d1e84744907d83a58c99623b")
dl_contentpack("http://forum.rigsofrods.org/resources/content-pack-trailers-loads.492/download" "Loads" "c86e4d5c605f6c97efc4da25257061bb")
dl_contentpack("http://forum.rigsofrods.org/resources/content-pack-air-sea.495/download" "AirSea" "d5510617dfbc64791e4006522a5110de")
dl_contentpack("http://forum.rigsofrods.org/resources/content-pack-trains.494/download" "Trains" "0927db107a7d8a164f57c9b45d57f773")
dl_contentpack("http://forum.rigsofrods.org/resources/content-pack-terrains.496/download" "Terrains" "48374d3f90045b6cd9a8271f1531f4b4")
if(NOT ROR_BUILD_INSTALLER STREQUAL "Offline")
dl_contentpack("http://forum.rigsofrods.org/resources/content-pack-trucks-heavy-equipment.490/download" "HeavyEquipment" "ef25dc781ad148359cbcec7a67281747")
dl_contentpack("http://forum.rigsofrods.org/resources/content-pack-cars-light-vehicles.491/download" "LightVehicles" "583a3056d1e84744907d83a58c99623b")
dl_contentpack("http://forum.rigsofrods.org/resources/content-pack-trailers-loads.492/download" "Loads" "c86e4d5c605f6c97efc4da25257061bb")
dl_contentpack("http://forum.rigsofrods.org/resources/content-pack-air-sea.495/download" "AirSea" "d5510617dfbc64791e4006522a5110de")
dl_contentpack("http://forum.rigsofrods.org/resources/content-pack-trains.494/download" "Trains" "0927db107a7d8a164f57c9b45d57f773")
dl_contentpack("http://forum.rigsofrods.org/resources/content-pack-terrains.496/download" "Terrains" "48374d3f90045b6cd9a8271f1531f4b4")
endif ()
else ()
set(CPACK_GENERATOR ZIP)
endif ()
Expand Down
16 changes: 8 additions & 8 deletions source/version_info/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,7 @@ set(VERSION_DEF_H ${CMAKE_CURRENT_BINARY_DIR}/version_def.h)
# Search for Git executable
find_package(Git)

# When packaging the installer use the version from the project
if(ROR_BUILD_INSTALLER)
set(VERSION_FLAGS
-DBUILD_DEV_VERSION=OFF
-DBUILD_CUSTOM_VERSION=TRUE
-DCUSTOM_VERSION=${PROJECT_VERSION}
)
else()
if(ROR_BUILD_INSTALLER STREQUAL "Off")
set(VERSION_FLAGS -DBUILD_DEV_VERSION=${ROR_BUILD_DEV_VERSION})
if (DEFINED ROR_CUSTOM_VERSION)
list(
Expand All @@ -25,6 +18,13 @@ else()
-DCUSTOM_VERSION=${ROR_CUSTOM_VERSION}
)
endif ()
else()
# When packaging the installer use the version from the project
set(VERSION_FLAGS
-DBUILD_DEV_VERSION=OFF
-DBUILD_CUSTOM_VERSION=TRUE
-DCUSTOM_VERSION=${PROJECT_VERSION}
)
endif()

# CMake custom targets are always out of date. Therefore the following target will update the
Expand Down

0 comments on commit 59ce704

Please sign in to comment.