diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index afe557cf3..70e9ce29b 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -284,3 +284,51 @@ std::string cmCommonTargetGenerator::GetFrameworkFlags(std::string const& l) } return flags; } + +//---------------------------------------------------------------------------- +std::string cmCommonTargetGenerator::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(); + + // Add language feature flags. + this->AddFeatureFlags(flags, lang); + + this->LocalGenerator->AddArchitectureFlags(flags, this->GeneratorTarget, + lang, this->ConfigName); + + // Fortran-specific flags computed for this target. + if(l == "Fortran") + { + this->AddFortranFlags(flags); + } + + this->LocalGenerator->AddCMP0018Flags(flags, this->Target, + lang, this->ConfigName); + + this->LocalGenerator->AddVisibilityPresetFlags(flags, this->Target, + lang); + + // Add include directory flags. + this->AddIncludeFlags(flags, lang); + + // Append old-style preprocessor definition flags. + this->LocalGenerator-> + AppendFlags(flags, this->Makefile->GetDefineFlags()); + + // Add framework directory flags. + this->LocalGenerator-> + AppendFlags(flags,this->GetFrameworkFlags(l)); + + // Add target-specific flags. + this->LocalGenerator->AddCompileOptions(flags, this->Target, + lang, this->ConfigName); + + ByLanguageMap::value_type entry(l, flags); + i = this->FlagsByLanguage.insert(entry).first; + } + return i->second; +} diff --git a/Source/cmCommonTargetGenerator.h b/Source/cmCommonTargetGenerator.h index 644d97245..5407c61d6 100644 --- a/Source/cmCommonTargetGenerator.h +++ b/Source/cmCommonTargetGenerator.h @@ -74,6 +74,13 @@ protected: // Return the a string with -F flags on apple std::string GetFrameworkFlags(std::string const& l); + + virtual void AddIncludeFlags(std::string& flags, + std::string const& lang) = 0; + + typedef std::map ByLanguageMap; + std::string GetFlags(const std::string &l); + ByLanguageMap FlagsByLanguage; }; #endif diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 41457393c..10799c6f7 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -272,54 +272,6 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules() << "\n\n"; } -//---------------------------------------------------------------------------- -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(); - - // Add language feature flags. - this->AddFeatureFlags(flags, lang); - - this->LocalGenerator->AddArchitectureFlags(flags, this->GeneratorTarget, - lang, this->ConfigName); - - // Fortran-specific flags computed for this target. - if(l == "Fortran") - { - this->AddFortranFlags(flags); - } - - this->LocalGenerator->AddCMP0018Flags(flags, this->Target, - lang, this->ConfigName); - - this->LocalGenerator->AddVisibilityPresetFlags(flags, this->Target, - lang); - - // Add include directory flags. - this->AddIncludeFlags(flags, lang); - - // Append old-style preprocessor definition flags. - this->LocalGenerator-> - AppendFlags(flags, this->Makefile->GetDefineFlags()); - - // Add framework directory flags. - this->LocalGenerator-> - AppendFlags(flags,this->GetFrameworkFlags(l)); - - // Add target-specific flags. - this->LocalGenerator->AddCompileOptions(flags, this->Target, - lang, this->ConfigName); - - ByLanguageMap::value_type entry(l, flags); - i = this->FlagsByLanguage.insert(entry).first; - } - return i->second; -} - std::string cmMakefileTargetGenerator::GetDefines(const std::string &l) { ByLanguageMap::iterator i = this->DefinesByLanguage.find(l); diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index e3e3a133f..9d05cd5cb 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -235,9 +235,6 @@ protected: cmOSXBundleGenerator* OSXBundleGenerator; MacOSXContentGeneratorType* MacOSXContentGenerator; - typedef std::map ByLanguageMap; - std::string GetFlags(const std::string &l); - ByLanguageMap FlagsByLanguage; std::string GetDefines(const std::string &l); ByLanguageMap DefinesByLanguage; }; diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index cd54c4dce..05120dada 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -110,55 +110,7 @@ std::string cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile const* source, const std::string& language) { - bool hasLangCached = this->LanguageFlags.count(language) != 0; - std::string& languageFlags = this->LanguageFlags[language]; - if(!hasLangCached) - { - this->AddFeatureFlags(languageFlags, language); - - this->GetLocalGenerator()->AddArchitectureFlags(languageFlags, - this->GeneratorTarget, - language, - this->GetConfigName()); - - // Fortran-specific flags computed for this target. - if(language == "Fortran") - { - this->AddFortranFlags(languageFlags); - } - - // Add shared-library flags if needed. - this->LocalGenerator->AddCMP0018Flags(languageFlags, this->Target, - language, - this->GetConfigName()); - - this->LocalGenerator->AddVisibilityPresetFlags(languageFlags, this->Target, - language); - - // Add include directory flags. - this->AddIncludeFlags(languageFlags, language); - - // Append old-style preprocessor definition flags. - this->LocalGenerator->AppendFlags(languageFlags, - this->Makefile->GetDefineFlags()); - - // Add framework directory flags. - this->LocalGenerator-> - AppendFlags(languageFlags, this->GetFrameworkFlags(language)); - - // Add target-specific flags. - this->LocalGenerator->AddCompileOptions(languageFlags, this->Target, - language, - this->GetConfigName()); - } - - std::string flags = languageFlags; - - // Add Fortran format flags. - if(language == "Fortran") - { - this->AppendFortranFormatFlags(flags, *source); - } + std::string flags = this->GetFlags(language); // Add source file specific flags. this->LocalGenerator->AppendFlags(flags, diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index 0cd5e4876..89124316d 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -149,9 +149,6 @@ private: /// List of object files for this target. cmNinjaDeps Objects; std::vector CustomCommands; - - typedef std::map LanguageFlagMap; - LanguageFlagMap LanguageFlags; }; #endif // ! cmNinjaTargetGenerator_h