summaryrefslogtreecommitdiffstats
path: root/Source/cmNinjaTargetGenerator.cxx
diff options
context:
space:
mode:
authorNils Gladitz <nilsgladitz@gmail.com>2016-09-23 20:59:37 (GMT)
committerBrad King <brad.king@kitware.com>2016-09-27 12:11:08 (GMT)
commit144cc6f1f9020433cb4a94f072fc74f1202ce1f3 (patch)
tree5c51f0fdaa1e394456252ea998f6412e4c7826e4 /Source/cmNinjaTargetGenerator.cxx
parenta721830767c6a7819ed82cda5f910b732201f885 (diff)
downloadCMake-144cc6f1f9020433cb4a94f072fc74f1202ce1f3.zip
CMake-144cc6f1f9020433cb4a94f072fc74f1202ce1f3.tar.gz
CMake-144cc6f1f9020433cb4a94f072fc74f1202ce1f3.tar.bz2
Ninja: Add source location as include directory for preprocessed files
Fortran INCLUDE statements are not handled by the preprocessor. Since the location of the preprocessed file is distinct from the original source file explicitly add the source file's directory as an include path in the actual compile step (not the preprocessing step) so INCLUDE can find it. Closes: #16332
Diffstat (limited to 'Source/cmNinjaTargetGenerator.cxx')
-rw-r--r--Source/cmNinjaTargetGenerator.cxx12
1 files changed, 12 insertions, 0 deletions
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index b418ce3..f88eb7b 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -841,6 +841,18 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
// directive.
ppVars["INCLUDES"] = vars["INCLUDES"];
+ // Prepend source file's original directory as an include directory
+ // so e.g. Fortran INCLUDE statements can look for files in it.
+ std::vector<std::string> sourceDirectory;
+ sourceDirectory.push_back(
+ cmSystemTools::GetParentDirectory(source->GetFullPath()));
+
+ std::string sourceDirectoryFlag = this->LocalGenerator->GetIncludeFlags(
+ sourceDirectory, this->GeneratorTarget, language, false, false,
+ this->GetConfigName());
+
+ vars["INCLUDES"] = sourceDirectoryFlag + " " + vars["INCLUDES"];
+
// Explicit preprocessing always uses a depfile.
ppVars["DEP_FILE"] =
cmGlobalNinjaGenerator::EncodeDepfileSpace(ppFileName + ".d");