cmake/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx

92 lines
2.5 KiB
C++
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
2015-04-27 22:25:09 +02:00
#include "cmWIXFeaturesSourceWriter.h"
2016-07-09 11:21:54 +02:00
cmWIXFeaturesSourceWriter::cmWIXFeaturesSourceWriter(
2016-10-30 18:24:19 +01:00
cmCPackLog* logger, std::string const& filename, GuidType componentGuidType)
: cmWIXSourceWriter(logger, filename, componentGuidType)
2015-04-27 22:25:09 +02:00
{
}
void cmWIXFeaturesSourceWriter::CreateCMakePackageRegistryEntry(
2016-07-09 11:21:54 +02:00
std::string const& package, std::string const& upgradeGuid)
2015-04-27 22:25:09 +02:00
{
BeginElement("Component");
AddAttribute("Id", "CM_PACKAGE_REGISTRY");
AddAttribute("Directory", "TARGETDIR");
2016-10-30 18:24:19 +01:00
AddAttribute("Guid", CreateGuidFromComponentId("CM_PACKAGE_REGISTRY"));
2015-04-27 22:25:09 +02:00
std::string registryKey =
2016-07-09 11:21:54 +02:00
std::string("Software\\Kitware\\CMake\\Packages\\") + package;
2015-04-27 22:25:09 +02: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-10-30 18:24:19 +01:00
cmCPackComponentGroup const& group, cmWIXPatch& patch)
2015-04-27 22:25:09 +02:00
{
BeginElement("Feature");
AddAttribute("Id", "CM_G_" + group.Name);
2016-07-09 11:21:54 +02:00
if (group.IsExpandedByDefault) {
2015-04-27 22:25:09 +02:00
AddAttribute("Display", "expand");
2016-07-09 11:21:54 +02:00
}
2015-04-27 22:25:09 +02:00
AddAttributeUnlessEmpty("Title", group.DisplayName);
AddAttributeUnlessEmpty("Description", group.Description);
2017-07-20 19:35:53 +02:00
patch.ApplyFragment("CM_G_" + group.Name, *this);
2018-01-26 17:06:56 +01:00
for (cmCPackComponentGroup* subgroup : group.Subgroups) {
EmitFeatureForComponentGroup(*subgroup, patch);
2016-07-09 11:21:54 +02:00
}
2015-04-27 22:25:09 +02:00
2018-01-26 17:06:56 +01:00
for (cmCPackComponent* component : group.Components) {
EmitFeatureForComponent(*component, patch);
2016-07-09 11:21:54 +02:00
}
2015-04-27 22:25:09 +02:00
EndElement("Feature");
}
void cmWIXFeaturesSourceWriter::EmitFeatureForComponent(
2016-10-30 18:24:19 +01:00
cmCPackComponent const& component, cmWIXPatch& patch)
2015-04-27 22:25:09 +02:00
{
BeginElement("Feature");
AddAttribute("Id", "CM_C_" + component.Name);
AddAttributeUnlessEmpty("Title", component.DisplayName);
AddAttributeUnlessEmpty("Description", component.Description);
2016-07-09 11:21:54 +02:00
if (component.IsRequired) {
2015-04-27 22:25:09 +02:00
AddAttribute("Absent", "disallow");
2016-07-09 11:21:54 +02:00
}
2015-04-27 22:25:09 +02:00
2016-07-09 11:21:54 +02:00
if (component.IsHidden) {
2015-04-27 22:25:09 +02:00
AddAttribute("Display", "hidden");
2016-07-09 11:21:54 +02:00
}
2015-04-27 22:25:09 +02:00
2016-10-30 18:24:19 +01:00
if (component.IsDisabledByDefault) {
AddAttribute("Level", "2");
}
patch.ApplyFragment("CM_C_" + component.Name, *this);
2015-04-27 22:25:09 +02:00
EndElement("Feature");
}
void cmWIXFeaturesSourceWriter::EmitComponentRef(std::string const& id)
{
BeginElement("ComponentRef");
AddAttribute("Id", id);
EndElement("ComponentRef");
}