summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2024-01-06 15:12:34 (GMT)
committerBen Boeckel <ben.boeckel@kitware.com>2024-01-06 16:07:52 (GMT)
commitde3dc16b64188a18b3607939f336525ce955589e (patch)
tree15503870a6250c82e4da6908d290db6333315368
parent1aa28f3b92bd5655c939fe99d54039d7dd9c4b6c (diff)
downloadCMake-de3dc16b64188a18b3607939f336525ce955589e.zip
CMake-de3dc16b64188a18b3607939f336525ce955589e.tar.gz
CMake-de3dc16b64188a18b3607939f336525ce955589e.tar.bz2
cmNinjaTargetGenerator: use `.` for the needed phony order-only dependency
It is only required for Ninja < 1.7 though.
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx8
-rw-r--r--Source/cmGlobalNinjaGenerator.h3
-rw-r--r--Source/cmNinjaTargetGenerator.cxx16
3 files changed, 21 insertions, 6 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 55eb9b5..74a6bea 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -828,6 +828,9 @@ void cmGlobalNinjaGenerator::CheckNinjaFeatures()
this->NinjaExpectedEncoding = codecvt_Encoding::ANSI;
}
#endif
+ this->NinjaSupportsCWDDepend =
+ !cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, this->NinjaVersion,
+ RequiredNinjaVersionForCWDDepend());
}
void cmGlobalNinjaGenerator::CheckNinjaCodePage()
@@ -1996,6 +1999,11 @@ bool cmGlobalNinjaGenerator::SupportsMultilineDepfile() const
return this->NinjaSupportsMultilineDepfile;
}
+bool cmGlobalNinjaGenerator::SupportsCWDDepend() const
+{
+ return this->NinjaSupportsCWDDepend;
+}
+
bool cmGlobalNinjaGenerator::WriteTargetCleanAdditional(std::ostream& os)
{
const auto& lgr = this->LocalGenerators.at(0);
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index 3443643..64eed4d 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -415,10 +415,12 @@ public:
return "1.10.2";
}
static std::string RequiredNinjaVersionForCodePage() { return "1.11"; }
+ static std::string RequiredNinjaVersionForCWDDepend() { return "1.7"; }
bool SupportsDirectConsole() const override;
bool SupportsImplicitOuts() const;
bool SupportsManifestRestat() const;
bool SupportsMultilineDepfile() const;
+ bool SupportsCWDDepend() const;
std::string NinjaOutputPath(std::string const& path) const;
bool HasOutputPathPrefix() const { return !this->OutputPathPrefix.empty(); }
@@ -597,6 +599,7 @@ private:
bool NinjaSupportsMultipleOutputs = false;
bool NinjaSupportsMetadataOnRegeneration = false;
bool NinjaSupportsCodePage = false;
+ bool NinjaSupportsCWDDepend = false;
codecvt_Encoding NinjaExpectedEncoding = codecvt_Encoding::None;
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 016705e..1f94569 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -1023,7 +1023,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements(
}
}
- {
+ if (!this->GetGlobalGenerator()->SupportsCWDDepend()) {
// Ensure that the object directory exists. If there are no objects in the
// target (e.g., an empty `OBJECT` library), the directory is still listed
// as an order-only depends in the build files. Alternate `ninja`
@@ -1106,11 +1106,15 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements(
// that "output ... of phony edge with no inputs doesn't exist" and
// consider the phony output "dirty".
if (orderOnlyDeps.empty()) {
- // Any path that always exists will work here. It would be nice to
- // use just "." but that is not supported by Ninja < 1.7.
- std::string tgtDir = cmStrCat(
- this->LocalGenerator->GetCurrentBinaryDirectory(), '/',
- this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget));
+ std::string tgtDir;
+ if (this->GetGlobalGenerator()->SupportsCWDDepend()) {
+ tgtDir = ".";
+ } else {
+ // Any path that always exists will work here.
+ tgtDir = cmStrCat(
+ this->LocalGenerator->GetCurrentBinaryDirectory(), '/',
+ this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget));
+ }
orderOnlyDeps.push_back(this->ConvertToNinjaPath(tgtDir));
}