summaryrefslogtreecommitdiff
path: root/Source/cmMakefileTargetGenerator.cxx
diff options
context:
space:
mode:
authorCristian Adam <cristian.adam@gmail.com>2019-10-05 12:20:37 +0200
committerCristian Adam <cristian.adam@gmail.com>2019-10-09 13:50:25 +0200
commit36ded610af1bf80304a35491eeb66c34c8e9b7a8 (patch)
treed41161cbbaafe3ecbe04aefffdc40e9e5adc6fae /Source/cmMakefileTargetGenerator.cxx
parentf1fb63b306ad06a8931ca5a00a2b9ce9e66bc12e (diff)
downloadcmake-36ded610af1bf80304a35491eeb66c34c8e9b7a8.tar.gz
PCH: Generate sources during Compute step
Diffstat (limited to 'Source/cmMakefileTargetGenerator.cxx')
-rw-r--r--Source/cmMakefileTargetGenerator.cxx35
1 files changed, 33 insertions, 2 deletions
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index d352f8eb49..51804d2873 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;