Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📦 Build installer with Inno setup #3086

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ cmake_policy(SET CMP0127 OLD)
include(CMakeDependentOption)
include(Macros)
include(FeatureSummary)
include(FetchContent)
include(CPackComponent)

################################################################################
# Project definition
Expand All @@ -16,17 +18,31 @@ set(PROJECT_NAME_LONG "Rigs of Rods")

set(REQUIRED_DEPS_VERSION 30)

project(${PROJECT_NAME_UNDERSCORE})
# The version is used by installer
project(${PROJECT_NAME_UNDERSCORE} VERSION 2023.09)

################################################################################
# Available build options
################################################################################
option(BUILD_DEV_VERSION "Disable this for official releases" ON)
option(BUILD_DOC_DOXYGEN "Build documentation from sources with Doxygen" OFF)
option(USE_PCH "Use a Precompiled header for speeding up the build" ON)
option(CREATE_CONTENT_FOLDER "Create the base content folder" ON)
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)
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)

# global cmake options
SET(BUILD_SHARED_LIBS ON)
Expand All @@ -43,7 +59,7 @@ SET(LIBRARY_OUTPUT_PATH ${RUNTIME_OUTPUT_DIRECTORY})

set(CMAKE_DEBUG_POSTFIX _d)

if (NOT USE_PCH)
if (NOT ROR_USE_PCH)
find_program(SCCACHE_PROGRAM sccache)
if (SCCACHE_PROGRAM)
set(CMAKE_CXX_COMPILER_LAUNCHER "${SCCACHE_PROGRAM}")
Expand Down
6 changes: 3 additions & 3 deletions cmake/GenerateVersionInfo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
# https://github.com/minetest/minetest/blob/master/cmake/Modules/GenerateVersion.cmake

macro(version_str_to_ints version year month suffix)
string(REGEX REPLACE "([0-9]+).[0-9]+[^\n\r]+" "\\1" ${year} ${version})
string(REGEX REPLACE "[0-9]+.([0-9]+)[^\n\r]+" "\\1" ${month} ${version})
string(REGEX REPLACE "[0-9]+.[0-9]+([^\n\r]+)" "\\1" ${suffix} ${version})
string(REGEX REPLACE "([0-9]+)\\.[0-9]+[^\n\r]*" "\\1" ${year} ${version})
string(REGEX REPLACE "[0-9]+\\.([0-9]+)[^\n\r]*" "\\1" ${month} ${version})
string(REGEX REPLACE "[0-9]+\\.[0-9]+([^\n\r]*)" "\\1" ${suffix} ${version})
endmacro(version_str_to_ints)

# Default variables
Expand Down
20 changes: 19 additions & 1 deletion cmake/Macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,27 @@ macro(better_parse_arglist opt args list_args)
endif ()
endmacro()


macro(lift_var)
foreach (varname IN ITEMS ${ARGN})
set("${varname}" "${${varname}}" PARENT_SCOPE)
endforeach ()
endmacro()

macro(dl_contentpack url name hash)
set(cname "CP_${name}")
FetchContent_Declare(
${cname}
URL ${url}
URL_MD5 ${hash}
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
SOURCE_DIR "${CMAKE_BINARY_DIR}/ContentPack/${name}"
)
FetchContent_MakeAvailable(${cname})
install(DIRECTORY "${CMAKE_BINARY_DIR}/ContentPack/${name}" DESTINATION "./content/" COMPONENT ${cname})

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()
2 changes: 1 addition & 1 deletion doc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
####################################################################################################
# Doxygen Documentation
####################################################################################################
if( BUILD_DOC_DOXYGEN )
if( ROR_BUILD_DOC_DOXYGEN )
# The doxygen package is required in order to build documentation
find_package( Doxygen REQUIRED )

Expand Down
91 changes: 53 additions & 38 deletions source/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ endif ()
# POST-BUILD STEPS
####################################################################################################

if (USE_PCH)
if (ROR_USE_PCH)
target_precompile_headers(${BINNAME} PRIVATE pch.h)
endif ()

Expand Down Expand Up @@ -487,7 +487,7 @@ if (WIN32)
set(CFG_OGRE_PLUGIN_CAELUM "Plugin=Caelum")
set(CFG_OGRE_PLUGIN_CAELUM_D "Plugin=Caelum_d")
else ()
if (${_PREFIX}USE_CAELUM STREQUAL "SYSTEM")
if (ROR_USE_CAELUM STREQUAL "SYSTEM")
set(CFG_OGRE_PLUGIN_CAELUM "Plugin=../libCaelum.so")
set(CFG_OGRE_PLUGIN_CAELUM_D "Plugin=../libCaelum_d.so")
else ()
Expand All @@ -502,7 +502,7 @@ configure_file(plugins_d.cfg.in ${RUNTIME_OUTPUT_DIRECTORY}/plugins_d.cfg)
# Copy resources to bin directory
# -----------------------
recursive_zip_folder("${CMAKE_SOURCE_DIR}/resources" "${RUNTIME_OUTPUT_DIRECTORY}/resources")
if (CREATE_CONTENT_FOLDER)
if (ROR_CREATE_CONTENT_FOLDER)
recursive_zip_folder("${CMAKE_SOURCE_DIR}/content" "${RUNTIME_OUTPUT_DIRECTORY}/content")
endif ()

