diff options
author | Cristian Adam <cristian.adam@gmail.com> | 2019-10-05 10:20:37 (GMT) |
---|---|---|
committer | Cristian Adam <cristian.adam@gmail.com> | 2019-10-09 11:50:25 (GMT) |
commit | 36ded610af1bf80304a35491eeb66c34c8e9b7a8 (patch) | |
tree | d41161cbbaafe3ecbe04aefffdc40e9e5adc6fae /Source/cmMakefileTargetGenerator.cxx | |
parent | f1fb63b306ad06a8931ca5a00a2b9ce9e66bc12e (diff) | |
download | CMake-36ded610af1bf80304a35491eeb66c34c8e9b7a8.zip CMake-36ded610af1bf80304a35491eeb66c34c8e9b7a8.tar.gz CMake-36ded610af1bf80304a35491eeb66c34c8e9b7a8.tar.bz2 |
PCH: Generate sources during Compute step
Diffstat (limited to 'Source/cmMakefileTargetGenerator.cxx')
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index d352f8e..51804d2 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -464,6 +464,19 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( // generate the depend scanning rule this->WriteObjectDependRules(source, depends); + std::string config = this->LocalGenerator->GetConfigName(); + std::string configUpper = cmSystemTools::UpperCase(config); + + // Add precompile headers dependencies + const std::string pchSource = + this->GeneratorTarget->GetPchSource(config, lang); + if (!pchSource.empty() && !source.GetProperty("SKIP_PRECOMPILE_HEADERS")) { + depends.push_back(this->GeneratorTarget->GetPchHeader(config, lang)); + if (source.GetFullPath() != pchSource) { + depends.push_back(this->GeneratorTarget->GetPchFile(config, lang)); + } + } + std::string relativeObj = cmStrCat(this->LocalGenerator->GetHomeRelativeOutputPath(), obj); // Write the build rule. @@ -475,8 +488,6 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( std::string langFlags = cmStrCat("$(", lang, "_FLAGS)"); this->LocalGenerator->AppendFlags(flags, langFlags); - std::string config = this->LocalGenerator->GetConfigName(); - std::string configUpper = cmSystemTools::UpperCase(config); cmGeneratorExpressionInterpreter genexInterpreter( this->LocalGenerator, config, this->GeneratorTarget, lang); @@ -506,6 +517,26 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( << "\n"; } + // Add precompile headers compile options. + if (!pchSource.empty() && !source.GetProperty("SKIP_PRECOMPILE_HEADERS")) { + std::string pchOptions; + if (source.GetFullPath() == pchSource) { + pchOptions = + this->GeneratorTarget->GetPchCreateCompileOptions(config, lang); + } else { + pchOptions = + this->GeneratorTarget->GetPchUseCompileOptions(config, lang); + } + + const std::string& evaluatedFlags = + genexInterpreter.Evaluate(pchOptions, COMPILE_OPTIONS); + + this->LocalGenerator->AppendCompileOptions(flags, evaluatedFlags); + *this->FlagFileStream << "# PCH options: " << relativeObj + << "_OPTIONS = " << evaluatedFlags << "\n" + << "\n"; + } + // Add include directories from source file properties. std::vector<std::string> includes; |