Merge topic 'cpack-wix-long-paths'

f0f1d6e147 CPack/WiX: Encode long paths with UNC prefix

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10929
This commit is contained in:
Brad King
2025-07-14 13:31:04 +00:00
committed by Kitware Robot

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;