Makefiles: Regression with add_subdirectory(generated_build_dir generated_build_dir/child)
I have somewhat "weird" setup that worked so far and now breaks with v3.24.0-rc5 (or any rc)
I have a CMake project that generates code in a sub-folder of the build tree (let's call it <build>/Generated
, in practice I have a dozen generated folders). This generated folder is a full C++/CMake based project that is immediately add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/Generated ${CMAKE_CURRENT_BINARY_DIR}/Generated/Build)
after generation in the main project. So I have a generated sub-dir in the binary dir and its associated binary dir as a sub-folder of itself.
I now get the following error: gmake[1]: *** No rule to make target 'Generated/Build/all', needed by 'all'. Stop.
This only happens:
- With CMake 3.24.0-rc# (3.23.3 is fine)
- With "Unix Makefiles" (Ninja is fine)
- On my CI which is a Debian container, I've not yet managed to reproduce the issue on my dev setup.
I've found a workaround: placing the associated binary dir alongside the generated dir instead of being a child. So add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/Generated ${CMAKE_CURRENT_BINARY_DIR}/Generated_build)
still works correctly.