summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2014-03-07 16:20:10 (GMT)
committerBrad King <brad.king@kitware.com>2014-03-20 13:21:56 (GMT)
commitbbffccca42d4f209220e833e1a86e735a5c83339 (patch)
tree2c59eda71ee2691eab3a5b922b17d91586b019c5 /Source
parentfb4aff058d2595078300b682dc477f0ccba6d31b (diff)
downloadCMake-bbffccca42d4f209220e833e1a86e735a5c83339.zip
CMake-bbffccca42d4f209220e833e1a86e735a5c83339.tar.gz
CMake-bbffccca42d4f209220e833e1a86e735a5c83339.tar.bz2
add_custom_command: Evaluate generator expressions in DEPENDS
Rely on evaluation in cmCustomCommandGenerator for the generators. When tracing target dependencies, depend on the union of dependencies for all configurations.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmCustomCommandGenerator.cxx18
-rw-r--r--Source/cmCustomCommandGenerator.h2
-rw-r--r--Source/cmGeneratorTarget.cxx39
3 files changed, 52 insertions, 7 deletions
diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx
index a091cff..cebd9f5 100644
--- a/Source/cmCustomCommandGenerator.cxx
+++ b/Source/cmCustomCommandGenerator.cxx
@@ -21,7 +21,7 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(
cmCustomCommand const& cc, const std::string& config, cmMakefile* mf):
CC(cc), Config(config), Makefile(mf), LG(mf->GetLocalGenerator()),
OldStyle(cc.GetEscapeOldStyle()), MakeVars(cc.GetEscapeAllowMakeVars()),
- GE(new cmGeneratorExpression(cc.GetBacktrace()))
+ GE(new cmGeneratorExpression(cc.GetBacktrace())), DependsDone(false)
{
}
@@ -93,5 +93,19 @@ std::vector<std::string> const& cmCustomCommandGenerator::GetOutputs() const
//----------------------------------------------------------------------------
std::vector<std::string> const& cmCustomCommandGenerator::GetDepends() const
{
- return this->CC.GetDepends();
+ if (!this->DependsDone)
+ {
+ this->DependsDone = true;
+ std::vector<std::string> depends = this->CC.GetDepends();
+ for(std::vector<std::string>::const_iterator
+ i = depends.begin();
+ i != depends.end(); ++i)
+ {
+ cmsys::auto_ptr<cmCompiledGeneratorExpression> cge
+ = this->GE->Parse(*i);
+ cmSystemTools::ExpandListArgument(
+ cge->Evaluate(this->Makefile, this->Config), this->Depends);
+ }
+ }
+ return this->Depends;
}
diff --git a/Source/cmCustomCommandGenerator.h b/Source/cmCustomCommandGenerator.h
index cbcdb41..0d8a0a4 100644
--- a/Source/cmCustomCommandGenerator.h
+++ b/Source/cmCustomCommandGenerator.h
@@ -28,6 +28,8 @@ class cmCustomCommandGenerator
bool OldStyle;
bool MakeVars;
cmGeneratorExpression* GE;
+ mutable bool DependsDone;
+ mutable std::vector<std::string> Depends;
public:
cmCustomCommandGenerator(cmCustomCommand const& cc,
const std::string& config,
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 2a144c6..b35e859 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -19,6 +19,7 @@
#include "cmGeneratorExpression.h"
#include "cmGeneratorExpressionDAGChecker.h"
#include "cmComputeLinkInformation.h"
+#include "cmCustomCommandGenerator.h"
#include <queue>
@@ -610,6 +611,9 @@ private:
bool IsUtility(std::string const& dep);
void CheckCustomCommand(cmCustomCommand const& cc);
void CheckCustomCommands(const std::vector<cmCustomCommand>& commands);
+ void FollowCommandDepends(cmCustomCommand const& cc,
+ const std::string& config,
+ std::set<std::string>& emitted);
};
//----------------------------------------------------------------------------
@@ -826,16 +830,41 @@ cmTargetTraceDependencies
}
// Queue the custom command dependencies.
- std::vector<std::string> const& depends = cc.GetDepends();
+ std::vector<std::string> configs;
+ std::set<std::string> emitted;
+ this->Makefile->GetConfigurations(configs);
+ if (configs.empty())
+ {
+ configs.push_back("");
+ }
+ for(std::vector<std::string>::const_iterator ci = configs.begin();
+ ci != configs.end(); ++ci)
+ {
+ this->FollowCommandDepends(cc, *ci, emitted);
+ }
+}
+
+//----------------------------------------------------------------------------
+void cmTargetTraceDependencies::FollowCommandDepends(cmCustomCommand const& cc,
+ const std::string& config,
+ std::set<std::string>& emitted)
+{
+ cmCustomCommandGenerator ccg(cc, config, this->Makefile);
+
+ const std::vector<std::string>& depends = ccg.GetDepends();
+
for(std::vector<std::string>::const_iterator di = depends.begin();
di != depends.end(); ++di)
{
std::string const& dep = *di;
- if(!this->IsUtility(dep))
+ if(emitted.insert(dep).second)
{
- // The dependency does not name a target and may be a file we
- // know how to generate. Queue it.
- this->FollowName(dep);
+ if(!this->IsUtility(dep))
+ {
+ // The dependency does not name a target and may be a file we
+ // know how to generate. Queue it.
+ this->FollowName(dep);
+ }
}
}
}