summaryrefslogtreecommitdiffstats
path: root/Source/CPack
diff options
context:
space:
mode:
authorMichael Stürmer <michael.stuermer@schaeffler.com>2016-07-20 13:32:38 (GMT)
committerNils Gladitz <nilsgladitz@gmail.com>2016-08-08 11:42:23 (GMT)
commit17bbf6af1ecca15194a693d31fdd8163aacfd994 (patch)
treec962a911d846f2cf6bf738315f80a9ba96ee22c5 /Source/CPack
parent5a62e0c1721281503c8b4cd9d4d3d0de8abebf0f (diff)
downloadCMake-17bbf6af1ecca15194a693d31fdd8163aacfd994.zip
CMake-17bbf6af1ecca15194a693d31fdd8163aacfd994.tar.gz
CMake-17bbf6af1ecca15194a693d31fdd8163aacfd994.tar.bz2
CPackWIX: Implement new CPACK_WIX_SKIP_PROGRAM_FOLDER feature
The new variable allows setting of a custom absolute installation prefix outside of the ProgramFiles folders.
Diffstat (limited to 'Source/CPack')
-rw-r--r--Source/CPack/WiX/cmCPackWIXGenerator.cxx9
-rw-r--r--Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx10
-rw-r--r--Source/CPack/WiX/cmWIXFilesSourceWriter.cxx14
-rw-r--r--Source/CPack/WiX/cmWIXFilesSourceWriter.h2
4 files changed, 31 insertions, 4 deletions
diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx
index 3ecc14d..d7f69a1 100644
--- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx
+++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx
@@ -18,6 +18,7 @@
#include <cmGeneratedFileStream.h>
#include <cmInstalledFile.h>
#include <cmSystemTools.h>
+#include <cmUuid.h>
#include "cmWIXDirectoriesSourceWriter.h"
#include "cmWIXFeaturesSourceWriter.h"
@@ -441,6 +442,11 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
cmWIXFilesSourceWriter fileDefinitions(this->Logger,
fileDefinitionsFilename);
+ // if install folder is supposed to be set absolutely, the default
+ // component guid "*" cannot be used
+ fileDefinitions.GenerateComponentGuids =
+ cmSystemTools::IsOn(GetOption("CPACK_WIX_SKIP_PROGRAM_FOLDER"));
+
fileDefinitions.BeginElement("Fragment");
std::string featureDefinitionsFilename =
@@ -566,6 +572,9 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
std::string cmCPackWIXGenerator::GetProgramFilesFolderId() const
{
+ if (cmSystemTools::IsOn(GetOption("CPACK_WIX_SKIP_PROGRAM_FOLDER"))) {
+ return "";
+ }
if (GetArchitecture() == "x86") {
return "ProgramFilesFolder";
} else {
diff --git a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx
index de64059..97e3a51 100644
--- a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx
+++ b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx
@@ -52,8 +52,12 @@ size_t cmWIXDirectoriesSourceWriter::BeginInstallationPrefixDirectory(
std::string const& programFilesFolderId,
std::string const& installRootString)
{
- BeginElement("Directory");
- AddAttribute("Id", programFilesFolderId);
+ size_t offset = 1;
+ if (!programFilesFolderId.empty()) {
+ BeginElement("Directory");
+ AddAttribute("Id", programFilesFolderId);
+ offset = 0;
+ }
std::vector<std::string> installRoot;
@@ -77,7 +81,7 @@ size_t cmWIXDirectoriesSourceWriter::BeginInstallationPrefixDirectory(
AddAttribute("Name", installRoot[i]);
}
- return installRoot.size();
+ return installRoot.size() - offset;
}
void cmWIXDirectoriesSourceWriter::EndInstallationPrefixDirectory(size_t size)
diff --git a/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx
index 9a143cc..dde9635 100644
--- a/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx
+++ b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx
@@ -16,6 +16,9 @@
#include <cmInstalledFile.h>
+#include <cmSystemTools.h>
+#include <cmUuid.h>
+
#include <sys/types.h>
// include sys/stat.h after sys/types.h
#include <sys/stat.h>
@@ -23,6 +26,7 @@
cmWIXFilesSourceWriter::cmWIXFilesSourceWriter(cmCPackLog* logger,
std::string const& filename)
: cmWIXSourceWriter(logger, filename)
+ , GenerateComponentGuids(false)
{
}
@@ -126,12 +130,20 @@ std::string cmWIXFilesSourceWriter::EmitComponentFile(
std::string componentId = std::string("CM_C") + id;
std::string fileId = std::string("CM_F") + id;
+ std::string guid = "*";
+ if (this->GenerateComponentGuids) {
+ std::string md5 = cmSystemTools::ComputeStringMD5(componentId);
+ cmUuid uuid;
+ std::vector<unsigned char> ns;
+ guid = uuid.FromMd5(ns, md5);
+ }
+
BeginElement("DirectoryRef");
AddAttribute("Id", directoryId);
BeginElement("Component");
AddAttribute("Id", componentId);
- AddAttribute("Guid", "*");
+ AddAttribute("Guid", guid);
if (installedFile) {
if (installedFile->GetPropertyAsBool("CPACK_NEVER_OVERWRITE")) {
diff --git a/Source/CPack/WiX/cmWIXFilesSourceWriter.h b/Source/CPack/WiX/cmWIXFilesSourceWriter.h
index c577e5b..eeb84cb 100644
--- a/Source/CPack/WiX/cmWIXFilesSourceWriter.h
+++ b/Source/CPack/WiX/cmWIXFilesSourceWriter.h
@@ -47,6 +47,8 @@ public:
std::string const& id,
std::string const& filePath, cmWIXPatch& patch,
cmInstalledFile const* installedFile);
+
+ bool GenerateComponentGuids;
};
#endif