From 1aa28f3b92bd5655c939fe99d54039d7dd9c4b6c Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 26 Dec 2023 14:45:53 -0500 Subject: 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 --- Source/cmNinjaTargetGenerator.cxx | 9 +++++++++ 1 file changed, 9 insertions(+) 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()); -- cgit v0.12