Greetings CMake users— I’m a long-time CMake user via the ROS (Robot Operating System) community. It’s been interesting to watch over time as certain features which were initially implemented in the ROS 1 buildsystem are now available natively, but this has resulted in some confusion as we map from one to the other.
One area like this is around the building of executables needed for tests. In ROS 1, we had CMake macros which would connect up all test executables as dependencies of a master
tests target, so that you could easily
make tests, and build only the tests and their dependencies, or conversely, avoid/defer building them as part of
ALL (and similarly a
run_tests target for actually invoking the tests). In the next generation system, this has all been removed, and so now the baseline behaviour is that the test executables need to build as part of
ALL, and either be built on every
make, or excluded from being configured at all using a define if you know won’t need to build them later (for example, when doing a build for packaging purposes).
What I am wondering about is whether it would be possible/recommended to use target labels as a way of getting back the ability to exclude these (and potentially other) auxiliary executables from
ALL. It looks like labels have been a long time feature of CMake (going back to at least 3.0), but seem to be mostly used internally by CTest, with the ominous line “Target label semantics are currently unspecified” as most of what’s documented about them.
Is there other documentation or a tutorial I could refer to which would help understand what the behaviour and capability of the labels feature is? For example, can I
set_target_properties(<target_name> LABELS test), and then have some way elsewhere of iterating all the targets and their labels in order to gather a specific set of them in a similar way to how
ctest -L works? Alternatively, is there some other CMake feature capable of grouping targets in this manner which would be helpful to know about?
Thanks in advance!