This commit is contained in:
BruebachL 2026-11-05 07:50:09 +01:00 • committed by GitHub
commit 50aedb243b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 526 additions and 66 deletions

View file

@ -358,23 +358,44 @@ if(UNIX)
endif()
endif()
elseif(WIN32)
set(CPACK_GENERATOR NSIS ${CPACK_GENERATOR})
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(TRICE_IS_64_BIT 1)
else()
set(TRICE_IS_64_BIT 0)
# Which tool writes the installer. InnoSetup, through CPack's own Inno Setup generator
# (cmake/InnoSetup.cmake), is the default. NSIS stays selectable for one release as the
# fallback for anyone who needs the old installer, and so the two can still be built from
# one tree and compared on a real upgrade. Both consume the same install() rules, so this
# is a packaging choice, never a build change.
set(COCKATRICE_WIN_INSTALLER
"InnoSetup"
CACHE STRING "Windows installer generator: InnoSetup (default) or NSIS (legacy)"
)
set_property(CACHE COCKATRICE_WIN_INSTALLER PROPERTY STRINGS NSIS InnoSetup)
if(NOT COCKATRICE_WIN_INSTALLER MATCHES "^(NSIS|InnoSetup)$")
message(FATAL_ERROR "COCKATRICE_WIN_INSTALLER must be NSIS or InnoSetup, not '${COCKATRICE_WIN_INSTALLER}'")
endif()
# Configure file with custom definitions for NSIS.
configure_file("${COCKATRICE_CMAKE_PATH}/NSIS.definitions.nsh.in" "${PROJECT_BINARY_DIR}/NSIS.definitions.nsh")
# Installer-log sender for the AbortInstall Sentry hook (values parsed out of COCKATRICE_SENTRY_DSN in
# cmake/CrashReporting.cmake). Generated only when a DSN was parsed: cmake/NSIS.template.in embeds it under
# the same CPACK_SENTRY_ENABLED check, so a build without reporting never references or carries the helper.
# Installer-log sender for the failure hooks of both installers (values parsed out of
# COCKATRICE_SENTRY_DSN in cmake/CrashReporting.cmake). Generated only when a DSN was
# parsed: cmake/NSIS.template.in and cmake/InnoSetup.install.iss embed it under the same
# CPACK_SENTRY_ENABLED check, so a build without reporting never references or carries the
# helper. Configured above the installer choice because both branches consume it.
if(CPACK_SENTRY_ENABLED)
configure_file(
"${COCKATRICE_CMAKE_PATH}/SendInstallerLog.ps1.in" "${PROJECT_BINARY_DIR}/SendInstallerLog.ps1" @ONLY
)
set(COCKATRICE_SENTRY_INSTALLER_LOG "${PROJECT_BINARY_DIR}/SendInstallerLog.ps1")
endif()
if(COCKATRICE_WIN_INSTALLER STREQUAL "InnoSetup")
include(${COCKATRICE_CMAKE_PATH}/InnoSetup.cmake)
else()
set(CPACK_GENERATOR NSIS ${CPACK_GENERATOR})
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(TRICE_IS_64_BIT 1)
else()
set(TRICE_IS_64_BIT 0)
endif()
# Configure file with custom definitions for NSIS.
configure_file("${COCKATRICE_CMAKE_PATH}/NSIS.definitions.nsh.in" "${PROJECT_BINARY_DIR}/NSIS.definitions.nsh")
endif()
# Every runtime DLL a Windows install has to contain, as paths relative to the
@ -410,7 +431,9 @@ elseif(WIN32)
# is available to CMake, requiring the vcpkg half would mean guessing names
# again, which is what produced this bug report in the first place. So assert
# what is derived from the build's own link lists and leave the rest to the
# purge in cmake/NSIS.template.in, which removes every DLL regardless of name.
# installer's own delete: the purge in cmake/NSIS.template.in and the
# install-delete section in cmake/InnoSetup.install.iss both remove every DLL
# regardless of name.
set(_required_runtime "")
foreach(_qt_module IN LISTS COCKATRICE_QT_MODULES SERVATRICE_QT_MODULES ORACLE_QT_MODULES)
get_target_property(_qt_module_type ${_qt_module} TYPE)
@ -426,7 +449,7 @@ elseif(WIN32)
string(REPLACE ";" "\n" _required_runtime "${_required_runtime}")
file(WRITE "${PROJECT_BINARY_DIR}/required-runtime.txt" "${_required_runtime}\n")
# include vcredist into the package; NSIS will take care of running it
# include vcredist into the package; both installers run it after the payload
if(VCREDISTRUNTIME_FOUND)
install(FILES "${VCREDISTRUNTIME_FILE}" DESTINATION ./)
endif()