cmCommonTargetGenerator: Adopt GetDefines method

Move the member up from cmMakefileTargetGenerator so it can be re-used
later by cmNinjaTargetGenerator.
This commit is contained in:
Brad King 2015-07-09 10:10:25 -04:00
parent 0837538e46
commit eacacacdce
4 changed files with 28 additions and 29 deletions

View File

@ -332,3 +332,29 @@ std::string cmCommonTargetGenerator::GetFlags(const std::string &l)
} }
return i->second; return i->second;
} }
std::string cmCommonTargetGenerator::GetDefines(const std::string &l)
{
ByLanguageMap::iterator i = this->DefinesByLanguage.find(l);
if (i == this->DefinesByLanguage.end())
{
std::set<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())
{
this->LocalGenerator->AppendDefines(defines, exportMacro);
}
// Add preprocessor definitions for this target and configuration.
this->LocalGenerator->AddCompileDefinitions(defines, this->Target,
this->LocalGenerator->GetConfigName(), l);
std::string definesString;
this->LocalGenerator->JoinDefines(defines, definesString, lang);
ByLanguageMap::value_type entry(l, definesString);
i = this->DefinesByLanguage.insert(entry).first;
}
return i->second;
}

View File

@ -81,6 +81,8 @@ protected:
typedef std::map<std::string, std::string> ByLanguageMap; typedef std::map<std::string, std::string> ByLanguageMap;
std::string GetFlags(const std::string &l); std::string GetFlags(const std::string &l);
ByLanguageMap FlagsByLanguage; ByLanguageMap FlagsByLanguage;
std::string GetDefines(const std::string &l);
ByLanguageMap DefinesByLanguage;
}; };
#endif #endif

View File

@ -272,32 +272,6 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules()
<< "\n\n"; << "\n\n";
} }
std::string cmMakefileTargetGenerator::GetDefines(const std::string &l)
{
ByLanguageMap::iterator i = this->DefinesByLanguage.find(l);
if (i == this->DefinesByLanguage.end())
{
std::set<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())
{
this->LocalGenerator->AppendDefines(defines, exportMacro);
}
// Add preprocessor definitions for this target and configuration.
this->LocalGenerator->AddCompileDefinitions(defines, this->Target,
this->LocalGenerator->GetConfigName(), l);
std::string definesString;
this->LocalGenerator->JoinDefines(defines, definesString, lang);
ByLanguageMap::value_type entry(l, definesString);
i = this->DefinesByLanguage.insert(entry).first;
}
return i->second;
}
void cmMakefileTargetGenerator::WriteTargetLanguageFlags() void cmMakefileTargetGenerator::WriteTargetLanguageFlags()
{ {
// write language flags for target // write language flags for target

View File

@ -234,9 +234,6 @@ protected:
std::set<std::string> MacContentFolders; std::set<std::string> MacContentFolders;
cmOSXBundleGenerator* OSXBundleGenerator; cmOSXBundleGenerator* OSXBundleGenerator;
MacOSXContentGeneratorType* MacOSXContentGenerator; MacOSXContentGeneratorType* MacOSXContentGenerator;
std::string GetDefines(const std::string &l);
ByLanguageMap DefinesByLanguage;
}; };
#endif #endif