I have a workspace set out as in the ROS REP 128 aka:
catkin_ws
src
CMakeLists.txt // < 1.
project_1
CMakeLists.txt
project_2
CMakeLists.txt
...
In fact you can reproduce this using just the catkin tutorials here. The top level CMakeLists.txt
(1.
in the example above) appears to not be sourced. I can tell this because i added the line, weifnbwefn
to the end of it expecting a cmake error (on a clean build) but got none.
To reproduce this:
catkin_tutorials/create_package_pubsub/catkin_ws
src/CMakeLists.txt
with something that won't build.catkin build
So this leads to 2 questions:
set(CMAKE_CXX_STANDARD 17)
for every sub-project?For 2. , i know that i can add additional cmake args to my build profile in .catkin_tools
but for anything more complex then a couple of arguments, this would not be scaleable.
My understanding from the docs is that the src/CMakeLists.txt
is intended to be a symlink to catkin/cmake/toplevel.cmake
in the ROS installation and not be edited. It is only used if CMake is driving the legacy build workflow.
The new workflow, which catkin build
implements, ignores this file specifically to isolate the builds and prevent cross-talk from one package setting CMake cache variables another reads.
So that answers part (1), but regrettably I am not experienced enough with catkin to know what the best practice is to store common configuration. I do know that there is a --cmake-args
flag to catkin build
that you could use in tandem with the CMAKE_PROJECT_INCLUDE
variable to inject a CMake file containing your settings.
For C++17 specifically, this would look like:
$ catkin build --cmake-args -DCMAKE_CXX_STANDARD=17
See the docs for this here: https://catkin-tools.readthedocs.io/en/latest/verbs/catkin_build.html#temporarily-changing-build-flags