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:32 (GMT) |
commit | 69329fff70300debf10b62ac08a6bcee9ae7bc3c (patch) | |
tree | 782390e19f3c69c3ed07fdfeacbcbeaaa683007f /Source | |
parent | 0431f2c4d7cbfcd873bc34caee9ed09253e8c8ad (diff) | |
download | CMake-69329fff70300debf10b62ac08a6bcee9ae7bc3c.zip CMake-69329fff70300debf10b62ac08a6bcee9ae7bc3c.tar.gz CMake-69329fff70300debf10b62ac08a6bcee9ae7bc3c.tar.bz2 |
cmGeneratorTarget: Move GetLanguages from cmTarget.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 53 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.h | 8 | ||||
-rw-r--r-- | Source/cmGlobalUnixMakefileGenerator3.cxx | 3 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudioGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator3.cxx | 4 | ||||
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 44 | ||||
-rw-r--r-- | Source/cmTarget.h | 8 |
9 files changed, 71 insertions, 59 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 22b1baf..4ada029 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -4416,6 +4416,57 @@ cmGeneratorTarget::GetLinkImplementation(const std::string& config) const } //---------------------------------------------------------------------------- +void cmGeneratorTarget::GetLanguages(std::set<std::string>& languages, + const std::string& config) const +{ + std::vector<cmSourceFile*> sourceFiles; + this->Target->GetSourceFiles(sourceFiles, config); + for(std::vector<cmSourceFile*>::const_iterator + i = sourceFiles.begin(); i != sourceFiles.end(); ++i) + { + const std::string& lang = (*i)->GetLanguage(); + if(!lang.empty()) + { + languages.insert(lang); + } + } + + std::vector<cmGeneratorTarget*> objectLibraries; + std::vector<cmSourceFile const*> externalObjects; + if (!this->Makefile->IsConfigured()) + { + std::vector<cmTarget*> objectTargets; + this->Target->GetObjectLibrariesCMP0026(objectTargets); + objectLibraries.reserve(objectTargets.size()); + for (std::vector<cmTarget*>::const_iterator it = objectTargets.begin(); + it != objectTargets.end(); ++it) + { + objectLibraries.push_back(this->GlobalGenerator + ->GetGeneratorTarget(*it)); + } + } + else + { + this->GetExternalObjects(externalObjects, config); + for(std::vector<cmSourceFile const*>::const_iterator + i = externalObjects.begin(); i != externalObjects.end(); ++i) + { + std::string objLib = (*i)->GetObjectLibrary(); + if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLib)) + { + objectLibraries.push_back(this->GlobalGenerator + ->GetGeneratorTarget(tgt)); + } + } + } + for(std::vector<cmGeneratorTarget*>::const_iterator + i = objectLibraries.begin(); i != objectLibraries.end(); ++i) + { + (*i)->GetLanguages(languages, config); + } +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::ComputeLinkImplementationLanguages( const std::string& config, cmOptionalLinkImplementation& impl) const @@ -4423,7 +4474,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLanguages( // This target needs runtime libraries for its source languages. std::set<std::string> languages; // Get languages used in our source files. - this->Target->GetLanguages(languages, config); + this->GetLanguages(languages, config); // Copy the set of langauges to the link implementation. impl.Languages.insert(impl.Languages.begin(), languages.begin(), languages.end()); diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index f5dc20d..5f96f2a 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -205,6 +205,14 @@ public: cmOptionalLinkImplementation& impl ) const; + // Compute the set of languages compiled by the target. This is + // computed every time it is called because the languages can change + // when source file properties are changed and we do not have enough + // information to forward these property changes to the targets + // until we have per-target object file properties. + void GetLanguages(std::set<std::string>& languages, + std::string const& config) const; + bool HaveBuildTreeRPATH(const std::string& config) const; /** Full path with trailing slash to the top-level directory diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index b240924..331caad 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -1134,7 +1134,8 @@ bool cmGlobalUnixMakefileGenerator3 ::NeedRequiresStep(cmTarget const& target) { std::set<std::string> languages; - target.GetLanguages(languages, + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&target); + gtgt->GetLanguages(languages, target.GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE")); for(std::set<std::string>::const_iterator l = languages.begin(); l != languages.end(); ++l) diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 634366e..9b1f4c2 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -836,6 +836,8 @@ void RegisterVisualStudioMacros(const std::string& macrosFile, bool cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target) { + cmGeneratorTarget* gt = this->GetGeneratorTarget(&target); + // check to see if this is a fortran build std::set<std::string> languages; { @@ -846,7 +848,7 @@ cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target) return false; } } - target.GetLanguages(languages, ""); + gt->GetLanguages(languages, ""); if(languages.size() == 1) { if(*languages.begin() == "Fortran") diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 68fd06b..4511de5 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1805,7 +1805,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, // Compute the compilation flags for each language. std::set<std::string> languages; - target.GetLanguages(languages, configName); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); + gtgt->GetLanguages(languages, configName); std::map<std::string, std::string> cflags; for (std::set<std::string>::iterator li = languages.begin(); li != languages.end(); ++li) @@ -1827,7 +1828,6 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, AddCompileOptions(flags, &target, lang, configName); } - cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); std::string llang = gtgt->GetLinkerLanguage(configName); if(binary && llang.empty()) { diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index ce370bc..589105e 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1257,7 +1257,9 @@ cmLocalUnixMakefileGenerator3 { // Get the set of source languages in the target. std::set<std::string> languages; - target.GetLanguages(languages, + cmGeneratorTarget *gtgt = + this->GlobalGenerator->GetGeneratorTarget(&target); + gtgt->GetLanguages(languages, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); fout << "\n" << "# Per-language clean rules from dependency scanning.\n" diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 0b3df90..cf88a74 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -276,7 +276,7 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags() { // write language flags for target std::set<std::string> languages; - this->Target->GetLanguages(languages, + this->GeneratorTarget->GetLanguages(languages, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); // put the compiler in the rules.make file so that if it changes // things rebuild diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index f395c45..8a21269 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3131,50 +3131,6 @@ cmTarget::GetObjectLibrariesCMP0026(std::vector<cmTarget*>& objlibs) const } //---------------------------------------------------------------------------- -void cmTarget::GetLanguages(std::set<std::string>& languages, - const std::string& config) const -{ - std::vector<cmSourceFile*> sourceFiles; - this->GetSourceFiles(sourceFiles, config); - for(std::vector<cmSourceFile*>::const_iterator - i = sourceFiles.begin(); i != sourceFiles.end(); ++i) - { - const std::string& lang = (*i)->GetLanguage(); - if(!lang.empty()) - { - languages.insert(lang); - } - } - - std::vector<cmTarget*> objectLibraries; - std::vector<cmSourceFile const*> externalObjects; - if (!this->Makefile->IsConfigured()) - { - this->GetObjectLibrariesCMP0026(objectLibraries); - } - else - { - cmGeneratorTarget* gt = this->Makefile->GetGlobalGenerator() - ->GetGeneratorTarget(this); - gt->GetExternalObjects(externalObjects, config); - for(std::vector<cmSourceFile const*>::const_iterator - i = externalObjects.begin(); i != externalObjects.end(); ++i) - { - std::string objLib = (*i)->GetObjectLibrary(); - if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLib)) - { - objectLibraries.push_back(tgt); - } - } - } - for(std::vector<cmTarget*>::const_iterator - i = objectLibraries.begin(); i != objectLibraries.end(); ++i) - { - (*i)->GetLanguages(languages, config); - } -} - -//---------------------------------------------------------------------------- cmTarget::ImportInfo const* cmTarget::GetImportInfo(const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 1db4ba1..8dee560 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -305,14 +305,6 @@ public: If no macro should be defined null is returned. */ const char* GetExportMacro() const; - // Compute the set of languages compiled by the target. This is - // computed every time it is called because the languages can change - // when source file properties are changed and we do not have enough - // information to forward these property changes to the targets - // until we have per-target object file properties. - void GetLanguages(std::set<std::string>& languages, - std::string const& config) const; - /** Return whether this target is an executable with symbol exports enabled. */ bool IsExecutableWithExports() const; |