Prologue
I have a preset-based plain CMake project so that I can build and test it with cmake --preset $PRESET && cmake --build --preset $PRESET && ctest --preset $PRESET
. Note that it nicely interacts with Microsoft's CMake Tools extension for Visual Studio Code, be it for building, testing, debugging and Intellisense.
Since I want to handle multiple presets in parallel, I set CMakePresets.json
's binaryDir
property to ${sourceDir}/build/${presetName}/
.
Issue
I want to also build this plain CMake project with colcon. colcon build --cmake-args "--preset $PRESET"
doesn't work, though, as it produces
WARNING:colcon.colcon_cmake.task.cmake.build:Could not build CMake package 'root_project_name' because the CMake cache has no 'CMAKE_PROJECT_NAME' variable
root_project_name
being the argument to CMake's project()
command in the top CMakeLists.txt
.
How can I resolve this warning and the subsequent build failure?