summaryrefslogtreecommitdiffstats
path: root/Source/cmNinjaTargetGenerator.cxx
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2014-02-12 05:00:29 (GMT)
committerBrad King <brad.king@kitware.com>2014-02-13 15:20:56 (GMT)
commit26762e16818749beeaa65149035e17a24cae5b1f (patch)
treef178991ab79e03b150abee0741ba35fcf0a28f3b /Source/cmNinjaTargetGenerator.cxx
parent5104f55d3f9cf2f9b2537364d1b9a5c86d2f790b (diff)
downloadCMake-26762e16818749beeaa65149035e17a24cae5b1f.zip
CMake-26762e16818749beeaa65149035e17a24cae5b1f.tar.gz
CMake-26762e16818749beeaa65149035e17a24cae5b1f.tar.bz2
Ninja: Cache target-level flags
Instead of figuring out target flags per-source file, cache the flags that are being used. This results in a *much* faster generate time for Ninja.
Diffstat (limited to 'Source/cmNinjaTargetGenerator.cxx')
-rw-r--r--Source/cmNinjaTargetGenerator.cxx91
1 files changed, 48 insertions, 43 deletions
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 82f8d1b..900af8d 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -129,15 +129,6 @@ std::string
cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source,
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.
// // Fortran-specific flags computed for this target.
// if(*l == "Fortran")
@@ -145,42 +136,56 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source,
// this->AddFortranFlags(flags);
// }
- // Add shared-library flags if needed.
- this->LocalGenerator->AddCMP0018Flags(flags, this->Target,
- language.c_str(),
- this->GetConfigName());
-
- this->LocalGenerator->AddVisibilityPresetFlags(flags, this->Target,
- language.c_str());
-
- // Add include directory flags.
- const char *config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE");
- {
- std::vector<std::string> includes;
- this->LocalGenerator->GetIncludeDirectories(includes,
- this->GeneratorTarget,
- language.c_str(), config);
- std::string includeFlags =
- this->LocalGenerator->GetIncludeFlags(includes, this->GeneratorTarget,
- language.c_str(),
- language == "RC" ? true : false); // full include paths for RC
- // needed by cmcldeps
- if(cmGlobalNinjaGenerator::IsMinGW())
- cmSystemTools::ReplaceString(includeFlags, "\\", "/");
-
- this->LocalGenerator->AppendFlags(flags, includeFlags.c_str());
- }
-
- // Append old-style preprocessor definition flags.
- this->LocalGenerator->AppendFlags(flags, this->Makefile->GetDefineFlags());
+ bool hasLangCached = this->LanguageFlags.count(language) != 0;
+ std::string& languageFlags = this->LanguageFlags[language];
+ if(!hasLangCached)
+ {
+ this->AddFeatureFlags(languageFlags, language.c_str());
+
+ this->GetLocalGenerator()->AddArchitectureFlags(languageFlags,
+ this->GeneratorTarget,
+ language.c_str(),
+ this->GetConfigName());
+
+ // Add shared-library flags if needed.
+ this->LocalGenerator->AddCMP0018Flags(languageFlags, this->Target,
+ language,
+ this->GetConfigName());
+
+ this->LocalGenerator->AddVisibilityPresetFlags(languageFlags, this->Target,
+ language.c_str());
+
+ std::vector<std::string> includes;
+ this->LocalGenerator->GetIncludeDirectories(includes,
+ this->GeneratorTarget,
+ language.c_str(),
+ this->GetConfigName());
+ // Add include directory flags.
+ std::string includeFlags =
+ this->LocalGenerator->GetIncludeFlags(includes, this->GeneratorTarget,
+ language.c_str(),
+ language == "RC" ? true : false); // full include paths for RC
+ // needed by cmcldeps
+ if(cmGlobalNinjaGenerator::IsMinGW())
+ cmSystemTools::ReplaceString(includeFlags, "\\", "/");
+
+ this->LocalGenerator->AppendFlags(languageFlags, includeFlags.c_str());
+
+ // Append old-style preprocessor definition flags.
+ this->LocalGenerator->AppendFlags(languageFlags,
+ this->Makefile->GetDefineFlags());
+
+ // Add target-specific flags.
+ this->LocalGenerator->AddCompileOptions(languageFlags, this->Target,
+ language.c_str(),
+ this->GetConfigName());
+ }
- // Add target-specific flags.
- this->LocalGenerator->AddCompileOptions(flags, this->Target,
- language.c_str(), config);
+ std::string flags = languageFlags;
- // Add source file specific flags.
- this->LocalGenerator->AppendFlags(flags,
- source->GetProperty("COMPILE_FLAGS"));
+ // Add source file specific flags.
+ this->LocalGenerator->AppendFlags(flags,
+ source->GetProperty("COMPILE_FLAGS"));
// TODO: Handle Apple frameworks.