cmWIXFeaturesSourceWriter.cxx 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #include "cmWIXFeaturesSourceWriter.h"
  4. cmWIXFeaturesSourceWriter::cmWIXFeaturesSourceWriter(
  5. cmCPackLog* logger, std::string const& filename, GuidType componentGuidType)
  6. : cmWIXSourceWriter(logger, filename, componentGuidType)
  7. {
  8. }
  9. void cmWIXFeaturesSourceWriter::CreateCMakePackageRegistryEntry(
  10. std::string const& package, std::string const& upgradeGuid)
  11. {
  12. BeginElement("Component");
  13. AddAttribute("Id", "CM_PACKAGE_REGISTRY");
  14. AddAttribute("Directory", "TARGETDIR");
  15. AddAttribute("Guid", CreateGuidFromComponentId("CM_PACKAGE_REGISTRY"));
  16. std::string registryKey =
  17. std::string("Software\\Kitware\\CMake\\Packages\\") + package;
  18. BeginElement("RegistryValue");
  19. AddAttribute("Root", "HKLM");
  20. AddAttribute("Key", registryKey);
  21. AddAttribute("Name", upgradeGuid);
  22. AddAttribute("Type", "string");
  23. AddAttribute("Value", "[INSTALL_ROOT]");
  24. AddAttribute("KeyPath", "yes");
  25. EndElement("RegistryValue");
  26. EndElement("Component");
  27. }
  28. void cmWIXFeaturesSourceWriter::EmitFeatureForComponentGroup(
  29. cmCPackComponentGroup const& group, cmWIXPatch& patch)
  30. {
  31. BeginElement("Feature");
  32. AddAttribute("Id", "CM_G_" + group.Name);
  33. if (group.IsExpandedByDefault) {
  34. AddAttribute("Display", "expand");
  35. }
  36. AddAttributeUnlessEmpty("Title", group.DisplayName);
  37. AddAttributeUnlessEmpty("Description", group.Description);
  38. patch.ApplyFragment("CM_G_" + group.Name, *this);
  39. for (cmCPackComponentGroup* subgroup : group.Subgroups) {
  40. EmitFeatureForComponentGroup(*subgroup, patch);
  41. }
  42. for (cmCPackComponent* component : group.Components) {
  43. EmitFeatureForComponent(*component, patch);
  44. }
  45. EndElement("Feature");
  46. }
  47. void cmWIXFeaturesSourceWriter::EmitFeatureForComponent(
  48. cmCPackComponent const& component, cmWIXPatch& patch)
  49. {
  50. BeginElement("Feature");
  51. AddAttribute("Id", "CM_C_" + component.Name);
  52. AddAttributeUnlessEmpty("Title", component.DisplayName);
  53. AddAttributeUnlessEmpty("Description", component.Description);
  54. if (component.IsRequired) {
  55. AddAttribute("Absent", "disallow");
  56. }
  57. if (component.IsHidden) {
  58. AddAttribute("Display", "hidden");
  59. }
  60. if (component.IsDisabledByDefault) {
  61. AddAttribute("Level", "2");
  62. }
  63. patch.ApplyFragment("CM_C_" + component.Name, *this);
  64. EndElement("Feature");
  65. }
  66. void cmWIXFeaturesSourceWriter::EmitComponentRef(std::string const& id)
  67. {
  68. BeginElement("ComponentRef");
  69. AddAttribute("Id", id);
  70. EndElement("ComponentRef");
  71. }