Need to override ProgramFilesFolder in CPack WiX installer, to use CommonFilesFolder instead
When using CPack to generate a WiX installer, normally the installer puts everything under ProgramFilesFolder (for 32-bit installers) or ProgramFiles64Folder (for 64-bit installers). And, normally this is good :)
I see that there is a new option CPACK_WIX_SKIP_PROGRAM_FOLDER which lets me skip using ProgramFilesFolder or ProgramFiles64Folder. But this isn't quite what I need.
What I need is to allow the installer to put things under CommonFilesFolder (for 32-bit installer) or CommonFiles64Folder (for 64-bit installer). There's no good way to do that, at least as of version 3.7.1.
It seems like adding support for this would be easy. Here's a proposed patch which I believe would accomplish it:
*** cmake-3.7.1/Source/CPack/WiX/cmCPackWIXGenerator.cxx.orig Wed Nov 30 10:14:52 2016
--- cmake-3.7.1/Source/CPack/WiX/cmCPackWIXGenerator.cxx Sat Jan 14 09:20:16 2017
***************
*** 575,585 ****
if (cmSystemTools::IsOn(GetOption("CPACK_WIX_SKIP_PROGRAM_FOLDER"))) {
return "";
}
! if (GetArchitecture() == "x86") {
! return "ProgramFilesFolder";
! } else {
! return "ProgramFiles64Folder";
}
}
bool cmCPackWIXGenerator::GenerateMainSourceFileFromTemplate()
--- 575,603 ----
if (cmSystemTools::IsOn(GetOption("CPACK_WIX_SKIP_PROGRAM_FOLDER"))) {
return "";
}
!
! const char* programFolderSpecifier = GetOption("CPACK_WIX_PROGRAM_FOLDER");
! if (programFolderSpecifier == 0)
! // The default is architecture-specific Program Files folder
! programFolderSpecifier = "ArchProgramFilesFolder";
!
! // Normal case, the folder is architecture-specific
! if (strcmp(programFolderSpecifier, "ArchProgramFilesFolder") == 0) {
! if (GetArchitecture() == "x86") {
! return "ProgramFilesFolder";
! } else {
! return "ProgramFiles64Folder";
! }
! } if (strcmp(programFolderSpecifier, "ArchCommonFilesFolder") == 0) {
! if (GetArchitecture() == "x86") {
! return "CommonFilesFolder";
! } else {
! return "CommonFiles64Folder";
! }
}
+ // Otherwise, assume the folder has been specified directly and is
+ // independent of architecture
+ return programFolderSpecifier;
}
bool cmCPackWIXGenerator::GenerateMainSourceFileFromTemplate()