From d1f00444d1f3475eddc19931895caf6092f6a594 Mon Sep 17 00:00:00 2001 From: Nikita Nemkin Date: Fri, 14 Feb 2025 18:01:01 +0500 Subject: CPack/NSIS: Avoid UNIX-style paths in macro variables NSIS macro variables MUI_*_BITMAP require Windows-style paths. Don't rely on the user and convert them explicitly. For good measure, also convert the paths for MUI_PAGE_LICENSE, MUI_ICON and MUI_UNIICON. Note that NSIS scripts only require quotes for strings with spaces and ConvertToWindowsOutputPath() handles this automatically. Fixes: #9945 --- Source/CPack/cmCPackNSISGenerator.cxx | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index 9c0398c..4196bfc 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -130,11 +130,13 @@ int cmCPackNSISGenerator::PackageFiles() if (this->IsSet("CPACK_NSIS_MUI_ICON") || this->IsSet("CPACK_NSIS_MUI_UNIICON")) { std::string installerIconCode; - if (cmValue icon = this->GetOptionIfSet("CPACK_NSIS_MUI_ICON")) { - installerIconCode += cmStrCat("!define MUI_ICON \"", *icon, "\"\n"); + if (cmValue v = this->GetOptionIfSet("CPACK_NSIS_MUI_ICON")) { + std::string iconFile = cmSystemTools::ConvertToWindowsOutputPath(*v); + installerIconCode += cmStrCat("!define MUI_ICON ", iconFile, "\n"); } - if (cmValue icon = this->GetOptionIfSet("CPACK_NSIS_MUI_UNIICON")) { - installerIconCode += cmStrCat("!define MUI_UNICON \"", *icon, "\"\n"); + if (cmValue v = this->GetOptionIfSet("CPACK_NSIS_MUI_UNIICON")) { + std::string iconFile = cmSystemTools::ConvertToWindowsOutputPath(*v); + installerIconCode += cmStrCat("!define MUI_UNICON ", iconFile, "\n"); } this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_MUI_ICON_CODE", installerIconCode.c_str()); @@ -146,24 +148,28 @@ int cmCPackNSISGenerator::PackageFiles() installerHeaderImage = *icon; } if (!installerHeaderImage.empty()) { - std::string installerIconCode = cmStrCat( - "!define MUI_HEADERIMAGE_BITMAP \"", installerHeaderImage, "\"\n"); + installerHeaderImage = + cmSystemTools::ConvertToWindowsOutputPath(installerHeaderImage); + std::string installerIconCode = + cmStrCat("!define MUI_HEADERIMAGE_BITMAP ", installerHeaderImage, "\n"); this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_ICON_CODE", installerIconCode); } if (cmValue v = this->GetOptionIfSet("CPACK_NSIS_MUI_WELCOMEFINISHPAGE_BITMAP")) { + std::string bitmapFile = cmSystemTools::ConvertToWindowsOutputPath(*v); std::string installerBitmapCode = - cmStrCat("!define MUI_WELCOMEFINISHPAGE_BITMAP \"", *v, "\"\n"); + cmStrCat("!define MUI_WELCOMEFINISHPAGE_BITMAP ", bitmapFile, "\n"); this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_MUI_WELCOMEFINISH_CODE", installerBitmapCode); } if (cmValue v = this->GetOptionIfSet("CPACK_NSIS_MUI_UNWELCOMEFINISHPAGE_BITMAP")) { + std::string bitmapFile = cmSystemTools::ConvertToWindowsOutputPath(*v); std::string installerBitmapCode = - cmStrCat("!define MUI_UNWELCOMEFINISHPAGE_BITMAP \"", *v, "\"\n"); + cmStrCat("!define MUI_UNWELCOMEFINISHPAGE_BITMAP ", bitmapFile, "\n"); this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_MUI_UNWELCOMEFINISH_CODE", installerBitmapCode); } @@ -231,9 +237,10 @@ int cmCPackNSISGenerator::PackageFiles() } if (!this->IsSet("CPACK_NSIS_IGNORE_LICENSE_PAGE")) { + cmValue v = this->GetOption("CPACK_RESOURCE_FILE_LICENSE"); + std::string licenseFile = cmSystemTools::ConvertToWindowsOutputPath(*v); std::string licenseCode = - cmStrCat("!insertmacro MUI_PAGE_LICENSE \"", - this->GetOption("CPACK_RESOURCE_FILE_LICENSE"), "\"\n"); + cmStrCat("!insertmacro MUI_PAGE_LICENSE ", licenseFile, "\n"); this->SetOptionIfNotSet("CPACK_NSIS_LICENSE_PAGE", licenseCode); } -- cgit v0.12