فهرست منبع

CPack/NSIS: Allow setting CRCCheck

Fixes: #27260
Daniel Pfeifer 3 هفته پیش
والد
کامیت
3c7fee0d99

+ 9 - 0
Help/cpack_gen/nsis.rst

@@ -240,3 +240,12 @@ on Windows Nullsoft Scriptable Install System.
 
  where ``<preArgs>...`` is constructed from ``CPACK_NSIS_EXECUTABLE_PRE_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``.

+ 6 - 0
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.

+ 1 - 0
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
 

+ 4 - 0
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);

+ 1 - 0
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)

+ 8 - 0
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()