summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/cmNinjaTargetGenerator.cxx28
-rw-r--r--Source/cmNinjaTargetGenerator.h1
3 files changed, 24 insertions, 7 deletions
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 46f7cce..5f6e9bb 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,7 +1,7 @@
# CMake version number components.
set(CMake_VERSION_MAJOR 3)
set(CMake_VERSION_MINOR 15)
-set(CMake_VERSION_PATCH 20190903)
+set(CMake_VERSION_PATCH 20190904)
#set(CMake_VERSION_RC 0)
set(CMake_VERSION_IS_DIRTY 0)
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 29e8b74..90b59e7 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -108,6 +108,13 @@ bool cmNinjaTargetGenerator::UsePreprocessedSource(
return lang == "Fortran";
}
+bool cmNinjaTargetGenerator::CompilePreprocessedSourceWithDefines(
+ std::string const& lang) const
+{
+ return this->Makefile->IsOn(
+ cmStrCat("CMAKE_", lang, "_COMPILE_WITH_DEFINES"));
+}
+
std::string cmNinjaTargetGenerator::LanguageDyndepRule(
const std::string& lang) const
{
@@ -458,12 +465,14 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
vars.ObjectDir = "$OBJECT_DIR";
vars.ObjectFileDir = "$OBJECT_FILE_DIR";
+ cmMakefile* mf = this->GetMakefile();
+
// For some cases we do an explicit preprocessor invocation.
bool const explicitPP = this->NeedExplicitPreprocessing(lang);
+ bool const compilePPWithDefines = this->UsePreprocessedSource(lang) &&
+ this->CompilePreprocessedSourceWithDefines(lang);
bool const needDyndep = this->NeedDyndep(lang);
- cmMakefile* mf = this->GetMakefile();
-
std::string flags = "$FLAGS";
std::string responseFlag;
@@ -517,9 +526,14 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
// Preprocessing and compilation use the same flags.
std::string ppFlags = flags;
- // Move preprocessor definitions to the preprocessor rule.
- ppVars.Defines = vars.Defines;
- vars.Defines = "";
+ if (!compilePPWithDefines) {
+ // Move preprocessor definitions to the preprocessor rule.
+ ppVars.Defines = vars.Defines;
+ vars.Defines = "";
+ } else {
+ // Copy preprocessor definitions to the preprocessor rule.
+ ppVars.Defines = vars.Defines;
+ }
// Copy include directories to the preprocessor rule. The Fortran
// compilation rule still needs them for the INCLUDE directive.
@@ -1011,6 +1025,8 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
ppBuild.RspFile = ppFileName + ".rsp";
bool const compilePP = this->UsePreprocessedSource(language);
+ bool const compilePPWithDefines =
+ compilePP && this->CompilePreprocessedSourceWithDefines(language);
if (compilePP) {
// Move compilation dependencies to the preprocessing build statement.
std::swap(ppBuild.ExplicitDeps, objBuild.ExplicitDeps);
@@ -1039,7 +1055,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
this->LocalGenerator->AppendFlags(vars["FLAGS"], postFlag);
}
- if (compilePP) {
+ if (compilePP && !compilePPWithDefines) {
// Move preprocessor definitions to the preprocessor build statement.
std::swap(ppBuild.Variables["DEFINES"], vars["DEFINES"]);
} else {
diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h
index a99d8e7..e304bc7 100644
--- a/Source/cmNinjaTargetGenerator.h
+++ b/Source/cmNinjaTargetGenerator.h
@@ -70,6 +70,7 @@ protected:
std::string LanguageDyndepRule(std::string const& lang) const;
bool NeedDyndep(std::string const& lang) const;
bool UsePreprocessedSource(std::string const& lang) const;
+ bool CompilePreprocessedSourceWithDefines(std::string const& lang) const;
std::string OrderDependsTargetForTarget();