Просмотр исходного кода

CPack/NSIS: Add option for setting DPI-aware

See https://nsis.sourceforge.io/Reference/ManifestDPIAware
for more information.

Fixes: #17724
Johnny Jazeix 5 лет назад
Родитель
Сommit
d6840a4f3c

+ 4 - 0
Help/cpack_gen/nsis.rst

@@ -155,3 +155,7 @@ on Windows Nullsoft Scriptable Install System.
 .. variable:: CPACK_NSIS_MUI_HEADERIMAGE
 
  The image to display on the header of installers pages.
+
+.. variable:: CPACK_NSIS_MANIFEST_DPI_AWARE
+
+ If set, declares that the installer is DPI-aware.

+ 6 - 0
Help/release/dev/nsis-dpi-aware.rst

@@ -0,0 +1,6 @@
+nsis-dpi-aware
+--------------
+
+* The :cpack_gen:`CPack NSIS Generator` gained a new variable
+  :variable:`CPACK_NSIS_MANIFEST_DPI_AWARE` to declare that the
+  installer is DPI-aware.

+ 1 - 0
Modules/Internal/CPack/NSIS.template.in

@@ -41,6 +41,7 @@
   RequestExecutionLevel admin
 
 @CPACK_NSIS_DEFINES@
+@CPACK_NSIS_MANIFEST_DPI_AWARE_CODE@
 
   !include Sections.nsh
 

+ 5 - 0
Source/CPack/cmCPackNSISGenerator.cxx

@@ -203,6 +203,11 @@ int cmCPackNSISGenerator::PackageFiles()
                             "!define MUI_FINISHPAGE_TITLE_3LINES");
   }
 
+  if (this->IsSet("CPACK_NSIS_MANIFEST_DPI_AWARE")) {
+    this->SetOptionIfNotSet("CPACK_NSIS_MANIFEST_DPI_AWARE_CODE",
+                            "ManifestDPIAware true");
+  }
+
   // Setup all of the component sections
   if (this->Components.empty()) {
     this->SetOptionIfNotSet("CPACK_NSIS_INSTALLATION_TYPES", "");

+ 1 - 0
Tests/CPackNSISGenerator/CMakeLists.txt

@@ -16,5 +16,6 @@ set(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}\\\\install.ico")
 set(CPACK_NSIS_MUI_UNIICON "${PROJECT_SOURCE_DIR}\\\\uninstall.ico")
 set(CPACK_GENERATOR "NSIS")
 set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
+set(CPACK_NSIS_MANIFEST_DPI_AWARE ON)
 
 include(CPack)

+ 8 - 0
Tests/CPackNSISGenerator/RunCPackVerifyResult.cmake

@@ -44,3 +44,11 @@ message(STATUS "Found the bitmap at index ${output_index}")
 if("${output_index}" EQUAL "-1")
   message(FATAL_ERROR "MUI_HEADERIMAGE_BITMAP not found in the project")
 endif()
+
+file(STRINGS "${project_file}" line REGEX "^ManifestDPIAware true")
+string(FIND "${line}" "true" output_index)
+if("${output_index}" EQUAL "-1")
+  message(FATAL_ERROR "ManifestDPIAware true not found in the project")
+else()
+  message(STATUS "Found DPI-aware")
+endif()