CPack/NSIS: Add option for setting DPI-aware

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

Fixes: #17724
This commit is contained in:
Johnny Jazeix
2020-04-14 13:47:49 +02:00
parent fab932c3cb
commit d6840a4f3c
6 changed files with 25 additions and 0 deletions

View File

@@ -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.

View File

@@ -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.

View File

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

View File

@@ -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", "");

View File

@@ -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)

View File

@@ -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()