cmWIXFeaturesSourceWriter.cxx 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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)
  13. : cmWIXSourceWriter(logger, filename)
  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", "*");
  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)
  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);
  49. }
  50. for (std::vector<cmCPackComponent*>::const_iterator i =
  51. group.Components.begin();
  52. i != group.Components.end(); ++i) {
  53. EmitFeatureForComponent(**i);
  54. }
  55. EndElement("Feature");
  56. }
  57. void cmWIXFeaturesSourceWriter::EmitFeatureForComponent(
  58. cmCPackComponent const& component)
  59. {
  60. BeginElement("Feature");
  61. AddAttribute("Id", "CM_C_" + component.Name);
  62. AddAttributeUnlessEmpty("Title", component.DisplayName);
  63. AddAttributeUnlessEmpty("Description", component.Description);
  64. if (component.IsRequired) {
  65. AddAttribute("Absent", "disallow");
  66. }
  67. if (component.IsHidden) {
  68. AddAttribute("Display", "hidden");
  69. }
  70. EndElement("Feature");
  71. }
  72. void cmWIXFeaturesSourceWriter::EmitComponentRef(std::string const& id)
  73. {
  74. BeginElement("ComponentRef");
  75. AddAttribute("Id", id);
  76. EndElement("ComponentRef");
  77. }