CPack/WiX: Encode long paths with UNC prefix

Closes: #27049
This commit is contained in:
Noki
2025-07-04 16:44:13 +02:00
committed by Brad King
parent be4ec6a11e
commit f0f1d6e147

View File

@@ -15,6 +15,10 @@
#include "cmUuid.h"
#include "cmWIXAccessControlList.h"
#ifdef _WIN32
# include "cmsys/Encoding.hxx"
#endif
cmWIXFilesSourceWriter::cmWIXFilesSourceWriter(unsigned long wixVersion,
cmCPackLog* logger,
std::string const& filename,
@@ -144,7 +148,18 @@ std::string cmWIXFilesSourceWriter::EmitComponentFile(
patch.ApplyFragment(componentId, *this);
BeginElement("File");
AddAttribute("Id", fileId);
AddAttribute("Source", CMakeToWixPath(filePath));
std::string sourcePath = CMakeToWixPath(filePath);
#ifdef _WIN32
// WiX cannot handle long paths natively, but since v4,
// it supports long paths via UNC prefixes.
if (this->WixVersion >= 4) {
sourcePath = cmsys::Encoding::ToNarrow(
cmsys::Encoding::ToWindowsExtendedPath(sourcePath));
}
#endif
AddAttribute("Source", sourcePath);
AddAttribute("KeyPath", "yes");
mode_t fileMode = 0;