cmWIXFeaturesSourceWriter.cxx 2.6 KB

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