diff options
author | Brad King <brad.king@kitware.com> | 2011-05-17 12:50:55 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2011-05-17 12:50:55 (GMT) |
commit | 4e2185cbd0d37dd642eefdc3365e8985d8f688c0 (patch) | |
tree | 8c04e6f85fc029a3afb4b6a43c64a76868575138 /Source/cmMakefileTargetGenerator.cxx | |
parent | a7e7a04aafdcb91e13180f421df550418041d9bf (diff) | |
download | CMake-4e2185cbd0d37dd642eefdc3365e8985d8f688c0.zip CMake-4e2185cbd0d37dd642eefdc3365e8985d8f688c0.tar.gz CMake-4e2185cbd0d37dd642eefdc3365e8985d8f688c0.tar.bz2 |
Make std::map usage more portable in language=>flags/defines maps
Older versions of GCC, the HP compiler, and the SGI MIPSpro compiler do
not like the use of make_pair in this case and the conversions it
requires:
a value of type "const char *" cannot be used to initialize an entity
of type "char [1]"
/usr/include/g++-3/stl_pair.h:68: assignment of read-only location
Instead use a map lookup pattern already used throughout the rest of our
source tree.
Diffstat (limited to 'Source/cmMakefileTargetGenerator.cxx')
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 6d3fbe0..d0df8f0 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -249,11 +249,12 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules() } //---------------------------------------------------------------------------- -std::string cmMakefileTargetGenerator::GetFlags(const std::string &l) { - std::pair<std::map<std::string, std::string>::iterator, bool> - insert_result = this->FlagsByLanguage.insert(std::make_pair(l, "")); - if (insert_result.second) { - std::string& flags = insert_result.first->second; +std::string cmMakefileTargetGenerator::GetFlags(const std::string &l) +{ + ByLanguageMap::iterator i = this->FlagsByLanguage.find(l); + if (i == this->FlagsByLanguage.end()) + { + std::string flags; const char *lang = l.c_str(); bool shared = ((this->Target->GetType() == cmTarget::SHARED_LIBRARY) || @@ -284,15 +285,19 @@ std::string cmMakefileTargetGenerator::GetFlags(const std::string &l) { // Add include directory flags. this->LocalGenerator-> AppendFlags(flags,this->GetFrameworkFlags().c_str()); - } - return insert_result.first->second; + + ByLanguageMap::value_type entry(l, flags); + i = this->FlagsByLanguage.insert(entry).first; + } + return i->second; } -std::string cmMakefileTargetGenerator::GetDefines(const std::string &l) { - std::pair<std::map<std::string, std::string>::iterator, bool> - insert_result = this->DefinesByLanguage.insert(std::make_pair(l, "")); - if (insert_result.second) { - std::string &defines = insert_result.first->second; +std::string cmMakefileTargetGenerator::GetDefines(const std::string &l) +{ + ByLanguageMap::iterator i = this->DefinesByLanguage.find(l); + if (i == this->DefinesByLanguage.end()) + { + std::string defines; const char *lang = l.c_str(); // Add the export symbol definition for shared library objects. if(const char* exportMacro = this->Target->GetExportMacro()) @@ -312,8 +317,11 @@ std::string cmMakefileTargetGenerator::GetDefines(const std::string &l) { (defines, this->Makefile->GetProperty(defPropName.c_str()), lang); this->LocalGenerator->AppendDefines (defines, this->Target->GetProperty(defPropName.c_str()), lang); - } - return insert_result.first->second; + + ByLanguageMap::value_type entry(l, defines); + i = this->DefinesByLanguage.insert(entry).first; + } + return i->second; } void cmMakefileTargetGenerator::WriteTargetLanguageFlags() |