1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-14 02:08:27 +08:00

CPack/NSIS: Allow setting CRCCheck

Fixes: #27260
This commit is contained in:
Daniel Pfeifer
2025-09-24 19:22:21 +02:00
parent 60cdc353c1
commit 3c7fee0d99
6 changed files with 29 additions and 0 deletions

View File

@@ -240,3 +240,12 @@ on Windows Nullsoft Scriptable Install System.
where ``<preArgs>...`` is constructed from ``CPACK_NSIS_EXECUTABLE_PRE_ARGUMENTS`` where ``<preArgs>...`` is constructed from ``CPACK_NSIS_EXECUTABLE_PRE_ARGUMENTS``
and ``<postArgs>...`` is constructed from ``CPACK_NSIS_EXECUTABLE_POST_ARGUMENTS``. and ``<postArgs>...`` is constructed from ``CPACK_NSIS_EXECUTABLE_POST_ARGUMENTS``.
.. variable:: CPACK_NSIS_CRC_CHECK
.. versionadded:: 4.2
Specifies whether or not the installer will perform a CRC on itself before
allowing an install.
Allowed values for this variable are ``on``, ``off``, and ``force``.
If not specified, the default behavior is ``on``.

View File

@@ -0,0 +1,6 @@
cpack-nsis-crc-check
--------------------
* The :cpack_gen:`CPack NSIS Generator` gained a new
:variable:`CPACK_NSIS_CRC_CHECK` variable for setting the ``CRCCheck``
attribute.

View File

@@ -43,6 +43,7 @@
@CPACK_NSIS_DEFINES@ @CPACK_NSIS_DEFINES@
@CPACK_NSIS_MANIFEST_DPI_AWARE_CODE@ @CPACK_NSIS_MANIFEST_DPI_AWARE_CODE@
@CPACK_NSIS_BRANDING_TEXT_CODE@ @CPACK_NSIS_BRANDING_TEXT_CODE@
@CPACK_NSIS_CRC_CHECK_CODE@
!include Sections.nsh !include Sections.nsh

View File

@@ -236,6 +236,10 @@ int cmCPackNSISGenerator::PackageFiles()
this->SetOptionIfNotSet("CPACK_NSIS_BRANDING_TEXT_CODE", brandingTextCode); this->SetOptionIfNotSet("CPACK_NSIS_BRANDING_TEXT_CODE", brandingTextCode);
} }
if (cmValue v = this->GetOptionIfSet("CPACK_NSIS_CRC_CHECK")) {
this->SetOption("CPACK_NSIS_CRC_CHECK_CODE", "CRCCheck " + *v);
}
if (!this->IsSet("CPACK_NSIS_IGNORE_LICENSE_PAGE")) { if (!this->IsSet("CPACK_NSIS_IGNORE_LICENSE_PAGE")) {
cmValue v = this->GetOption("CPACK_RESOURCE_FILE_LICENSE"); cmValue v = this->GetOption("CPACK_RESOURCE_FILE_LICENSE");
std::string licenseFile = cmSystemTools::ConvertToWindowsOutputPath(*v); std::string licenseFile = cmSystemTools::ConvertToWindowsOutputPath(*v);

View File

@@ -40,5 +40,6 @@ set(CPACK_NSIS_MANIFEST_DPI_AWARE ON)
set(CPACK_NSIS_BRANDING_TEXT "CMake branding text") set(CPACK_NSIS_BRANDING_TEXT "CMake branding text")
set(CPACK_NSIS_BRANDING_TEXT_TRIM_POSITION "RIGHT") set(CPACK_NSIS_BRANDING_TEXT_TRIM_POSITION "RIGHT")
set(CPACK_NSIS_IGNORE_LICENSE_PAGE ON) set(CPACK_NSIS_IGNORE_LICENSE_PAGE ON)
set(CPACK_NSIS_CRC_CHECK "off")
include(CPack) include(CPack)

View File

@@ -90,3 +90,11 @@ message(STATUS "Found EndsWithDot. component directory name as EndsWithDot._")
if("${output_index}" EQUAL "-1") if("${output_index}" EQUAL "-1")
message(FATAL_ERROR "EndsWithDot. component directory name not found as EndsWithDot._ in the project") message(FATAL_ERROR "EndsWithDot. component directory name not found as EndsWithDot._ in the project")
endif() endif()
file(STRINGS "${project_file}" line REGEX "^CRCCheck off")
string(FIND "${line}" "off" output_index)
if("${output_index}" EQUAL "-1")
message(FATAL_ERROR "CRCCheck off not found in the project")
else()
message(STATUS "Found CRCCheck")
endif()