From 2c7668fa63be0a551ff452a06e8b1b2b4349684c Mon Sep 17 00:00:00 2001
From: Brian Bassett <bbassett@tibco.com>
Date: Fri, 27 Apr 2012 14:24:10 -0700
Subject: [PATCH 1/2] Add new generator expression for getting the
 configuration specific version of a variable (i.e.,
 $<CONFIG_SPECIFIC:CMAKE_ASM_MASM_FLAGS> ==
 $(CMAKE_ASM_MASM_FLAGS_DEBUG).)

---
 Source/cmCustomCommandGenerator.cxx |    6 +++++-
 Source/cmGeneratorExpression.cxx    |   27 +++++++++++++++++++++++++++
 Source/cmGeneratorExpression.h      |    2 ++
 3 files changed, 34 insertions(+), 1 deletions(-)

diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx
index a650129..ed6ebe5 100644
--- a/Source/cmCustomCommandGenerator.cxx
+++ b/Source/cmCustomCommandGenerator.cxx
@@ -60,7 +60,11 @@ cmCustomCommandGenerator
     {
     std::string arg = this->GE->Process(commandLine[j]);
     cmd += " ";
-    if(this->OldStyle)
+    if(commandLine[j].find("$<CONFIG_SPECIFIC:") != std::string::npos)
+      {
+      cmd += arg.c_str();
+      }
+    else if(this->OldStyle)
       {
       cmd += this->LG->EscapeForShellOldStyle(arg.c_str());
       }
diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx
index f88ab0b..59ecac6 100644
--- a/Source/cmGeneratorExpression.cxx
+++ b/Source/cmGeneratorExpression.cxx
@@ -25,6 +25,9 @@ cmGeneratorExpression::cmGeneratorExpression(
                            "_FILE(|_NAME|_DIR):" // Filename component.
                            "([A-Za-z0-9_.-]+)"   // Target name.
                            ">$");
+  this->ConfigSpecific.compile("^\\$<CONFIG_SPECIFIC:"
+                               "([A-Za-z_0-9/.+-]+)" // CMake variable
+                               ">$");
 }
 
 //----------------------------------------------------------------------------
@@ -112,6 +115,13 @@ bool cmGeneratorExpression::Evaluate(const char* expr, std::string& result)
       return false;
       }
     }
+  else if(this->ConfigSpecific.find(expr))
+    {
+    if(!this->EvaluateConfigSpecific(result))
+      {
+      return false;
+      }
+    }
   else if(strcmp(expr, "$<CONFIGURATION>") == 0)
     {
     result = this->Config? this->Config : "";
@@ -191,3 +201,20 @@ bool cmGeneratorExpression::EvaluateTargetInfo(std::string& result)
     }
   return true;
 }
+
+//----------------------------------------------------------------------------
+bool cmGeneratorExpression::EvaluateConfigSpecific(std::string& result)
+{
+  if(this->Config)
+    {
+    std::string var = this->ConfigSpecific.match(1);
+    var += "_";
+    var += cmsys::SystemTools::UpperCase(this->Config);
+    result = this->Makefile->GetRequiredDefinition(var.c_str());
+    }
+  else
+    {
+    result = "";
+    }
+  return true;
+}
\ No newline at end of file
diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h
index 1a9d4c6..ca00ebc 100644
--- a/Source/cmGeneratorExpression.h
+++ b/Source/cmGeneratorExpression.h
@@ -51,8 +51,10 @@ private:
   std::vector<char> Data;
   std::stack<size_t> Barriers;
   cmsys::RegularExpression TargetInfo;
+  cmsys::RegularExpression ConfigSpecific;
   std::set<cmTarget*> Targets;
   bool Evaluate();
   bool Evaluate(const char* expr, std::string& result);
   bool EvaluateTargetInfo(std::string& result);
+  bool EvaluateConfigSpecific(std::string& result);
 };
-- 
1.7.6.msysgit.0

