From 4b1889376cfc9213397a374e98ff70f543f080e1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20St=C3=BCrmer?= <michael.stuermer@schaeffler.com>
Date: Tue, 6 Sep 2016 12:42:07 +0200
Subject: [PATCH 3/3] enabled patching of WIX <Feature> tags

---
 Source/CPack/WiX/cmCPackWIXGenerator.cxx       |  4 ++--
 Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx | 10 ++++++----
 Source/CPack/WiX/cmWIXFeaturesSourceWriter.h   |  7 +++++--
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx
index 5a979b1..40b29df 100644
--- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx
+++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx
@@ -628,7 +628,7 @@ bool cmCPackWIXGenerator::CreateFeatureHierarchy(
        i != ComponentGroups.end(); ++i) {
     cmCPackComponentGroup const& group = i->second;
     if (group.ParentGroup == 0) {
-      featureDefinitions.EmitFeatureForComponentGroup(group);
+      featureDefinitions.EmitFeatureForComponentGroup(group, *this->Patch);
     }
   }
 
@@ -638,7 +638,7 @@ bool cmCPackWIXGenerator::CreateFeatureHierarchy(
     cmCPackComponent const& component = i->second;
 
     if (!component.Group) {
-      featureDefinitions.EmitFeatureForComponent(component);
+      featureDefinitions.EmitFeatureForComponent(component, *this->Patch);
     }
   }
 
diff --git a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx
index d615450..8bddc2e 100644
--- a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx
+++ b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx
@@ -44,7 +44,7 @@ void cmWIXFeaturesSourceWriter::CreateCMakePackageRegistryEntry(
 }
 
 void cmWIXFeaturesSourceWriter::EmitFeatureForComponentGroup(
-  cmCPackComponentGroup const& group)
+  cmCPackComponentGroup const& group, cmWIXPatch& patch)
 {
   BeginElement("Feature");
   AddAttribute("Id", "CM_G_" + group.Name);
@@ -59,20 +59,20 @@ void cmWIXFeaturesSourceWriter::EmitFeatureForComponentGroup(
   for (std::vector<cmCPackComponentGroup*>::const_iterator i =
          group.Subgroups.begin();
        i != group.Subgroups.end(); ++i) {
-    EmitFeatureForComponentGroup(**i);
+    EmitFeatureForComponentGroup(**i, patch);
   }
 
   for (std::vector<cmCPackComponent*>::const_iterator i =
          group.Components.begin();
        i != group.Components.end(); ++i) {
-    EmitFeatureForComponent(**i);
+    EmitFeatureForComponent(**i, patch);
   }
 
   EndElement("Feature");
 }
 
 void cmWIXFeaturesSourceWriter::EmitFeatureForComponent(
-  cmCPackComponent const& component)
+  cmCPackComponent const& component, cmWIXPatch& patch)
 {
   BeginElement("Feature");
   AddAttribute("Id", "CM_C_" + component.Name);
@@ -92,6 +92,8 @@ void cmWIXFeaturesSourceWriter::EmitFeatureForComponent(
     AddAttribute("Level", "2");
   }
 
+  patch.ApplyFragment("CM_C_" + component.Name, *this);
+
   EndElement("Feature");
 }
 
diff --git a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.h b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.h
index eb90e5f..09768db 100644
--- a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.h
+++ b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.h
@@ -13,6 +13,7 @@
 #ifndef cmWIXFeaturesSourceWriter_h
 #define cmWIXFeaturesSourceWriter_h
 
+#include "cmWIXPatch.h"
 #include "cmWIXSourceWriter.h"
 
 #include <CPack/cmCPackGenerator.h>
@@ -29,9 +30,11 @@ public:
   void CreateCMakePackageRegistryEntry(std::string const& package,
                                        std::string const& upgradeGuid);
 
-  void EmitFeatureForComponentGroup(const cmCPackComponentGroup& group);
+  void EmitFeatureForComponentGroup(const cmCPackComponentGroup& group,
+                                    cmWIXPatch& patch);
 
-  void EmitFeatureForComponent(const cmCPackComponent& component);
+  void EmitFeatureForComponent(const cmCPackComponent& component,
+                               cmWIXPatch& patch);
 
   void EmitComponentRef(std::string const& id);
 };
-- 
2.8.0.windows.1

