We have a number of different CMake projects, each representing a set of tests for our code. Each project uses the same build target names (preprocess
, compute
, postprocess
and others) to perform said steps of the set of tests.
Now, I’m having some difficulty to properly tie this collection of projects into an overall suite of tests with CMake. I have explored the option to repeatedly use add_subdirectory
, but then I get an error about duplicate target names and CMP0002. While this can be circumvented by setting ALLOW_DUPLICATE_CUSTOM_TARGETS
, this does not work with other build tools then Makefiles. Furthermore, dependencies of sub-level targets with the same name on a top-level target is not handled correctly: if the target preprocess
in subdirs Test1 Test2 and Test3 all depend on the top-level target all_preprocess
, executing make all_preprocess
will only make the last preprocess
target added to its dependencies.
The other option is to sever the connection between the top-level directory and the sub-level directories, and have the top-level CMake project execute cmake
, and each build target as a loop over the sub-level directories. This works as expected with both Makefiles and Ninja, but then I loose the ability to execute sub-level build steps in parallel.
To summarize: I’m looking for a way to build targets in sub-level directories with the same name in each sub-directory
a) with Makefiles and Ninja, and
b) with sub-level directory parallelism, i.e. executing Test1/preprocess
, Test2/preprocess
and Test3/preprocess
in parallel, when invoking the top-level target all_preprocess
Any hints how to do this, or where to find documentation, or examples of other similar projects are much appreciated