i know that i can add additional cmake args to my build profile in .catkin_tools
you don't explicitly mention which tool you are using to build your workspace, and I believe that's important here.
The "catkin tutorials" you mention (should that link point to wiki/ROS/Tutorials/CreatingPackage instead?) specifically use catkin_make
.
You appear to use catkin_tools
(or at least, you mention its support for profiles).
Those don't work exactly the same, and one difference is the fact that "top-level CMakeLists.txt
" is not used by catkin_tools
, as it builds every package in your workspace on its own (terminology used is "in isolation"), just as you would when you mkdir build && cmake .. && ... && make install DESTDIR=...
each project in the correct order.
How can i add default cmake items for all of my sub projects? for eg. if i wanted to add set(CMAKE_CXX_STANDARD 17)
for every sub-project? [..] 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.
I'm a bit confused as to how adding those flags to a .yaml
file used by your build tool is less scalable than editing a CMakeLists.txt
(which would contain the same information). And for the specific example you show, the most efficient would be passing -DCMAKE_CXX_STANDARD=17
to the --cmake-args
option of catkin_tools
, which seems like something well suited for using catkin_tools
' configuration profiles.
But to answer your question: catkin_tools
doesn't have any convenience built-in for setting build arguments per-package right now. Per-workspace is supported, exactly through the use of the configurations. Passing --cmake-args -DCMAKE_...
and/or adding those to your profile would be what is supported.
Colcon however does support this: see Colcon: Configuration. Specifically the colcon.pkg and .meta files sections. Using a .pkg
file you can configure build flags to always pass to whichever tool is used to build the package automatically (ie: CMake or something else). Example file (from here):
{
"name": "microxrcedds_client",
"type": "cmake",
"dependencies":[
"microcdr"
],
"cmake-args":[
"-DUCLIENT_ISOLATED_INSTALL=OFF",
"-DUCLIENT_SUPERBUILD=OFF"
]
}
Note the cmake-args
key there.
Colcon will automatically discover these files and apply the settings it finds in them, per-package.
This comes with a trade-off again, as for your copy of a package, you may want to change some flags, but not necessarily commit those.
That's where .meta
files come in (see again the Colcon: Configuration page I linked above): they essentially perform a similar function to the configurations supported by catkin_tools
(so per-workspace configuration), but they also support the same content as the .pkg
files, so it's possible to specify configuration for a subset of the packages in your workspace, including CMake flags, without having to touch any files in the package's directory.
Colcon can be used to build ROS 1 packages as well, but officially it's not completely supported (last time I checked).