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.
This commit is contained in:
parent
a7e7a04aaf
commit
4e2185cbd0
|
@ -249,11 +249,12 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
std::string cmMakefileTargetGenerator::GetFlags(const std::string &l) {
|
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, ""));
|
ByLanguageMap::iterator i = this->FlagsByLanguage.find(l);
|
||||||
if (insert_result.second) {
|
if (i == this->FlagsByLanguage.end())
|
||||||
std::string& flags = insert_result.first->second;
|
{
|
||||||
|
std::string flags;
|
||||||
const char *lang = l.c_str();
|
const char *lang = l.c_str();
|
||||||
|
|
||||||
bool shared = ((this->Target->GetType() == cmTarget::SHARED_LIBRARY) ||
|
bool shared = ((this->Target->GetType() == cmTarget::SHARED_LIBRARY) ||
|
||||||
|
@ -284,15 +285,19 @@ std::string cmMakefileTargetGenerator::GetFlags(const std::string &l) {
|
||||||
// Add include directory flags.
|
// Add include directory flags.
|
||||||
this->LocalGenerator->
|
this->LocalGenerator->
|
||||||
AppendFlags(flags,this->GetFrameworkFlags().c_str());
|
AppendFlags(flags,this->GetFrameworkFlags().c_str());
|
||||||
|
|
||||||
|
ByLanguageMap::value_type entry(l, flags);
|
||||||
|
i = this->FlagsByLanguage.insert(entry).first;
|
||||||
}
|
}
|
||||||
return insert_result.first->second;
|
return i->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string cmMakefileTargetGenerator::GetDefines(const std::string &l) {
|
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, ""));
|
ByLanguageMap::iterator i = this->DefinesByLanguage.find(l);
|
||||||
if (insert_result.second) {
|
if (i == this->DefinesByLanguage.end())
|
||||||
std::string &defines = insert_result.first->second;
|
{
|
||||||
|
std::string defines;
|
||||||
const char *lang = l.c_str();
|
const char *lang = l.c_str();
|
||||||
// Add the export symbol definition for shared library objects.
|
// Add the export symbol definition for shared library objects.
|
||||||
if(const char* exportMacro = this->Target->GetExportMacro())
|
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);
|
(defines, this->Makefile->GetProperty(defPropName.c_str()), lang);
|
||||||
this->LocalGenerator->AppendDefines
|
this->LocalGenerator->AppendDefines
|
||||||
(defines, this->Target->GetProperty(defPropName.c_str()), lang);
|
(defines, this->Target->GetProperty(defPropName.c_str()), lang);
|
||||||
|
|
||||||
|
ByLanguageMap::value_type entry(l, defines);
|
||||||
|
i = this->DefinesByLanguage.insert(entry).first;
|
||||||
}
|
}
|
||||||
return insert_result.first->second;
|
return i->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmMakefileTargetGenerator::WriteTargetLanguageFlags()
|
void cmMakefileTargetGenerator::WriteTargetLanguageFlags()
|
||||||
|
|
|
@ -216,10 +216,11 @@ protected:
|
||||||
std::string MacContentDirectory;
|
std::string MacContentDirectory;
|
||||||
std::set<cmStdString> MacContentFolders;
|
std::set<cmStdString> MacContentFolders;
|
||||||
|
|
||||||
|
typedef std::map<cmStdString, cmStdString> ByLanguageMap;
|
||||||
std::string GetFlags(const std::string &l);
|
std::string GetFlags(const std::string &l);
|
||||||
std::map<std::string, std::string> FlagsByLanguage;
|
ByLanguageMap FlagsByLanguage;
|
||||||
std::string GetDefines(const std::string &l);
|
std::string GetDefines(const std::string &l);
|
||||||
std::map<std::string, std::string> DefinesByLanguage;
|
ByLanguageMap DefinesByLanguage;
|
||||||
|
|
||||||
// Target-wide Fortran module output directory.
|
// Target-wide Fortran module output directory.
|
||||||
bool FortranModuleDirectoryComputed;
|
bool FortranModuleDirectoryComputed;
|
||||||
|
|
Loading…
Reference in New Issue