summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-11-13 10:08:32 -0500
committerCMake Topic Stage <kwrobot@kitware.com>2014-11-13 10:08:32 -0500
commitcddb5002b5c28c0cc5fe9c1e41a5e0f556b3e3a8 (patch)
tree82663543eff5ef399e9f51dfbe3d0ead4fc43265 /Source
parentf4e652b5633c14d3602be8805a2f0c49bb524147 (diff)
parentb80557c7bdf12f9e924ac8b010d547ce4561848e (diff)
downloadcmake-cddb5002b5c28c0cc5fe9c1e41a5e0f556b3e3a8.tar.gz
Merge topic 'file-GENERATE-source'
b80557c7 file(GENERATE): Evaluate early to allow generating source files 0019d54b Genex: Fix whitespace issue.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGeneratorExpression.cxx2
-rw-r--r--Source/cmGeneratorExpression.h5
-rw-r--r--Source/cmGeneratorExpressionEvaluationFile.cxx17
-rw-r--r--Source/cmGeneratorExpressionEvaluationFile.h2
-rw-r--r--Source/cmGeneratorExpressionEvaluator.cxx6
-rw-r--r--Source/cmGeneratorExpressionEvaluator.h1
-rw-r--r--Source/cmGeneratorTarget.cxx11
-rw-r--r--Source/cmGlobalGenerator.cxx30
-rw-r--r--Source/cmGlobalGenerator.h10
-rw-r--r--Source/cmLocalGenerator.cxx11
10 files changed, 92 insertions, 3 deletions
diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx
index 09d02ea6f7..bff6f5f6cc 100644
--- a/Source/cmGeneratorExpression.cxx
+++ b/Source/cmGeneratorExpression.cxx
@@ -90,6 +90,7 @@ const char *cmCompiledGeneratorExpression::Evaluate(
context.HadError = false;
context.HadContextSensitiveCondition = false;
context.HadHeadSensitiveCondition = false;
+ context.SourceSensitiveTargets.clear();
context.HeadTarget = headTarget;
context.EvaluateForBuildsystem = this->EvaluateForBuildsystem;
context.CurrentTarget = currentTarget ? currentTarget : headTarget;
@@ -118,6 +119,7 @@ const char *cmCompiledGeneratorExpression::Evaluate(
{
this->HadContextSensitiveCondition = context.HadContextSensitiveCondition;
this->HadHeadSensitiveCondition = context.HadHeadSensitiveCondition;
+ this->SourceSensitiveTargets = context.SourceSensitiveTargets;
}
this->DependTargets = context.DependTargets;
diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h
index b952520e60..57f78c5160 100644
--- a/Source/cmGeneratorExpression.h
+++ b/Source/cmGeneratorExpression.h
@@ -115,6 +115,10 @@ public:
{
return this->HadHeadSensitiveCondition;
}
+ std::set<cmTarget const*> GetSourceSensitiveTargets() const
+ {
+ return this->SourceSensitiveTargets;
+ }
void SetEvaluateForBuildsystem(bool eval)
{
@@ -146,6 +150,7 @@ private:
mutable std::string Output;
mutable bool HadContextSensitiveCondition;
mutable bool HadHeadSensitiveCondition;
+ mutable std::set<cmTarget const*> SourceSensitiveTargets;
bool EvaluateForBuildsystem;
};
diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx
index 3a8dc4843d..1a101ddf67 100644
--- a/Source/cmGeneratorExpressionEvaluationFile.cxx
+++ b/Source/cmGeneratorExpressionEvaluationFile.cxx
@@ -13,6 +13,9 @@
#include "cmGeneratorExpressionEvaluationFile.h"
#include "cmMakefile.h"
+#include "cmLocalGenerator.h"
+#include "cmGlobalGenerator.h"
+#include "cmSourceFile.h"
#include "cmGeneratedFileStream.h"
#include <cmsys/FStream.hxx>
@@ -90,6 +93,20 @@ void cmGeneratorExpressionEvaluationFile::Generate(const std::string& config,
}
//----------------------------------------------------------------------------
+void cmGeneratorExpressionEvaluationFile::CreateOutputFile(
+ std::string const& config)
+{
+ std::string name = this->OutputFileExpr->Evaluate(this->Makefile, config);
+ cmSourceFile* sf = this->Makefile->GetOrCreateSource(name);
+ sf->SetProperty("GENERATED", "1");
+
+ cmGlobalGenerator *gg
+ = this->Makefile->GetLocalGenerator()->GetGlobalGenerator();
+ gg->SetFilenameTargetDepends(sf,
+ this->OutputFileExpr->GetSourceSensitiveTargets());
+}
+
+//----------------------------------------------------------------------------
void cmGeneratorExpressionEvaluationFile::Generate()
{
mode_t perm = 0;
diff --git a/Source/cmGeneratorExpressionEvaluationFile.h b/Source/cmGeneratorExpressionEvaluationFile.h
index 4e87a88a62..3394ade8f2 100644
--- a/Source/cmGeneratorExpressionEvaluationFile.h
+++ b/Source/cmGeneratorExpressionEvaluationFile.h
@@ -31,6 +31,8 @@ public:
std::vector<std::string> GetFiles() const { return this->Files; }
+ void CreateOutputFile(std::string const& config);
+
private:
void Generate(const std::string& config,
cmCompiledGeneratorExpression* inputExpression,
diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx
index 27fe9102b5..9aa8e6f75b 100644
--- a/Source/cmGeneratorExpressionEvaluator.cxx
+++ b/Source/cmGeneratorExpressionEvaluator.cxx
@@ -939,7 +939,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
reportError(context, content->GetOriginalExpression(), e.str());
return std::string();
}
- context->AllTargets.insert(target);
+ context->AllTargets.insert(target);
}
if (target == context->HeadTarget)
@@ -950,6 +950,10 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
// value for all evaluations.
context->SeenTargetProperties.insert(propertyName);
}
+ if (propertyName == "SOURCES")
+ {
+ context->SourceSensitiveTargets.insert(target);
+ }
if (propertyName.empty())
{
diff --git a/Source/cmGeneratorExpressionEvaluator.h b/Source/cmGeneratorExpressionEvaluator.h
index 8a529e88d0..0bf17974e9 100644
--- a/Source/cmGeneratorExpressionEvaluator.h
+++ b/Source/cmGeneratorExpressionEvaluator.h
@@ -31,6 +31,7 @@ struct cmGeneratorExpressionContext
std::set<cmTarget*> DependTargets;
std::set<cmTarget const*> AllTargets;
std::set<std::string> SeenTargetProperties;
+ std::set<cmTarget const*> SourceSensitiveTargets;
std::map<cmTarget const*, std::map<std::string, std::string> >
MaxLanguageStandard;
cmMakefile *Makefile;
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 1d1225f8c6..5836a273c9 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -646,6 +646,17 @@ cmTargetTraceDependencies
si != sources.end(); ++si)
{
cmSourceFile* sf = *si;
+ const std::set<cmTarget const*> tgts =
+ this->GlobalGenerator->GetFilenameTargetDepends(sf);
+ if (tgts.find(this->Target) != tgts.end())
+ {
+ cmOStringStream e;
+ e << "Evaluation output file\n \"" << sf->GetFullPath()
+ << "\"\ndepends on the sources of a target it is used in. This "
+ "is a dependency loop and is not allowed.";
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ return;
+ }
if(emitted.insert(sf).second && this->SourcesQueued.insert(sf).second)
{
this->SourceQueue.push(sf);
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index aec47fbcbd..ab9dc88b6e 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1263,8 +1263,6 @@ void cmGlobalGenerator::Generate()
// Create per-target generator information.
this->CreateGeneratorTargets();
- this->ForceLinkerLanguages();
-
#ifdef CMAKE_BUILD_WITH_CMAKE
for (AutogensType::iterator it = autogens.begin(); it != autogens.end();
++it)
@@ -1280,6 +1278,8 @@ void cmGlobalGenerator::Generate()
this->LocalGenerators[i]->TraceDependencies();
}
+ this->ForceLinkerLanguages();
+
// Compute the manifest of main targets generated.
for (i = 0; i < this->LocalGenerators.size(); ++i)
{
@@ -2993,6 +2993,32 @@ std::string cmGlobalGenerator::EscapeJSON(const std::string& s) {
}
//----------------------------------------------------------------------------
+void cmGlobalGenerator::SetFilenameTargetDepends(cmSourceFile* sf,
+ std::set<cmTarget const*> tgts)
+{
+ this->FilenameTargetDepends[sf] = tgts;
+}
+
+//----------------------------------------------------------------------------
+std::set<cmTarget const*> const&
+cmGlobalGenerator::GetFilenameTargetDepends(cmSourceFile* sf) const {
+ return this->FilenameTargetDepends[sf];
+}
+
+//----------------------------------------------------------------------------
+void cmGlobalGenerator::CreateEvaluationSourceFiles(
+ std::string const& config) const
+{
+ for(std::vector<cmGeneratorExpressionEvaluationFile*>::const_iterator
+ li = this->EvaluationFiles.begin();
+ li != this->EvaluationFiles.end();
+ ++li)
+ {
+ (*li)->CreateOutputFile(config);
+ }
+}
+
+//----------------------------------------------------------------------------
void cmGlobalGenerator::AddEvaluationFile(const std::string &inputFile,
cmsys::auto_ptr<cmCompiledGeneratorExpression> outputExpr,
cmMakefile *makefile,
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index ddd7e910d7..8a10d3879d 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -341,6 +341,13 @@ public:
bool GenerateCPackPropertiesFile();
+ void CreateEvaluationSourceFiles(std::string const& config) const;
+
+ void SetFilenameTargetDepends(cmSourceFile* sf,
+ std::set<cmTarget const*> tgts);
+ std::set<cmTarget const*> const&
+ GetFilenameTargetDepends(cmSourceFile* sf) const;
+
protected:
virtual void Generate();
@@ -488,6 +495,9 @@ private:
// track targets to issue CMP0042 warning for.
std::set<std::string> CMP0042WarnTargets;
+
+ mutable std::map<cmSourceFile*, std::set<cmTarget const*> >
+ FilenameTargetDepends;
};
#endif
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 69b56c6b2f..3fb1e1eec7 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -259,6 +259,17 @@ void cmLocalGenerator::ConfigureFinalPass()
void cmLocalGenerator::TraceDependencies()
{
+ std::vector<std::string> configs;
+ 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->GlobalGenerator->CreateEvaluationSourceFiles(*ci);
+ }
// Generate the rule files for each target.
cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets();
for(cmGeneratorTargetsType::iterator t = targets.begin();