diff options
author | Alexander Neundorf <neundorf@kde.org> | 2007-07-11 21:29:27 (GMT) |
---|---|---|
committer | Alexander Neundorf <neundorf@kde.org> | 2007-07-11 21:29:27 (GMT) |
commit | 16705a3e87f3f8a877b5fe8dc1e953c7abca4da3 (patch) | |
tree | b0d172432a933f384da65b00d0ff031ff2f39b41 /Source/cmTarget.cxx | |
parent | bea1a5de771832463299146b4f2e4317c37f30bc (diff) | |
download | CMake-16705a3e87f3f8a877b5fe8dc1e953c7abca4da3.zip CMake-16705a3e87f3f8a877b5fe8dc1e953c7abca4da3.tar.gz CMake-16705a3e87f3f8a877b5fe8dc1e953c7abca4da3.tar.bz2 |
COMP: revert last commit for now, broke Visual Studio
Alex
Diffstat (limited to 'Source/cmTarget.cxx')
-rw-r--r-- | Source/cmTarget.cxx | 84 |
1 files changed, 43 insertions, 41 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 40132a5..70d0035 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -1477,57 +1477,59 @@ const char* cmTarget::GetLinkerLanguage(cmGlobalGenerator* gg) const_cast<cmTarget*>(this)->SetProperty("LINKER_LANGUAGE", "CXX"); } const char* linkerLang = this->GetProperty("LINKER_LANGUAGE"); - if (linkerLang==0) + if(linkerLang) { - // if the property has not yet been set, collect all languages in the - // target and then find the language with the highest preference value - std::set<cmStdString> languages; - for(std::vector<cmSourceFile*>::const_iterator - i = this->SourceFiles.begin(); i != this->SourceFiles.end(); ++i) + return linkerLang; + } + std::set<cmStdString> languages; + for(std::vector<cmSourceFile*>::const_iterator i + = this->SourceFiles.begin(); + i != this->SourceFiles.end(); ++i) + { + if(const char* lang = (*i)->GetLanguage()) { - if(const char* lang = (*i)->GetLanguage()) - { - languages.insert(lang); - } + languages.insert(lang); } - - std::string linkerLangList; // only used for the error message - int maxLinkerPref = 0; - bool multiplePreferedLanguages = false; - for(std::set<cmStdString>::const_iterator sit = languages.begin(); - sit != languages.end(); ++sit) + } + if(languages.size() == 0) + { + return 0; + } + if(languages.size() == 1) + { + const_cast<cmTarget*>(this)->SetProperty("LINKER_LANGUAGE", + languages.begin()->c_str()); + return this->GetProperty("LINKER_LANGUAGE"); + } + const char* prefLang = 0; + for(std::set<cmStdString>::const_iterator s = languages.begin(); + s != languages.end(); ++s) + { + const char* lpref = gg->GetLinkerPreference(s->c_str()); + if(lpref[0] == 'P') { - int linkerPref = gg->GetLinkerPreference(sit->c_str()); - if ((linkerPref > maxLinkerPref) || (linkerLang==0)) + if(prefLang && !(*s == prefLang)) { - maxLinkerPref = linkerPref; - linkerLang = sit->c_str(); - linkerLangList = *sit; - multiplePreferedLanguages = false; + std::string m = "Error Target: "; + m += this->Name + " Contains more than one Prefered language: "; + m += *s; + m += " and "; + m += prefLang; + m += "\nYou must set the LINKER_LANGUAGE property for this target."; + cmSystemTools::Error(m.c_str()); } - else if (linkerPref == maxLinkerPref) + else { - linkerLangList += "; "; - linkerLangList += *sit; - multiplePreferedLanguages = true; + prefLang = s->c_str(); } } - - if (linkerLang!=0) - { - const_cast<cmTarget*>(this)->SetProperty("LINKER_LANGUAGE", linkerLang); - } - if (multiplePreferedLanguages) - { - cmOStringStream err; - err << "Error: Target " << this->Name << " contains multiple languages " - << "with the highest linker preference (" << maxLinkerPref << "): " - << linkerLangList << "\n" - << "You must set the LINKER_LANGUAGE property for this target."; - cmSystemTools::Error(err.str().c_str()); - } } - return linkerLang; + if(!prefLang) + { + prefLang = languages.begin()->c_str(); + } + const_cast<cmTarget*>(this)->SetProperty("LINKER_LANGUAGE", prefLang); + return this->GetProperty("LINKER_LANGUAGE"); } //---------------------------------------------------------------------------- |