My project is not large, but we do build about 100 executables. These executables come in a handful of different types: daemons, tools, tests, filters, etc. Usually, all the executable targets of a certain type share the same CMake properties, so I’d like to be able to default these once per type. But there doesn’t appear to be a good way to do this in CMake.
Today I do this with wrapper functions for add_executable, like add_daemon_executable, etc. But this doesn’t feel properly “modern” CMake. There is great debate in our group whether wrapping CMake functions like this is good software abstraction process, or if it represents shortcoming in the CMake system. I don’t want to set these properties globally, and the types of executables are not represented in the source tree – there’s not one interior node in the tree for “daemons”.
Seems like the “modern CMake target-based way” should be to have an “executables (plural)” kind of target that is a container of other executables, that can have properties set on it, which flow down to dependent executables, much like library targets. If you think of a CMake target as an object, this would be similar to having inheritance between objects. But I don’t see a way to do this with executables.
What’s the best practice for sharing common properties between executables of similar types?