Expand All @@ -513,20 +513,20 @@ fast_copy("${CMAKE_SOURCE_DIR}/languages" "${RUNTIME_OUTPUT_DIRECTORY}/languages

# Install targets
# -----------------------
install(TARGETS ${BINNAME} DESTINATION .)
install(TARGETS ${BINNAME} DESTINATION . COMPONENT "Base_Game")

install(DIRECTORY ${CMAKE_SOURCE_DIR}/resources/fonts/ DESTINATION languages)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/languages/ DESTINATION languages FILES_MATCHING PATTERN "*.mo")
install(DIRECTORY ${RUNTIME_OUTPUT_DIRECTORY}/resources/ DESTINATION resources)
install(DIRECTORY ${RUNTIME_OUTPUT_DIRECTORY}/content/ DESTINATION content)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/resources/fonts/ DESTINATION languages COMPONENT "Base_Game")
install(DIRECTORY ${CMAKE_SOURCE_DIR}/languages/ DESTINATION languages COMPONENT "Base_Game" FILES_MATCHING PATTERN "*.mo" )
install(DIRECTORY ${RUNTIME_OUTPUT_DIRECTORY}/resources/ DESTINATION resources COMPONENT "Base_Game")
install(DIRECTORY ${RUNTIME_OUTPUT_DIRECTORY}/content/ DESTINATION content COMPONENT "Base_Content")

if (WIN32)
install(FILES ${RUNTIME_OUTPUT_DIRECTORY}/plugins.cfg DESTINATION .)
install(FILES ${CMAKE_SOURCE_DIR}/tools/windows/.itch.toml DESTINATION .)
install(FILES ${RUNTIME_OUTPUT_DIRECTORY}/plugins.cfg DESTINATION . COMPONENT "Base_Game")
install(FILES ${CMAKE_SOURCE_DIR}/tools/windows/.itch.toml DESTINATION . COMPONENT "Base_Game")
install(CODE "file(GLOB files ${RUNTIME_OUTPUT_DIRECTORY}/*.dll)
file(INSTALL \${files} DESTINATION \${CMAKE_INSTALL_PREFIX})")
file(INSTALL \${files} DESTINATION \${CMAKE_INSTALL_PREFIX})" COMPONENT "Base_Game")
install(CODE "file(GLOB files ${RUNTIME_OUTPUT_DIRECTORY}/*.exe)
file(INSTALL \${files} DESTINATION \${CMAKE_INSTALL_PREFIX})")
file(INSTALL \${files} DESTINATION \${CMAKE_INSTALL_PREFIX})" COMPONENT "Base_Game")
else ()
set(PLUGINS_FOLDER "lib")
configure_file(plugins.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/plugins-install.cfg)
Expand All @@ -540,38 +540,53 @@ endif ()

# CPack
# -----------------------
set(CPACK_PACKAGE_NAME "Rigs of Rods")
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 "Edgar@AnotherFoxGuy.com")
set(CPACK_PACKAGE_VENDOR "AnotherFoxGuy")
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/tools/windows/license.rtf")
set(CPACK_PACKAGE_EXECUTABLES "RoR" "Rigs of Rods Simulator")

set(CPACK_PACKAGE_EXECUTABLES "RoR" "Rigs of Rods")


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")
set(CPACK_CREATE_DESKTOP_LINKS "RoR" "Rigs of Rods")

set(CPACK_INNOSETUP_ALLOW_CUSTOM_DIRECTORY ON)
set(CPACK_INNOSETUP_USE_MODERN_WIZARD ON)
set(CPACK_INNOSETUP_ICON_FILE "${CMAKE_CURRENT_SOURCE_DIR}/ror.ico")
set(CPACK_INNOSETUP_SETUP_WizardImageFile "${CMAKE_SOURCE_DIR}/tools/windows/RoRSetupLarge.bmp")
set(CPACK_INNOSETUP_SETUP_WizardSmallImageFile "${CMAKE_SOURCE_DIR}/tools/windows/ror-64.bmp")
set(CPACK_INNOSETUP_SETUP_AppId "{{EF536888-919D-47C0-8675-2F7AFA52EE27}")

set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}")

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 ()

