mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 09:33:25 -08:00
COCKATRICE_WIN_INSTALLER chooses which tool writes the Windows installer.
NSIS stays the default, so nothing on the existing path changes; InnoSetup
selects CPack's own INNOSETUP generator (CMake >= 3.27) and builds from the
same install() rules. Both can be built from one tree and the resulting
installers compared on an upgrade from 3.1.x.
What the Inno path does differently:
- Installs over the previous version instead of running the old uninstaller
first, which is what the backup/restore pair in the NSIS template exists
to survive.
- Closes and restarts a running application through Windows Restart Manager
(CloseApplications/RestartApplications) instead of the two PowerShell
process guards the template needed.
- Removes stale runtime with one [InstallDelete] of *.dll and Plugins,
instead of RetryDllPurge and its diagnostics.
- Writes a log on every run through SetupLogging, instead of CockLog.
- Resolves the install directory from the legacy NSIS registration, and
deletes that registration after a successful install so the old
uninstaller (whose blanket directory removal caused the 3.1.x data loss)
cannot be run after the upgrade.
- Keeps the portable mode the client detects, the C++ runtime bootstrap and
the /PORTABLE switch.
The in-app updater still passes the NSIS switches (/R, /PID=); the installer
logs them so the first Windows run settles whether Inno Setup accepts them or
the switch-over needs a client version gate.
The installer content check in .ci/compile.sh learns to strip Inno Setup's
{app} prefix from the paths 7-Zip lists, so the required-runtime comparison
works for either archive format.
92 lines
4.9 KiB
CMake
92 lines
4.9 KiB
CMake
# Windows installer written by Inno Setup, through CPack's own InnoSetup generator.
|
|
#
|
|
# Included from the WIN32 branch of the top-level CMakeLists.txt when
|
|
# COCKATRICE_WIN_INSTALLER is InnoSetup. It sits next to the NSIS template rather than
|
|
# replacing it so both installers can be built from the same tree and compared on a real
|
|
# upgrade.
|
|
#
|
|
# The generator writes [Files], [Dirs], [Icons], [Run] and [Registry] from the install()
|
|
# rules the project already declares, so nothing here repeats them. What is added is only
|
|
# what the generator has no opinion about: upgrade identity, closure behaviour for a
|
|
# running application, the stale-runtime [InstallDelete], and the migration off the NSIS
|
|
# installation (both script fragments below).
|
|
|
|
# The generator itself arrived in 3.27; cmake_minimum_required() here would reset the
|
|
# policies the top level already selected, so it is refused at the include site instead.
|
|
if(CMAKE_VERSION VERSION_LESS 3.27)
|
|
message(FATAL_ERROR "COCKATRICE_WIN_INSTALLER=InnoSetup needs CMake >= 3.27 (found ${CMAKE_VERSION})")
|
|
endif()
|
|
|
|
# CPack is allowed to be told -DCPACK_GENERATOR=... by the caller; do not list the
|
|
# generator twice when that caller already asked for it.
|
|
if(NOT "InnoSetup" IN_LIST CPACK_GENERATOR)
|
|
set(CPACK_GENERATOR InnoSetup ${CPACK_GENERATOR})
|
|
endif()
|
|
|
|
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|
set(CPACK_INNOSETUP_ARCHITECTURE x64)
|
|
else()
|
|
set(CPACK_INNOSETUP_ARCHITECTURE x86)
|
|
endif()
|
|
|
|
# Shortcuts and the finish-page run entry come from the executables CPack already knows.
|
|
# Only the client is offered: oracle.exe and servatrice.exe are tools, and the NSIS
|
|
# installer never created shortcuts for them either.
|
|
set(CPACK_PACKAGE_EXECUTABLES "cockatrice" "Cockatrice")
|
|
set(CPACK_INNOSETUP_RUN_EXECUTABLES "cockatrice")
|
|
|
|
set(CPACK_INNOSETUP_USE_MODERN_WIZARD ON)
|
|
set(CPACK_INNOSETUP_PROGRAM_MENU_FOLDER "Cockatrice")
|
|
set(CPACK_INNOSETUP_ICON_FILE "${PROJECT_SOURCE_DIR}/cockatrice/resources/appicon.ico")
|
|
set(CPACK_INNOSETUP_IGNORE_README_PAGE ON)
|
|
# The uninstall entry is the only place a user sees the version they have after an update
|
|
# that replaced the folder, so keep it and give it the icon.
|
|
set(CPACK_INNOSETUP_CREATE_UNINSTALL_LINK ON)
|
|
|
|
# Upgrade identity. Never change this value: it is what makes a new build an upgrade of the
|
|
# previous one (same uninstall entry, same "previous app path", same tasks) instead of a
|
|
# second, parallel installation. No braces: a literal { in an .iss script opens a constant,
|
|
# and a GUID here buys nothing that this string does not already do.
|
|
set(CPACK_INNOSETUP_SETUP_AppId "Cockatrice-6F1C5B2A-9D84-4E37-B0A5-2C7E9A31D4F8")
|
|
set(CPACK_INNOSETUP_SETUP_AppName "Cockatrice")
|
|
set(CPACK_INNOSETUP_SETUP_DefaultGroupName "Cockatrice")
|
|
|
|
# An NSIS install registers nothing under Inno's own keys, so the default directory is
|
|
# resolved from the legacy registration instead of guessed. See GetDefaultInstallDir in
|
|
# cmake/InnoSetup.code.iss.
|
|
set(CPACK_INNOSETUP_SETUP_DefaultDirName "{code:GetDefaultInstallDir}")
|
|
|
|
set(CPACK_INNOSETUP_SETUP_Compression "lzma2/max")
|
|
set(CPACK_INNOSETUP_SETUP_SolidCompression ON)
|
|
# Replaces the CockLog/CockLogListing machinery: every run writes a log to %TEMP% without
|
|
# any script support, which is what a failed upgrade on a user's machine needs to be
|
|
# diagnosable after the fact.
|
|
set(CPACK_INNOSETUP_SETUP_SetupLogging ON)
|
|
|
|
set(CPACK_INNOSETUP_SETUP_PrivilegesRequired "admin")
|
|
# Users without administrator rights get a working installation instead of a dead end;
|
|
# /CURRENTUSER covers the same choice when driven by a package manager or the updater.
|
|
set(CPACK_INNOSETUP_SETUP_PrivilegesRequiredOverridesAllowed "dialog commandline")
|
|
|
|
# Restart Manager, not a PowerShell process scan. Setup detects the applications holding
|
|
# the files it is about to replace, closes them, and starts them again afterwards. This is
|
|
# the whole of what WaitForAppToClose/GuardAppsNotRunning/ForceCloseApps approximated in
|
|
# the NSIS template, including the uninstaller copies that had to repeat it.
|
|
set(CPACK_INNOSETUP_SETUP_CloseApplications ON)
|
|
set(CPACK_INNOSETUP_SETUP_RestartApplications ON)
|
|
|
|
# The payload is built for one architecture only; refuse to install it on a system that
|
|
# cannot run it. x64 (not x64compatible) keeps this valid on every Inno Setup 6.x.
|
|
if(CPACK_INNOSETUP_ARCHITECTURE STREQUAL "x64")
|
|
set(CPACK_INNOSETUP_SETUP_ArchitecturesAllowed "x64")
|
|
set(CPACK_INNOSETUP_SETUP_ArchitecturesInstallIn64BitMode "x64")
|
|
endif()
|
|
|
|
set(CPACK_INNOSETUP_SETUP_UninstallDisplayIcon "{app}\\cockatrice.exe")
|
|
|
|
# Sections the generator does not emit (the stale-runtime deletes), and the behaviour it
|
|
# cannot express (legacy migration, portable marker, C++ runtime bootstrap).
|
|
set(CPACK_INNOSETUP_EXTRA_SCRIPTS "${COCKATRICE_CMAKE_PATH}/InnoSetup.install.iss")
|
|
set(CPACK_INNOSETUP_CODE_FILES "${COCKATRICE_CMAKE_PATH}/InnoSetup.code.iss")
|
|
|
|
message(STATUS "Windows installer: Inno Setup (CPack InnoSetup generator, ${CPACK_INNOSETUP_ARCHITECTURE})")
|