cmake/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx

99 lines
2.7 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"
2023-12-07 09:12:54 +01:00
#include "cmStringAlgorithms.h"
2016-07-09 11:21:54 +02:00
cmWIXFeaturesSourceWriter::cmWIXFeaturesSourceWriter(
2024-07-09 14:46:46 +02:00
unsigned long wixVersion, cmCPackLog* logger, std::string const& filename,
GuidType componentGuidType)
: cmWIXSourceWriter(wixVersion, 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 =
2023-12-07 09:12:54 +01:00
cmStrCat(R"(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");
2023-12-07 09:12:54 +01:00
AddAttribute("Id", cmStrCat("CM_G_", group.Name));
2015-04-27 22:25:09 +02:00
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);
2023-12-07 09:12:54 +01:00
patch.ApplyFragment(cmStrCat("CM_G_", group.Name), *this);
2017-07-20 19:35:53 +02:00
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");
2023-12-07 09:12:54 +01:00
AddAttribute("Id", cmStrCat("CM_C_", component.Name));
2015-04-27 22:25:09 +02:00
AddAttributeUnlessEmpty("Title", component.DisplayName);
AddAttributeUnlessEmpty("Description", component.Description);
2016-07-09 11:21:54 +02:00
if (component.IsRequired) {
2024-07-09 14:46:46 +02:00
if (this->WixVersion >= 4) {
AddAttribute("AllowAbsent", "no");
} else {
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");
}
2023-12-07 09:12:54 +01:00
patch.ApplyFragment(cmStrCat("CM_C_", component.Name), *this);
2016-10-30 18:24:19 +01:00
2015-04-27 22:25:09 +02:00
EndElement("Feature");
}
void cmWIXFeaturesSourceWriter::EmitComponentRef(std::string const& id)
{
BeginElement("ComponentRef");
AddAttribute("Id", id);
EndElement("ComponentRef");
}