My project has quite a few build time configurations with multiple possible values for each. I have a small python wrapper around cmake to execute builds. I would like to add the build step itself as a test in ctest. Is it possible to have parameterized configuration values for cmake. What would be the preferred way to handle this.
I don’t know about “preferred” as there is a bunch of “taste” involved in such determinations. Personally, I’ve found something like VTK’s examples to be a scalable pattern (it supports running as part of the main build or as a standalone top-level directory).
Thanks for the reply. Examples are indeed useful. One additional thing, what I meant by parameterized configurations, was if we specify multiple values for a couple of configuration variables (-DCONFIG=CONFIG1;CONFIG2) is there a way where the build and test is done separately for both these values. If there are 2 such configurations accepting 2 values each, with a single ctest command can we have instances of build and run for each combination of configurations
CMake does not support such “cross-product” builds natively. You’ll need to do
for loops to generate a build for each wanted combination. Note that you can do this in CMake code, but it gets very complicated very fast (namely when making non-overlapping targets while also supporting conditionally building some axes).
Thanks for the reply Ben. Was hoping if this was an issue faced by others and if they had a nicer way of handling cross products. In my case, product space is already quite big, and as you mentioned conditional supports etc will make it quite complex. Not sure if ctest would be the best way forward in this case
foreach loops around
add_test is far simpler to deal with than around
add_library. With labels and name matching, running subsets should also be pretty easy from the command line.