2014-02-25 02:21:12 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2014 Kitware, Inc.
|
|
|
|
|
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
|
|
|
|
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
|
|
|
|
|
|
|
#include "cmWIXFeaturesSourceWriter.h"
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmWIXFeaturesSourceWriter::cmWIXFeaturesSourceWriter(
|
2016-09-06 13:11:00 +03:00
|
|
|
cmCPackLog* logger, std::string const& filename, GuidType componentGuidType)
|
|
|
|
: cmWIXSourceWriter(logger, filename, componentGuidType)
|
2014-02-25 02:21:12 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmWIXFeaturesSourceWriter::CreateCMakePackageRegistryEntry(
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string const& package, std::string const& upgradeGuid)
|
2014-02-25 02:21:12 +04:00
|
|
|
{
|
|
|
|
BeginElement("Component");
|
|
|
|
AddAttribute("Id", "CM_PACKAGE_REGISTRY");
|
|
|
|
AddAttribute("Directory", "TARGETDIR");
|
2016-09-06 13:11:00 +03:00
|
|
|
AddAttribute("Guid", CreateGuidFromComponentId("CM_PACKAGE_REGISTRY"));
|
2014-02-25 02:21:12 +04:00
|
|
|
|
|
|
|
std::string registryKey =
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string("Software\\Kitware\\CMake\\Packages\\") + package;
|
2014-02-25 02:21:12 +04:00
|
|
|
|
|
|
|
BeginElement("RegistryValue");
|
|
|
|
AddAttribute("Root", "HKLM");
|
|
|
|
AddAttribute("Key", registryKey);
|
|
|
|
AddAttribute("Name", upgradeGuid);
|
|
|
|
AddAttribute("Type", "string");
|
|
|
|
AddAttribute("Value", "[INSTALL_ROOT]");
|
|
|
|
AddAttribute("KeyPath", "yes");
|
|
|
|
EndElement("RegistryValue");
|
|
|
|
|
|
|
|
EndElement("Component");
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmWIXFeaturesSourceWriter::EmitFeatureForComponentGroup(
|
2016-09-09 11:53:26 +03:00
|
|
|
cmCPackComponentGroup const& group, cmWIXPatch& patch)
|
2014-02-25 02:21:12 +04:00
|
|
|
{
|
|
|
|
BeginElement("Feature");
|
|
|
|
AddAttribute("Id", "CM_G_" + group.Name);
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (group.IsExpandedByDefault) {
|
2014-02-25 02:21:12 +04:00
|
|
|
AddAttribute("Display", "expand");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-02-25 02:21:12 +04:00
|
|
|
|
|
|
|
AddAttributeUnlessEmpty("Title", group.DisplayName);
|
|
|
|
AddAttributeUnlessEmpty("Description", group.Description);
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmCPackComponentGroup*>::const_iterator i =
|
|
|
|
group.Subgroups.begin();
|
|
|
|
i != group.Subgroups.end(); ++i) {
|
2016-09-09 11:53:26 +03:00
|
|
|
EmitFeatureForComponentGroup(**i, patch);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-02-25 02:21:12 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmCPackComponent*>::const_iterator i =
|
|
|
|
group.Components.begin();
|
|
|
|
i != group.Components.end(); ++i) {
|
2016-09-09 11:53:26 +03:00
|
|
|
EmitFeatureForComponent(**i, patch);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-02-25 02:21:12 +04:00
|
|
|
|
2016-09-09 11:53:26 +03:00
|
|
|
patch.ApplyFragment("CM_G_" + group.Name, *this);
|
|
|
|
|
2014-02-25 02:21:12 +04:00
|
|
|
EndElement("Feature");
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmWIXFeaturesSourceWriter::EmitFeatureForComponent(
|
2016-09-09 11:53:26 +03:00
|
|
|
cmCPackComponent const& component, cmWIXPatch& patch)
|
2014-02-25 02:21:12 +04:00
|
|
|
{
|
|
|
|
BeginElement("Feature");
|
|
|
|
AddAttribute("Id", "CM_C_" + component.Name);
|
|
|
|
|
|
|
|
AddAttributeUnlessEmpty("Title", component.DisplayName);
|
|
|
|
AddAttributeUnlessEmpty("Description", component.Description);
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (component.IsRequired) {
|
2014-02-25 02:21:12 +04:00
|
|
|
AddAttribute("Absent", "disallow");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-02-25 02:21:12 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (component.IsHidden) {
|
2014-02-25 02:21:12 +04:00
|
|
|
AddAttribute("Display", "hidden");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-02-25 02:21:12 +04:00
|
|
|
|
2016-07-21 17:34:35 +03:00
|
|
|
if (component.IsDisabledByDefault) {
|
|
|
|
AddAttribute("Level", "2");
|
|
|
|
}
|
|
|
|
|
2016-09-09 11:53:26 +03:00
|
|
|
patch.ApplyFragment("CM_C_" + component.Name, *this);
|
|
|
|
|
2014-02-25 02:21:12 +04:00
|
|
|
EndElement("Feature");
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmWIXFeaturesSourceWriter::EmitComponentRef(std::string const& id)
|
|
|
|
{
|
|
|
|
BeginElement("ComponentRef");
|
|
|
|
AddAttribute("Id", id);
|
|
|
|
EndElement("ComponentRef");
|
|
|
|
}
|