diff options
author | Stephen Kelly <steveire@gmail.com> | 2015-08-05 15:37:50 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2015-08-26 17:46:33 (GMT) |
commit | c2b7336ff3122c57a235aeaa1699ba5627ecf3ce (patch) | |
tree | 58638a12ead027a3e9ab1c67f358da46082632b4 | |
parent | 69329fff70300debf10b62ac08a6bcee9ae7bc3c (diff) | |
download | CMake-c2b7336ff3122c57a235aeaa1699ba5627ecf3ce.zip CMake-c2b7336ff3122c57a235aeaa1699ba5627ecf3ce.tar.gz CMake-c2b7336ff3122c57a235aeaa1699ba5627ecf3ce.tar.bz2 |
cmGeneratorTarget: Move GetConfigCommonSourceFiles from cmTarget.
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 59 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.h | 2 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudioGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 11 | ||||
-rw-r--r-- | Source/cmLocalVisualStudio6Generator.cxx | 5 | ||||
-rw-r--r-- | Source/cmLocalVisualStudio7Generator.cxx | 7 | ||||
-rw-r--r-- | Source/cmQtAutoGenerators.cxx | 14 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 56 | ||||
-rw-r--r-- | Source/cmTarget.h | 2 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 2 |
10 files changed, 88 insertions, 72 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 4ada029..cd7671d 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -4416,11 +4416,68 @@ cmGeneratorTarget::GetLinkImplementation(const std::string& config) const } //---------------------------------------------------------------------------- +bool cmGeneratorTarget::GetConfigCommonSourceFiles( + std::vector<cmSourceFile*>& files) const +{ + std::vector<std::string> configs; + this->Makefile->GetConfigurations(configs); + if (configs.empty()) + { + configs.push_back(""); + } + + std::vector<std::string>::const_iterator it = configs.begin(); + const std::string& firstConfig = *it; + this->Target->GetSourceFiles(files, firstConfig); + + for ( ; it != configs.end(); ++it) + { + std::vector<cmSourceFile*> configFiles; + this->Target->GetSourceFiles(configFiles, *it); + if (configFiles != files) + { + std::string firstConfigFiles; + const char* sep = ""; + for (std::vector<cmSourceFile*>::const_iterator fi = files.begin(); + fi != files.end(); ++fi) + { + firstConfigFiles += sep; + firstConfigFiles += (*fi)->GetFullPath(); + sep = "\n "; + } + + std::string thisConfigFiles; + sep = ""; + for (std::vector<cmSourceFile*>::const_iterator fi = configFiles.begin(); + fi != configFiles.end(); ++fi) + { + thisConfigFiles += sep; + thisConfigFiles += (*fi)->GetFullPath(); + sep = "\n "; + } + std::ostringstream e; + e << "Target \"" << this->GetName() + << "\" has source files which vary by " + "configuration. This is not supported by the \"" + << this->GlobalGenerator->GetName() + << "\" generator.\n" + "Config \"" << firstConfig << "\":\n" + " " << firstConfigFiles << "\n" + "Config \"" << *it << "\":\n" + " " << thisConfigFiles << "\n"; + this->LocalGenerator->IssueMessage(cmake::FATAL_ERROR, e.str()); + return false; + } + } + return true; +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetLanguages(std::set<std::string>& languages, const std::string& config) const { std::vector<cmSourceFile*> sourceFiles; - this->Target->GetSourceFiles(sourceFiles, config); + this->GetSourceFiles(sourceFiles, config); for(std::vector<cmSourceFile*>::const_iterator i = sourceFiles.begin(); i != sourceFiles.end(); ++i) { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 5f96f2a..2c8467f 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -213,6 +213,8 @@ public: void GetLanguages(std::set<std::string>& languages, std::string const& config) const; + bool GetConfigCommonSourceFiles(std::vector<cmSourceFile*>& files) const; + bool HaveBuildTreeRPATH(const std::string& config) const; /** Full path with trailing slash to the top-level directory diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 9b1f4c2..2bf04b4 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -843,7 +843,7 @@ cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target) { // Issue diagnostic if the source files depend on the config. std::vector<cmSourceFile*> sources; - if (!target.GetConfigCommonSourceFiles(sources)) + if (!gt->GetConfigCommonSourceFiles(sources)) { return false; } diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 4511de5..eb547bd 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1124,7 +1124,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, // organize the sources std::vector<cmSourceFile*> classes; - if (!cmtarget.GetConfigCommonSourceFiles(classes)) + if (!gtgt->GetConfigCommonSourceFiles(classes)) { return false; } @@ -1505,7 +1505,8 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases, } std::vector<cmSourceFile*> classes; - if (!cmtarget.GetConfigCommonSourceFiles(classes)) + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); + if (!gtgt->GetConfigCommonSourceFiles(classes)) { return; } @@ -2557,7 +2558,8 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget) if(cmtarget.GetType() == cmTarget::UTILITY) { std::vector<cmSourceFile*> sources; - if (!cmtarget.GetConfigCommonSourceFiles(sources)) + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); + if (!gtgt->GetConfigCommonSourceFiles(sources)) { return 0; } @@ -3085,7 +3087,8 @@ bool cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root, } std::vector<cmSourceFile*> classes; - if (!cmtarget.GetConfigCommonSourceFiles(classes)) + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); + if (!gtgt->GetConfigCommonSourceFiles(classes)) { return false; } diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 0d07536..3a44367 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -305,9 +305,12 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout, // We may be modifying the source groups temporarily, so make a copy. std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups(); + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); + // get the classes from the source lists then add them to the groups std::vector<cmSourceFile*> classes; - if (!target.GetConfigCommonSourceFiles(classes)) + if (!gt->GetConfigCommonSourceFiles(classes)) { return; } diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index f17c9a4..55ad852 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1469,10 +1469,13 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, // We may be modifying the source groups temporarily, so make a copy. std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups(); + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); + // get the classes from the source lists then add them to the groups this->ModuleDefinitionFile = ""; std::vector<cmSourceFile*> classes; - if (!target.GetConfigCommonSourceFiles(classes)) + if (!gt->GetConfigCommonSourceFiles(classes)) { return; } @@ -1514,8 +1517,6 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, { // VS >= 8 support per-config source locations so we // list object library content as external objects. - cmGeneratorTarget* gt = - this->GlobalGenerator->GetGeneratorTarget(&target); std::vector<std::string> objs; gt->UseObjectLibraries(objs, ""); if(!objs.empty()) diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index c58e7e4..0a4b546 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -403,7 +403,9 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg, ) { std::vector<cmSourceFile*> srcFiles; - target->GetConfigCommonSourceFiles(srcFiles); + cmGeneratorTarget* gtgt = + lg->GetGlobalGenerator()->GetGeneratorTarget(target); + gtgt->GetConfigCommonSourceFiles(srcFiles); for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin(); fileIt != srcFiles.end(); ++fileIt) @@ -661,7 +663,10 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target) const char* sepHeaders = ""; std::vector<cmSourceFile*> srcFiles; - target->GetConfigCommonSourceFiles(srcFiles); + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); + gtgt->GetConfigCommonSourceFiles(srcFiles); const char *skipMocSep = ""; const char *skipUicSep = ""; @@ -1046,7 +1051,10 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) cmMakefile *makefile = target->GetMakefile(); std::vector<cmSourceFile*> srcFiles; - target->GetConfigCommonSourceFiles(srcFiles); + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); + gtgt->GetConfigCommonSourceFiles(srcFiles); std::string qrcInputs; const char* qrcInputsSep = ""; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 8a21269..b2c70f0 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -725,62 +725,6 @@ void cmTarget::GetSourceFiles(std::vector<std::string> &files, } //---------------------------------------------------------------------------- -bool -cmTarget::GetConfigCommonSourceFiles(std::vector<cmSourceFile*>& files) const -{ - std::vector<std::string> configs; - this->Makefile->GetConfigurations(configs); - if (configs.empty()) - { - configs.push_back(""); - } - - std::vector<std::string>::const_iterator it = configs.begin(); - const std::string& firstConfig = *it; - this->GetSourceFiles(files, firstConfig); - - for ( ; it != configs.end(); ++it) - { - std::vector<cmSourceFile*> configFiles; - this->GetSourceFiles(configFiles, *it); - if (configFiles != files) - { - std::string firstConfigFiles; - const char* sep = ""; - for (std::vector<cmSourceFile*>::const_iterator fi = files.begin(); - fi != files.end(); ++fi) - { - firstConfigFiles += sep; - firstConfigFiles += (*fi)->GetFullPath(); - sep = "\n "; - } - - std::string thisConfigFiles; - sep = ""; - for (std::vector<cmSourceFile*>::const_iterator fi = configFiles.begin(); - fi != configFiles.end(); ++fi) - { - thisConfigFiles += sep; - thisConfigFiles += (*fi)->GetFullPath(); - sep = "\n "; - } - std::ostringstream e; - e << "Target \"" << this->Name << "\" has source files which vary by " - "configuration. This is not supported by the \"" - << this->Makefile->GetGlobalGenerator()->GetName() - << "\" generator.\n" - "Config \"" << firstConfig << "\":\n" - " " << firstConfigFiles << "\n" - "Config \"" << *it << "\":\n" - " " << thisConfigFiles << "\n"; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); - return false; - } - } - return true; -} - -//---------------------------------------------------------------------------- void cmTarget::GetSourceFiles(std::vector<cmSourceFile*> &files, const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8dee560..d032380 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -137,8 +137,6 @@ public: */ void GetSourceFiles(std::vector<cmSourceFile*> &files, const std::string& config) const; - bool GetConfigCommonSourceFiles(std::vector<cmSourceFile*>& files) const; - /** * Add sources to the target. */ diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 464a83a..e7716d8 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -965,7 +965,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups() std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups(); std::vector<cmSourceFile*> classes; - if (!this->Target->GetConfigCommonSourceFiles(classes)) + if (!this->GeneratorTarget->GetConfigCommonSourceFiles(classes)) { return; } |