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
This commit is contained in:
Ben Boeckel
2023-12-26 14:45:53 -05:00
parent 4a9613ff9b
commit 1aa28f3b92

View File

@@ -1023,6 +1023,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 =