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>
This commit is contained in:
parent
8317ea01aa
commit
1bc33257d4
|
@ -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);
|
||||
|
||||
|
|
|
@ -162,6 +162,8 @@ private:
|
|||
std::string CPackTopLevel;
|
||||
|
||||
cmWIXPatch* Patch;
|
||||
|
||||
cmWIXSourceWriter::GuidType ComponentGuidType;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue