summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2023-12-26 19:45:53 (GMT)
committerBen Boeckel <ben.boeckel@kitware.com>2024-01-06 14:56:40 (GMT)
commit1aa28f3b92bd5655c939fe99d54039d7dd9c4b6c (patch)
tree2d3d3acc139016d43a4bbb28cf493cb6e787941b /Source
parent4a9613ff9b8c8b4e20c1fe1423b31d815b84aa94 (diff)
downloadCMake-1aa28f3b92bd5655c939fe99d54039d7dd9c4b6c.zip
CMake-1aa28f3b92bd5655c939fe99d54039d7dd9c4b6c.tar.gz
CMake-1aa28f3b92bd5655c939fe99d54039d7dd9c4b6c.tar.bz2
cmNinjaTargetGenerator: ensure that the object output directory exists
If a target has no object compilations within it, nothing ensures that the directory exists yet it is still mentioned as an order-only dependency within the build files. While `ninja` is OK with this, `samu`, an alternate `ninja` implementation, is not. Make sure the directory always exists for consistency. Fixes: #25526
Diffstat (limited to 'Source')
-rw-r--r--Source/cmNinjaTargetGenerator.cxx9
1 files changed, 9 insertions, 0 deletions
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 1f7aaaf..016705e 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -1024,6 +1024,15 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements(
}
{
+ // 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`
+ // implementations may not allow this (such as `samu`). See #25526.
+ auto const objectDir = this->GetObjectFileDir(config);
+ this->EnsureDirectoryExists(objectDir);
+ }
+
+ {
cmNinjaBuild build("phony");
build.Comment =
cmStrCat("Order-only phony target for ", this->GetTargetName());