summaryrefslogtreecommitdiff
path: root/Source/cmGeneratorExpressionEvaluationFile.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-04-25 10:53:15 -0400
committerBrad King <brad.king@kitware.com>2018-04-26 08:39:44 -0400
commit0826c20128fad20aafac2006ac0371e381e3cf60 (patch)
treecc57f74801d1c8a6c37daac376056fe14dc97363 /Source/cmGeneratorExpressionEvaluationFile.cxx
parentfbe6cd1596bf280edd49aeb8f981f99d7cd8beb3 (diff)
downloadcmake-0826c20128fad20aafac2006ac0371e381e3cf60.tar.gz
Ninja: Do not add empty custom command for file(GENERATE) outputs
Internally we mark `file(GENERATE)` outputs as `GENERATED` in order to tell custom command dependency tracing logic not to expect the files to exist on disk yet. This is because we do not generate the files until after that tracing is done. The Ninja generator also interprets the `GENERATED` property to mean that it is expected that some build rule will generate the file if another build rule depends on it. If the generator does not know of a custom command that generates the file then it adds an empty one so that the `ninja` build tool does not complain about a dependency on a file that does not exist and has no rule to generate it. However, this step is not necessary for `file(GENERATE)` outputs because there is no build rule to generate them and they will exist before `ninja` runs. Add an additional `__CMAKE_GENERATED_BY_CMAKE` property internally to tell the Ninja generator that a `GENERATED` file will exist before the build starts and is not expected to have a build rule producing it. Fixes: #17942
Diffstat (limited to 'Source/cmGeneratorExpressionEvaluationFile.cxx')
-rw-r--r--Source/cmGeneratorExpressionEvaluationFile.cxx6
1 files changed, 6 insertions, 0 deletions
diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx
index c544141932..99b926126f 100644
--- a/Source/cmGeneratorExpressionEvaluationFile.cxx
+++ b/Source/cmGeneratorExpressionEvaluationFile.cxx
@@ -105,8 +105,14 @@ void cmGeneratorExpressionEvaluationFile::CreateOutputFile(
lg, config, false, nullptr, nullptr, nullptr, le);
cmSourceFile* sf = lg->GetMakefile()->GetOrCreateSource(
name, false, cmSourceFileLocationKind::Known);
+ // Tell TraceDependencies that the file is not expected to exist
+ // on disk yet. We generate it after that runs.
sf->SetProperty("GENERATED", "1");
+ // Tell the build system generators that there is no build rule
+ // to generate the file.
+ sf->SetProperty("__CMAKE_GENERATED_BY_CMAKE", "1");
+
gg->SetFilenameTargetDepends(
sf, this->OutputFileExpr->GetSourceSensitiveTargets());
}