summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Stürmer <michael.stuermer@schaeffler.com>2016-09-06 10:11:00 (GMT)
committerNils Gladitz <nilsgladitz@gmail.com>2016-09-06 15:44:48 (GMT)
commit1bc33257d48bb4b54333b755951967c6c3fa1df6 (patch)
tree9279d779c344357821f3a5e199e8ca0410cec39d
parent8317ea01aa3cf9319ef907e127fa6dbf9666cc53 (diff)
downloadCMake-1bc33257d48bb4b54333b755951967c6c3fa1df6.zip
CMake-1bc33257d48bb4b54333b755951967c6c3fa1df6.tar.gz
CMake-1bc33257d48bb4b54333b755951967c6c3fa1df6.tar.bz2
CPackWIX: Fix incomplete CPACK_WIX_SKIP_PROGRAM_FOLDER implementation
Commit 17bbf6af (CPackWIX: Implement new CPACK_WIX_SKIP_PROGRAM_FOLDER feature) generates GUIDs for most but not all components when the feature is active. Generate the remaining GUIDs as well. Co-Author: Nils Gladitz <nilsgladitz@gmail.com>
-rw-r--r--Source/CPack/WiX/cmCPackWIXGenerator.cxx39
-rw-r--r--Source/CPack/WiX/cmCPackWIXGenerator.h2
-rw-r--r--Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx4
-rw-r--r--Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h4
-rw-r--r--Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx6
-rw-r--r--Source/CPack/WiX/cmWIXFeaturesSourceWriter.h3
-rw-r--r--Source/CPack/WiX/cmWIXFilesSourceWriter.cxx14
-rw-r--r--Source/CPack/WiX/cmWIXFilesSourceWriter.h5
-rw-r--r--Source/CPack/WiX/cmWIXSourceWriter.cxx21
-rw-r--r--Source/CPack/WiX/cmWIXSourceWriter.h19
10 files changed, 79 insertions, 38 deletions
diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx
index d7f69a1..85e0ae3 100644
--- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx
+++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx
@@ -35,6 +35,7 @@
cmCPackWIXGenerator::cmCPackWIXGenerator()
: Patch(0)
+ , ComponentGuidType(cmWIXSourceWriter::WIX_GENERATED_GUID)
{
}
@@ -234,6 +235,12 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration()
}
}
+ // if install folder is supposed to be set absolutely, the default
+ // component guid "*" cannot be used
+ if (cmSystemTools::IsOn(GetOption("CPACK_WIX_SKIP_PROGRAM_FOLDER"))) {
+ this->ComponentGuidType = cmWIXSourceWriter::CMAKE_GENERATED_GUID;
+ }
+
return true;
}
@@ -317,7 +324,9 @@ void cmCPackWIXGenerator::CreateWiXVariablesIncludeFile()
{
std::string includeFilename = this->CPackTopLevel + "/cpack_variables.wxi";
- cmWIXSourceWriter includeFile(this->Logger, includeFilename, true);
+ cmWIXSourceWriter includeFile(this->Logger, includeFilename,
+ this->ComponentGuidType,
+ cmWIXSourceWriter::INCLUDE_ELEMENT_ROOT);
CopyDefinition(includeFile, "CPACK_WIX_PRODUCT_GUID");
CopyDefinition(includeFile, "CPACK_WIX_UPGRADE_GUID");
@@ -338,7 +347,9 @@ void cmCPackWIXGenerator::CreateWiXPropertiesIncludeFile()
{
std::string includeFilename = this->CPackTopLevel + "/properties.wxi";
- cmWIXSourceWriter includeFile(this->Logger, includeFilename, true);
+ cmWIXSourceWriter includeFile(this->Logger, includeFilename,
+ this->ComponentGuidType,
+ cmWIXSourceWriter::INCLUDE_ELEMENT_ROOT);
std::string prefix = "CPACK_WIX_PROPERTY_";
std::vector<std::string> options = GetOptions();
@@ -386,7 +397,9 @@ void cmCPackWIXGenerator::CreateWiXProductFragmentIncludeFile()
{
std::string includeFilename = this->CPackTopLevel + "/product_fragment.wxi";
- cmWIXSourceWriter includeFile(this->Logger, includeFilename, true);
+ cmWIXSourceWriter includeFile(this->Logger, includeFilename,
+ this->ComponentGuidType,
+ cmWIXSourceWriter::INCLUDE_ELEMENT_ROOT);
this->Patch->ApplyFragment("#PRODUCT", includeFile);
}
@@ -413,13 +426,15 @@ void cmCPackWIXGenerator::AddDefinition(cmWIXSourceWriter& source,
bool cmCPackWIXGenerator::CreateWiXSourceFiles()
{
+ // if install folder is supposed to be set absolutely, the default
+ // component guid "*" cannot be used
std::string directoryDefinitionsFilename =
this->CPackTopLevel + "/directories.wxs";
this->WixSources.push_back(directoryDefinitionsFilename);
cmWIXDirectoriesSourceWriter directoryDefinitions(
- this->Logger, directoryDefinitionsFilename);
+ this->Logger, directoryDefinitionsFilename, this->ComponentGuidType);
directoryDefinitions.BeginElement("Fragment");
std::string installRoot;
@@ -439,13 +454,8 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
this->WixSources.push_back(fileDefinitionsFilename);
- 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"));
+ cmWIXFilesSourceWriter fileDefinitions(this->Logger, fileDefinitionsFilename,
+ this->ComponentGuidType);
fileDefinitions.BeginElement("Fragment");
@@ -454,8 +464,8 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
this->WixSources.push_back(featureDefinitionsFilename);
- cmWIXFeaturesSourceWriter featureDefinitions(this->Logger,
- featureDefinitionsFilename);
+ cmWIXFeaturesSourceWriter featureDefinitions(
+ this->Logger, featureDefinitionsFilename, this->ComponentGuidType);
featureDefinitions.BeginElement("Fragment");
@@ -764,7 +774,8 @@ bool cmCPackWIXGenerator::CreateShortcutsOfSpecificType(
fileDefinitions.BeginElement("Component");
fileDefinitions.AddAttribute("Id", componentId);
- fileDefinitions.AddAttribute("Guid", "*");
+ fileDefinitions.AddAttribute(
+ "Guid", fileDefinitions.CreateGuidFromComponentId(componentId));
this->Patch->ApplyFragment(componentId, fileDefinitions);
diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.h b/Source/CPack/WiX/cmCPackWIXGenerator.h
index 9d3a522..883df9a 100644
--- a/Source/CPack/WiX/cmCPackWIXGenerator.h
+++ b/Source/CPack/WiX/cmCPackWIXGenerator.h
@@ -162,6 +162,8 @@ private:
std::string CPackTopLevel;
cmWIXPatch* Patch;
+
+ cmWIXSourceWriter::GuidType ComponentGuidType;
};
#endif
diff --git a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx
index 97e3a51..9704195 100644
--- a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx
+++ b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx
@@ -13,8 +13,8 @@
#include "cmWIXDirectoriesSourceWriter.h"
cmWIXDirectoriesSourceWriter::cmWIXDirectoriesSourceWriter(
- cmCPackLog* logger, std::string const& filename)
- : cmWIXSourceWriter(logger, filename)
+ cmCPackLog* logger, std::string const& filename, GuidType componentGuidType)
+ : cmWIXSourceWriter(logger, filename, componentGuidType)
{
}
diff --git a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h
index 023f4b8..6ebe281 100644
--- a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h
+++ b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h
@@ -25,8 +25,8 @@
class cmWIXDirectoriesSourceWriter : public cmWIXSourceWriter
{
public:
- cmWIXDirectoriesSourceWriter(cmCPackLog* logger,
- std::string const& filename);
+ cmWIXDirectoriesSourceWriter(cmCPackLog* logger, std::string const& filename,
+ GuidType componentGuidType);
void EmitStartMenuFolder(std::string const& startMenuFolder);
diff --git a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx
index 1747b62..7794935 100644
--- a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx
+++ b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx
@@ -13,8 +13,8 @@
#include "cmWIXFeaturesSourceWriter.h"
cmWIXFeaturesSourceWriter::cmWIXFeaturesSourceWriter(
- cmCPackLog* logger, std::string const& filename)
- : cmWIXSourceWriter(logger, filename)
+ cmCPackLog* logger, std::string const& filename, GuidType componentGuidType)
+ : cmWIXSourceWriter(logger, filename, componentGuidType)
{
}
@@ -24,7 +24,7 @@ void cmWIXFeaturesSourceWriter::CreateCMakePackageRegistryEntry(
BeginElement("Component");
AddAttribute("Id", "CM_PACKAGE_REGISTRY");
AddAttribute("Directory", "TARGETDIR");
- AddAttribute("Guid", "*");
+ AddAttribute("Guid", CreateGuidFromComponentId("CM_PACKAGE_REGISTRY"));
std::string registryKey =
std::string("Software\\Kitware\\CMake\\Packages\\") + package;
diff --git a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.h b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.h
index ee9c17a..9974b63 100644
--- a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.h
+++ b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.h
@@ -23,7 +23,8 @@
class cmWIXFeaturesSourceWriter : public cmWIXSourceWriter
{
public:
- cmWIXFeaturesSourceWriter(cmCPackLog* logger, std::string const& filename);
+ cmWIXFeaturesSourceWriter(cmCPackLog* logger, std::string const& filename,
+ GuidType componentGuidType);
void CreateCMakePackageRegistryEntry(std::string const& package,
std::string const& upgradeGuid);
diff --git a/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx
index dde9635..846edde 100644
--- a/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx
+++ b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx
@@ -24,9 +24,9 @@
#include <sys/stat.h>
cmWIXFilesSourceWriter::cmWIXFilesSourceWriter(cmCPackLog* logger,
- std::string const& filename)
- : cmWIXSourceWriter(logger, filename)
- , GenerateComponentGuids(false)
+ std::string const& filename,
+ GuidType componentGuidType)
+ : cmWIXSourceWriter(logger, filename, componentGuidType)
{
}
@@ -130,13 +130,7 @@ 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);
- }
+ std::string guid = CreateGuidFromComponentId(componentId);
BeginElement("DirectoryRef");
AddAttribute("Id", directoryId);
diff --git a/Source/CPack/WiX/cmWIXFilesSourceWriter.h b/Source/CPack/WiX/cmWIXFilesSourceWriter.h
index eeb84cb..c1952af 100644
--- a/Source/CPack/WiX/cmWIXFilesSourceWriter.h
+++ b/Source/CPack/WiX/cmWIXFilesSourceWriter.h
@@ -26,7 +26,8 @@
class cmWIXFilesSourceWriter : public cmWIXSourceWriter
{
public:
- cmWIXFilesSourceWriter(cmCPackLog* logger, std::string const& filename);
+ cmWIXFilesSourceWriter(cmCPackLog* logger, std::string const& filename,
+ GuidType componentGuidType);
void EmitShortcut(std::string const& id, cmWIXShortcut const& shortcut,
std::string const& shortcutPrefix, size_t shortcutIndex);
@@ -47,8 +48,6 @@ public:
std::string const& id,
std::string const& filePath, cmWIXPatch& patch,
cmInstalledFile const* installedFile);
-
- bool GenerateComponentGuids;
};
#endif
diff --git a/Source/CPack/WiX/cmWIXSourceWriter.cxx b/Source/CPack/WiX/cmWIXSourceWriter.cxx
index 2c0384e..a287424 100644
--- a/Source/CPack/WiX/cmWIXSourceWriter.cxx
+++ b/Source/CPack/WiX/cmWIXSourceWriter.cxx
@@ -14,19 +14,23 @@
#include <CPack/cmCPackGenerator.h>
+#include <cmUuid.h>
+
#include <windows.h>
cmWIXSourceWriter::cmWIXSourceWriter(cmCPackLog* logger,
std::string const& filename,
- bool isIncludeFile)
+ GuidType componentGuidType,
+ RootElementType rootElementType)
: Logger(logger)
, File(filename.c_str())
, State(DEFAULT)
, SourceFilename(filename)
+ , ComponentGuidType(componentGuidType)
{
WriteXMLDeclaration();
- if (isIncludeFile) {
+ if (rootElementType == INCLUDE_ELEMENT_ROOT) {
BeginElement("Include");
} else {
BeginElement("Wix");
@@ -173,6 +177,19 @@ std::string cmWIXSourceWriter::CMakeEncodingToUtf8(std::string const& value)
#endif
}
+std::string cmWIXSourceWriter::CreateGuidFromComponentId(
+ std::string const& componentId)
+{
+ std::string guid = "*";
+ if (this->ComponentGuidType == CMAKE_GENERATED_GUID) {
+ std::string md5 = cmSystemTools::ComputeStringMD5(componentId);
+ cmUuid uuid;
+ std::vector<unsigned char> ns;
+ guid = uuid.FromMd5(ns, md5);
+ }
+ return guid;
+}
+
void cmWIXSourceWriter::WriteXMLDeclaration()
{
File << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl;
diff --git a/Source/CPack/WiX/cmWIXSourceWriter.h b/Source/CPack/WiX/cmWIXSourceWriter.h
index 4efc026..c29ffa7 100644
--- a/Source/CPack/WiX/cmWIXSourceWriter.h
+++ b/Source/CPack/WiX/cmWIXSourceWriter.h
@@ -26,8 +26,21 @@
class cmWIXSourceWriter
{
public:
+ enum GuidType
+ {
+ WIX_GENERATED_GUID,
+ CMAKE_GENERATED_GUID
+ };
+
+ enum RootElementType
+ {
+ WIX_ELEMENT_ROOT,
+ INCLUDE_ELEMENT_ROOT
+ };
+
cmWIXSourceWriter(cmCPackLog* logger, std::string const& filename,
- bool isIncludeFile = false);
+ GuidType componentGuidType,
+ RootElementType rootElementType = WIX_ELEMENT_ROOT);
~cmWIXSourceWriter();
@@ -45,6 +58,8 @@ public:
void AddAttributeUnlessEmpty(std::string const& key,
std::string const& value);
+ std::string CreateGuidFromComponentId(std::string const& componentId);
+
static std::string CMakeEncodingToUtf8(std::string const& value);
protected:
@@ -70,6 +85,8 @@ private:
std::vector<std::string> Elements;
std::string SourceFilename;
+
+ GuidType ComponentGuidType;
};
#endif