cmWIXFeaturesSourceWriter.cxx 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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(cmCPackLog* logger,
  12. std::string const& filename):
  13. cmWIXSourceWriter(logger, filename)
  14. {
  15. }
  16. void cmWIXFeaturesSourceWriter::CreateCMakePackageRegistryEntry(
  17. std::string const& package,
  18. std::string const& upgradeGuid)
  19. {
  20. BeginElement("Component");
  21. AddAttribute("Id", "CM_PACKAGE_REGISTRY");
  22. AddAttribute("Directory", "TARGETDIR");
  23. AddAttribute("Guid", "*");
  24. std::string registryKey =
  25. std::string("Software\\Kitware\\CMake\\Packages\\") + package;
  26. BeginElement("RegistryValue");
  27. AddAttribute("Root", "HKLM");
  28. AddAttribute("Key", registryKey);
  29. AddAttribute("Name", upgradeGuid);
  30. AddAttribute("Type", "string");
  31. AddAttribute("Value", "[INSTALL_ROOT]");
  32. AddAttribute("KeyPath", "yes");
  33. EndElement("RegistryValue");
  34. EndElement("Component");
  35. }
  36. void cmWIXFeaturesSourceWriter::EmitFeatureForComponentGroup(
  37. cmCPackComponentGroup const& group)
  38. {
  39. BeginElement("Feature");
  40. AddAttribute("Id", "CM_G_" + group.Name);
  41. if(group.IsExpandedByDefault)
  42. {
  43. AddAttribute("Display", "expand");
  44. }
  45. AddAttributeUnlessEmpty("Title", group.DisplayName);
  46. AddAttributeUnlessEmpty("Description", group.Description);
  47. for(std::vector<cmCPackComponentGroup*>::const_iterator
  48. i = group.Subgroups.begin(); i != group.Subgroups.end(); ++i)
  49. {
  50. EmitFeatureForComponentGroup(**i);
  51. }
  52. for(std::vector<cmCPackComponent*>::const_iterator
  53. i = group.Components.begin(); i != group.Components.end(); ++i)
  54. {
  55. EmitFeatureForComponent(**i);
  56. }
  57. EndElement("Feature");
  58. }
  59. void cmWIXFeaturesSourceWriter::EmitFeatureForComponent(
  60. cmCPackComponent const& component)
  61. {
  62. BeginElement("Feature");
  63. AddAttribute("Id", "CM_C_" + component.Name);
  64. AddAttributeUnlessEmpty("Title", component.DisplayName);
  65. AddAttributeUnlessEmpty("Description", component.Description);
  66. if(component.IsRequired)
  67. {
  68. AddAttribute("Absent", "disallow");
  69. }
  70. if(component.IsHidden)
  71. {
  72. AddAttribute("Display", "hidden");
  73. }
  74. EndElement("Feature");
  75. }
  76. void cmWIXFeaturesSourceWriter::EmitComponentRef(std::string const& id)
  77. {
  78. BeginElement("ComponentRef");
  79. AddAttribute("Id", id);
  80. EndElement("ComponentRef");
  81. }