cmWIXFeaturesSourceWriter.cxx 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. for (std::vector<cmCPackComponentGroup*>::const_iterator i =
  39. group.Subgroups.begin();
  40. i != group.Subgroups.end(); ++i) {
  41. EmitFeatureForComponentGroup(**i, patch);
  42. }
  43. for (std::vector<cmCPackComponent*>::const_iterator i =
  44. group.Components.begin();
  45. i != group.Components.end(); ++i) {
  46. EmitFeatureForComponent(**i, patch);
  47. }
  48. patch.ApplyFragment("CM_G_" + group.Name, *this);
  49. EndElement("Feature");
  50. }
  51. void cmWIXFeaturesSourceWriter::EmitFeatureForComponent(
  52. cmCPackComponent const& component, cmWIXPatch& patch)
  53. {
  54. BeginElement("Feature");
  55. AddAttribute("Id", "CM_C_" + component.Name);
  56. AddAttributeUnlessEmpty("Title", component.DisplayName);
  57. AddAttributeUnlessEmpty("Description", component.Description);
  58. if (component.IsRequired) {
  59. AddAttribute("Absent", "disallow");
  60. }
  61. if (component.IsHidden) {
  62. AddAttribute("Display", "hidden");
  63. }
  64. if (component.IsDisabledByDefault) {
  65. AddAttribute("Level", "2");
  66. }
  67. patch.ApplyFragment("CM_C_" + component.Name, *this);
  68. EndElement("Feature");
  69. }
  70. void cmWIXFeaturesSourceWriter::EmitComponentRef(std::string const& id)
  71. {
  72. BeginElement("ComponentRef");
  73. AddAttribute("Id", id);
  74. EndElement("ComponentRef");
  75. }