I’m using NixOS, and the issue goes away if I build unsandboxed, in a develop shell, or with --keep-failed. If I use breakpointHook (as suggested in Build breaks, but only *without* --keep-failed) then sure enough the path is missing. The issue seems to also just go away on its own sometimes, even retrying the build immediately afterward. So it seems like it must be something racy, but I’m at a bit of a loss for how to make headway on it.
Unfortunately, this doesn’t change anything for me, since my package isn’t actually using the cmake-provided configurePhase. I’m using a custom Nix package builder which builds these packages using colcon, which is helpful for my scenario since colcon is also the workspace development tool, so there’s greater development/packaging consistency without forcing my users to directly work with Nix.
Since it definitely does seem to come up specifically in the cmake-within-cmake case, I may try to put together a MWE of that scenario and see if I can stimulate the issue to manifest.
Agree in general! This is a bit of a special case as it’s an x86 “package” that wraps up some scripts and helper binaries with an ARM Cortex firmware— and the firmware is what’s built in the inner project.
It may well be possible to do this purely with add_subdirectory, but at this point it’s what’s worked for my org, and we’re just confused why it would fail to build on Nix.
Time to close the loop here! Turns out this wasn’t a CMake issue at all, but rather one with the Makefile that came with the bootloader we were using. Which, as it turns out, is open source— the problem is here:
The creation of the BUILDDIRS directories is a dependency of the final elf target, but not of the intermediate .o targets. Thanks for the suggestions and patience!