Merge topic 'dev/ninja-speedup'

26762e16 Ninja: Cache target-level flags
This commit is contained in:
Brad King 2014-02-13 10:28:32 -05:00 committed by CMake Topic Stage
commit 79bb8cfcf3
2 changed files with 47 additions and 39 deletions

View File

@ -129,15 +129,6 @@ std::string
cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source, cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source,
const std::string& language) const std::string& language)
{ {
std::string flags;
this->AddFeatureFlags(flags, language.c_str());
this->GetLocalGenerator()->AddArchitectureFlags(flags,
this->GeneratorTarget,
language.c_str(),
this->GetConfigName());
// TODO: Fortran support. // TODO: Fortran support.
// // Fortran-specific flags computed for this target. // // Fortran-specific flags computed for this target.
// if(*l == "Fortran") // if(*l == "Fortran")
@ -145,21 +136,31 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source,
// this->AddFortranFlags(flags); // this->AddFortranFlags(flags);
// } // }
// Add shared-library flags if needed. bool hasLangCached = this->LanguageFlags.count(language) != 0;
this->LocalGenerator->AddCMP0018Flags(flags, this->Target, std::string& languageFlags = this->LanguageFlags[language];
if(!hasLangCached)
{
this->AddFeatureFlags(languageFlags, language.c_str());
this->GetLocalGenerator()->AddArchitectureFlags(languageFlags,
this->GeneratorTarget,
language.c_str(), language.c_str(),
this->GetConfigName()); this->GetConfigName());
this->LocalGenerator->AddVisibilityPresetFlags(flags, this->Target, // Add shared-library flags if needed.
this->LocalGenerator->AddCMP0018Flags(languageFlags, this->Target,
language,
this->GetConfigName());
this->LocalGenerator->AddVisibilityPresetFlags(languageFlags, this->Target,
language.c_str()); language.c_str());
// Add include directory flags.
const char *config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE");
{
std::vector<std::string> includes; std::vector<std::string> includes;
this->LocalGenerator->GetIncludeDirectories(includes, this->LocalGenerator->GetIncludeDirectories(includes,
this->GeneratorTarget, this->GeneratorTarget,
language.c_str(), config); language.c_str(),
this->GetConfigName());
// Add include directory flags.
std::string includeFlags = std::string includeFlags =
this->LocalGenerator->GetIncludeFlags(includes, this->GeneratorTarget, this->LocalGenerator->GetIncludeFlags(includes, this->GeneratorTarget,
language.c_str(), language.c_str(),
@ -168,15 +169,19 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source,
if(cmGlobalNinjaGenerator::IsMinGW()) if(cmGlobalNinjaGenerator::IsMinGW())
cmSystemTools::ReplaceString(includeFlags, "\\", "/"); cmSystemTools::ReplaceString(includeFlags, "\\", "/");
this->LocalGenerator->AppendFlags(flags, includeFlags.c_str()); this->LocalGenerator->AppendFlags(languageFlags, includeFlags.c_str());
}
// Append old-style preprocessor definition flags. // Append old-style preprocessor definition flags.
this->LocalGenerator->AppendFlags(flags, this->Makefile->GetDefineFlags()); this->LocalGenerator->AppendFlags(languageFlags,
this->Makefile->GetDefineFlags());
// Add target-specific flags. // Add target-specific flags.
this->LocalGenerator->AddCompileOptions(flags, this->Target, this->LocalGenerator->AddCompileOptions(languageFlags, this->Target,
language.c_str(), config); language.c_str(),
this->GetConfigName());
}
std::string flags = languageFlags;
// Add source file specific flags. // Add source file specific flags.
this->LocalGenerator->AppendFlags(flags, this->LocalGenerator->AppendFlags(flags,

View File

@ -154,6 +154,9 @@ private:
/// List of object files for this target. /// List of object files for this target.
cmNinjaDeps Objects; cmNinjaDeps Objects;
typedef std::map<std::string, std::string> LanguageFlagMap;
LanguageFlagMap LanguageFlags;
// The windows module definition source file (.def), if any. // The windows module definition source file (.def), if any.
std::string ModuleDefinitionFile; std::string ModuleDefinitionFile;
}; };