summaryrefslogtreecommitdiffstats
path: root/Source/cmNinjaTargetGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-11-06 16:29:58 (GMT)
committerBrad King <brad.king@kitware.com>2020-11-06 16:51:02 (GMT)
commit941be1d3568506351228fcf0627e6ce5fbc92da8 (patch)
tree6ba1730193a168a5fc01741035f842c15ea505b1 /Source/cmNinjaTargetGenerator.cxx
parent33a8e0bb093f33fb0c206c820fe3b3945cae5a78 (diff)
downloadCMake-941be1d3568506351228fcf0627e6ce5fbc92da8.zip
CMake-941be1d3568506351228fcf0627e6ce5fbc92da8.tar.gz
CMake-941be1d3568506351228fcf0627e6ce5fbc92da8.tar.bz2
cmNinjaTargetGenerator: Clarify variable names for preprocessing conditions
What is important about code paths for Fortran's explicit preprocessing is that the compilation step following it does not do preprocessing.
Diffstat (limited to 'Source/cmNinjaTargetGenerator.cxx')
-rw-r--r--Source/cmNinjaTargetGenerator.cxx31
1 files changed, 14 insertions, 17 deletions
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 2b63a09..f2bec8c 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -610,10 +610,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang,
// For some cases we scan to dynamically discover dependencies.
bool const needDyndep = this->NeedDyndep(lang);
- // For some cases we do an explicit preprocessor invocation.
- bool const explicitPP = this->NeedExplicitPreprocessing(lang);
- bool const compilePPWithDefines =
- explicitPP && this->CompileWithDefines(lang);
+ bool const compilationPreprocesses = !this->NeedExplicitPreprocessing(lang);
std::string flags = "$FLAGS";
@@ -672,13 +669,14 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang,
this->GetGlobalGenerator()->AddRule(scanRule);
}
- if (!compilePPWithDefines) {
- // Remove preprocessor definitions from compilation step
- vars.Defines = "";
- }
-
- // Rule to scan dependencies of sources that do not need preprocessing.
{
+ // Compilation will not preprocess, so it does not need the defines
+ // unless the compiler wants them for some other purpose.
+ if (!this->CompileWithDefines(lang)) {
+ vars.Defines = "";
+ }
+
+ // Rule to scan dependencies of sources that do not need preprocessing.
std::string const& scanRuleName = this->LanguageScanRule(lang, config);
std::vector<std::string> scanCommands;
scanCommands.emplace_back(
@@ -735,8 +733,8 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang,
// Tell ninja dependency format so all deps can be loaded into a database
std::string cldeps;
- if (explicitPP) {
- // The explicit preprocessing step will handle dependency scanning.
+ if (!compilationPreprocesses) {
+ // The compiler will not do preprocessing, so it has no such dependencies.
} else if (this->NeedDepTypeMSVC(lang)) {
rule.DepType = "msvc";
rule.DepFile.clear();
@@ -1271,13 +1269,12 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
sourceFileName, objBuild.OrderOnlyDeps);
}
- // For some cases we need to generate a ninja dyndep file.
+ // For some cases we scan to dynamically discover dependencies.
bool const needDyndep = this->NeedDyndep(language);
+ bool const compilationPreprocesses =
+ !this->NeedExplicitPreprocessing(language);
if (needDyndep) {
- // For some cases we do an explicit preprocessor invocation.
- bool const explicitPP = this->NeedExplicitPreprocessing(language);
-
// If source/target has preprocessing turned off, we still need to
// generate an explicit dependency step
const auto srcpp = source->GetSafeProperty("Fortran_PREPROCESS");
@@ -1289,7 +1286,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
preprocess = cmOutputConverter::GetFortranPreprocess(tgtpp);
}
- bool const compilePP = explicitPP &&
+ bool const compilePP = !compilationPreprocesses &&
(preprocess != cmOutputConverter::FortranPreprocess::NotNeeded);
bool const compilePPWithDefines =
compilePP && this->CompileWithDefines(language);