cmWIXFeaturesSourceWriter.cxx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2014 Kitware, Inc.
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #include "cmWIXFeaturesSourceWriter.h"
  11. cmWIXFeaturesSourceWriter::cmWIXFeaturesSourceWriter(
  12. cmCPackLog* logger, std::string const& filename, GuidType componentGuidType)
  13. : cmWIXSourceWriter(logger, filename, componentGuidType)
  14. {
  15. }
  16. void cmWIXFeaturesSourceWriter::CreateCMakePackageRegistryEntry(
  17. std::string const& package, std::string const& upgradeGuid)
  18. {
  19. BeginElement("Component");
  20. AddAttribute("Id", "CM_PACKAGE_REGISTRY");
  21. AddAttribute("Directory", "TARGETDIR");
  22. AddAttribute("Guid", CreateGuidFromComponentId("CM_PACKAGE_REGISTRY"));
  23. std::string registryKey =
  24. std::string("Software\\Kitware\\CMake\\Packages\\") + package;
  25. BeginElement("RegistryValue");
  26. AddAttribute("Root", "HKLM");
  27. AddAttribute("Key", registryKey);
  28. AddAttribute("Name", upgradeGuid);
  29. AddAttribute("Type", "string");
  30. AddAttribute("Value", "[INSTALL_ROOT]");
  31. AddAttribute("KeyPath", "yes");
  32. EndElement("RegistryValue");
  33. EndElement("Component");
  34. }
  35. void cmWIXFeaturesSourceWriter::EmitFeatureForComponentGroup(
  36. cmCPackComponentGroup const& group, cmWIXPatch& patch)
  37. {
  38. BeginElement("Feature");
  39. AddAttribute("Id", "CM_G_" + group.Name);
  40. if (group.IsExpandedByDefault) {
  41. AddAttribute("Display", "expand");
  42. }
  43. AddAttributeUnlessEmpty("Title", group.DisplayName);
  44. AddAttributeUnlessEmpty("Description", group.Description);
  45. for (std::vector<cmCPackComponentGroup*>::const_iterator i =
  46. group.Subgroups.begin();
  47. i != group.Subgroups.end(); ++i) {
  48. EmitFeatureForComponentGroup(**i, patch);
  49. }
  50. for (std::vector<cmCPackComponent*>::const_iterator i =
  51. group.Components.begin();
  52. i != group.Components.end(); ++i) {
  53. EmitFeatureForComponent(**i, patch);
  54. }
  55. patch.ApplyFragment("CM_G_" + group.Name, *this);
  56. EndElement("Feature");
  57. }
  58. void cmWIXFeaturesSourceWriter::EmitFeatureForComponent(
  59. cmCPackComponent const& component, cmWIXPatch& patch)
  60. {
  61. BeginElement("Feature");
  62. AddAttribute("Id", "CM_C_" + component.Name);
  63. AddAttributeUnlessEmpty("Title", component.DisplayName);
  64. AddAttributeUnlessEmpty("Description", component.Description);
  65. if (component.IsRequired) {
  66. AddAttribute("Absent", "disallow");
  67. }
  68. if (component.IsHidden) {
  69. AddAttribute("Display", "hidden");
  70. }
  71. if (component.IsDisabledByDefault) {
  72. AddAttribute("Level", "2");
  73. }
  74. patch.ApplyFragment("CM_C_" + component.Name, *this);
  75. EndElement("Feature");
  76. }
  77. void cmWIXFeaturesSourceWriter::EmitComponentRef(std::string const& id)
  78. {
  79. BeginElement("ComponentRef");
  80. AddAttribute("Id", id);
  81. EndElement("ComponentRef");
  82. }