diff --git a/Help/cpack_gen/nsis.rst b/Help/cpack_gen/nsis.rst index 458ed93890..53b1e9b279 100644 --- a/Help/cpack_gen/nsis.rst +++ b/Help/cpack_gen/nsis.rst @@ -240,3 +240,12 @@ on Windows Nullsoft Scriptable Install System. where ``...`` is constructed from ``CPACK_NSIS_EXECUTABLE_PRE_ARGUMENTS`` and ``...`` 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``. diff --git a/Help/release/dev/cpack-nsis-crc-check.rst b/Help/release/dev/cpack-nsis-crc-check.rst new file mode 100644 index 0000000000..03b5f0a02e --- /dev/null +++ b/Help/release/dev/cpack-nsis-crc-check.rst @@ -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. diff --git a/Modules/Internal/CPack/NSIS.template.in b/Modules/Internal/CPack/NSIS.template.in index c0b61e37e0..cba71bfd63 100644 --- a/Modules/Internal/CPack/NSIS.template.in +++ b/Modules/Internal/CPack/NSIS.template.in @@ -43,6 +43,7 @@ @CPACK_NSIS_DEFINES@ @CPACK_NSIS_MANIFEST_DPI_AWARE_CODE@ @CPACK_NSIS_BRANDING_TEXT_CODE@ +@CPACK_NSIS_CRC_CHECK_CODE@ !include Sections.nsh diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index 31f0737264..85f17866c0 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -236,6 +236,10 @@ int cmCPackNSISGenerator::PackageFiles() 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")) { cmValue v = this->GetOption("CPACK_RESOURCE_FILE_LICENSE"); std::string licenseFile = cmSystemTools::ConvertToWindowsOutputPath(*v); diff --git a/Tests/CPackNSISGenerator/CMakeLists.txt b/Tests/CPackNSISGenerator/CMakeLists.txt index cb0b13d00f..569a478e5e 100644 --- a/Tests/CPackNSISGenerator/CMakeLists.txt +++ b/Tests/CPackNSISGenerator/CMakeLists.txt @@ -40,5 +40,6 @@ 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_CRC_CHECK "off") include(CPack) diff --git a/Tests/CPackNSISGenerator/RunCPackVerifyResult.cmake b/Tests/CPackNSISGenerator/RunCPackVerifyResult.cmake index 3e4d7b4dc2..e811deb433 100644 --- a/Tests/CPackNSISGenerator/RunCPackVerifyResult.cmake +++ b/Tests/CPackNSISGenerator/RunCPackVerifyResult.cmake @@ -90,3 +90,11 @@ message(STATUS "Found EndsWithDot. component directory name as EndsWithDot._") if("${output_index}" EQUAL "-1") message(FATAL_ERROR "EndsWithDot. component directory name not found as EndsWithDot._ in the project") 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()