if (WIN32)
#For Windows Desktop shortcuts
set(CPACK_CREATE_DESKTOP_LINKS "RoR" "Rigs of Rods Simulator")

# Windows Add or Remove Program properties
set(CPACK_WIX_PROGRAM_MENU_FOLDER "Rigs of Rods Simulator")
set(CPACK_WIX_PROPERTY_ARPCOMMENTS "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}")
set(CPACK_WIX_PROPERTY_ARPHELPLINK "https://discord.gg/rigsofrods")
set(CPACK_WIX_PROPERTY_ARPURLINFOABOUT "https://www.rigsofrods.org/")
set(CPACK_WIX_PROPERTY_URLUPDATEINFO "https://github.com/RigsOfRods/rigs-of-rods/releases")

set(CPACK_WIX_PRODUCT_ICON "${CMAKE_SOURCE_DIR}/source/main/ror.ico")
set(CPACK_WIX_UI_BANNER "${CMAKE_SOURCE_DIR}/tools/windows/bannrbmp.bmp")
set(CPACK_WIX_UI_DIALOG "${CMAKE_SOURCE_DIR}/tools/windows/dlgbmp.bmp")

set(CPACK_WIX_LICENSE_RTF "${CPACK_RESOURCE_FILE_LICENSE}")
set(CPACK_WIX_UPGRADE_GUID "dc178e9c-840d-443f-b249-434433ae5fd1")

set(CPACK_PACKAGE_NAME "Rigs of Rods")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "Rigs of Rods")
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${PROJECT_VERSION}")
set(CPACK_GENERATOR ZIP;WIX)
set(CPACK_MODULE_PATH "")
if(NOT ROR_BUILD_INSTALLER STREQUAL "Offline")
dl_contentpack("http://forum.rigsofrods.org/resources/content-pack-trucks-heavy-equipment.490/download" "HeavyEquipment" "49a6edcce914f3d5fd57204342091c62")
dl_contentpack("http://forum.rigsofrods.org/resources/content-pack-cars-light-vehicles.491/download" "LightVehicles" "1f5c074708f4c6d27391e612d41d871c")
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
27 changes: 18 additions & 9 deletions source/version_info/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,27 @@ set(VERSION_DEF_H ${CMAKE_CURRENT_BINARY_DIR}/version_def.h)
# Search for Git executable
find_package(Git)

# CMake custom targets are always out of date. Therefore the following target will update the
# versioning information on each build. It executes the GenerateVersionInfo.cmake script which
# generates the version_info.cpp and version_def.h files.
set(VERSION_FLAGS -DBUILD_DEV_VERSION=${BUILD_DEV_VERSION})

if (DEFINED ${_PREFIX}CUSTOM_VERSION)
list(
if(ROR_BUILD_INSTALLER STREQUAL "Off")
set(VERSION_FLAGS -DBUILD_DEV_VERSION=${ROR_BUILD_DEV_VERSION})
if (DEFINED ROR_CUSTOM_VERSION)
list(
APPEND VERSION_FLAGS
-DBUILD_CUSTOM_VERSION=TRUE
-DCUSTOM_VERSION=${${_PREFIX}CUSTOM_VERSION}
-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 ()
endif()

# CMake custom targets are always out of date. Therefore the following target will update the
# versioning information on each build. It executes the GenerateVersionInfo.cmake script which
# generates the version_info.cpp and version_def.h files.

add_custom_target(
generate_version
Expand Down
31 changes: 31 additions & 0 deletions tools/windows/AfterInstall.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
-----------------------------------

Thanks for installing Rigs of Rods!

-----------------------------------

By default, Rigs of Rods only comes with a very small selection of vehicles and terrains.
For the best experience download some mods from the Repository: https://forum.rigsofrods.org/resources/
The Showroom Subforum (https://forum.rigsofrods.org/#repository.11) and the Archives (http://archives.rigsofrods.net/) contain additional content not found in the Repository.
If you downloaded one (or more) content packs, please note that the licenses of the included content may be different from the license used by Rigs of Rods.

-----------------------------------

Check out the Beginner's Guide (http://docs.rigsofrods.org/gameplay/beginners-guide/) to learn the basics of Rigs of Rods.

-----------------------------------

Come visit our Discord server!
https://discord.gg/rigsofrods

-----------------------------------

Other useful links:

Website - https://rigsofrods.org/
Forum - https://forum.rigsofrods.org/
Repository - https://forum.rigsofrods.org/resources/
Documentation - https://docs.rigsofrods.org/
GitHub - https://github.com/RigsOfRods/rigs-of-rods

-----------------------------------
Loading