From 8046ceadf3f862bd83ff4f72b66afaeac2d6b486 Mon Sep 17 00:00:00 2001 From: Chris Mocock Date: Sat, 11 Apr 2026 20:21:10 +0100 Subject: [PATCH] CPack/NSIS: Add option to not display component selection page Fixes: #27754 --- Help/cpack_gen/nsis.rst | 6 ++++++ Help/release/dev/nsis_ignore_components_page.rst | 6 ++++++ Source/CPack/cmCPackNSISGenerator.cxx | 6 ++++-- Tests/CPackNSISGenerator/CMakeLists.txt | 1 + Tests/CPackNSISGenerator/RunCPackVerifyResult.cmake | 9 +++++++++ 5 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 Help/release/dev/nsis_ignore_components_page.rst diff --git a/Help/cpack_gen/nsis.rst b/Help/cpack_gen/nsis.rst index 53b1e9b279..a6bc84ad1d 100644 --- a/Help/cpack_gen/nsis.rst +++ b/Help/cpack_gen/nsis.rst @@ -249,3 +249,9 @@ on Windows Nullsoft Scriptable Install System. allowing an install. Allowed values for this variable are ``on``, ``off``, and ``force``. If not specified, the default behavior is ``on``. + +.. variable:: CPACK_NSIS_IGNORE_COMPONENTS_PAGE + + .. versionadded:: 4.4 + + If set, do not display the page containing the license during installation. diff --git a/Help/release/dev/nsis_ignore_components_page.rst b/Help/release/dev/nsis_ignore_components_page.rst new file mode 100644 index 0000000000..f5c36e39e4 --- /dev/null +++ b/Help/release/dev/nsis_ignore_components_page.rst @@ -0,0 +1,6 @@ +nsis_ignore_components_page +--------------------------- + +* The :cpack_gen:`CPack NSIS Generator` gained a new variable + :variable:`CPACK_NSIS_IGNORE_COMPONENTS_PAGE` to ignore the + component selection page in the installer. diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index e3a060c133..551a93e7ef 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -375,8 +375,10 @@ int cmCPackNSISGenerator::PackageFiles() } this->SetOptionIfNotSet("CPACK_NSIS_INSTALLATION_TYPES", installTypesCode); - this->SetOptionIfNotSet("CPACK_NSIS_PAGE_COMPONENTS", - "!insertmacro MUI_PAGE_COMPONENTS"); + if (!this->IsSet("CPACK_NSIS_IGNORE_COMPONENTS_PAGE")) { + this->SetOptionIfNotSet("CPACK_NSIS_PAGE_COMPONENTS", + "!insertmacro MUI_PAGE_COMPONENTS"); + } this->SetOptionIfNotSet("CPACK_NSIS_FULL_INSTALL", ""); this->SetOptionIfNotSet("CPACK_NSIS_COMPONENT_SECTIONS", componentCode); this->SetOptionIfNotSet("CPACK_NSIS_COMPONENT_SECTION_LIST", sectionList); diff --git a/Tests/CPackNSISGenerator/CMakeLists.txt b/Tests/CPackNSISGenerator/CMakeLists.txt index 569a478e5e..ed4a2647bb 100644 --- a/Tests/CPackNSISGenerator/CMakeLists.txt +++ b/Tests/CPackNSISGenerator/CMakeLists.txt @@ -40,6 +40,7 @@ set(CPACK_NSIS_MANIFEST_DPI_AWARE ON) set(CPACK_NSIS_BRANDING_TEXT "CMake branding text") set(CPACK_NSIS_BRANDING_TEXT_TRIM_POSITION "RIGHT") set(CPACK_NSIS_IGNORE_LICENSE_PAGE ON) +set(CPACK_NSIS_IGNORE_COMPONENTS_PAGE ON) set(CPACK_NSIS_CRC_CHECK "off") include(CPack) diff --git a/Tests/CPackNSISGenerator/RunCPackVerifyResult.cmake b/Tests/CPackNSISGenerator/RunCPackVerifyResult.cmake index e811deb433..66a112473f 100644 --- a/Tests/CPackNSISGenerator/RunCPackVerifyResult.cmake +++ b/Tests/CPackNSISGenerator/RunCPackVerifyResult.cmake @@ -70,6 +70,15 @@ else() message(FATAL_ERROR "License found in the project") endif() +# components page should not be present +file(STRINGS "${project_file}" line REGEX "!insertmacro MUI_PAGE_COMPONENTS") +string(FIND "${line}" "MUI_PAGE_COMPONENTS" output_index) +if("${output_index}" EQUAL "-1") + message(STATUS "Components page not found in the project") +else() + message(FATAL_ERROR "Components page found in the project") +endif() + file(STRINGS "${project_file}" line REGEX [[\\_CON\\]]) string(FIND "${line}" [[\_CON\]] output_index) message(STATUS "Found CON component reserved directory name as _CON")