Large software projects can almost always be logically divided into distinct yet interrelated components. At Kitware, we refer to such components as subprojects. CDash has long supported the notion of subprojects, but up until now it has been a bit tricky to use this feature. Fear not, now it is easier than ever!
Previously, clients submitting to CDash needed to build and test each subproject separately. New features in CMake 3.10 and CDash 2.6 allow you to build and test your whole project at once while still splitting the results across subprojects. Here’s how to do it!
Step 1: In your project’s CMakeLists.txt files, use a label to represent each subproject.
It’s likely that your subprojects are already organized into separate subdirectories in your source code repository. In this case, you can easily set a label on each directory.
This causes any targets or tests declared in this directory or its subdirectories to inherit the label mysubproj1.
If your subprojects are not organized into separate directories you should instead assign a label to each target and test.
add_test(NAME foo COMMAND foo)
set_property(TARGET foo PROPERTY LABELS mysubproj1)
set_property(TEST foo PROPERTY LABELS mysubproj1)
Step 2: tell CDash which labels represent subprojects.
Labels are a general feature in CMake that can be used for purposes other than subprojects. For this reason, you need to explicitly tell CDash which labels should be treated as subprojects. To do this, set the CTEST_LABELS_FOR_SUBPROJECTS variable in your CTestConfig.cmake file.
set(CTEST_LABELS_FOR_SUBPROJECTS mysubproj1 mysubproj2)
Step 3: build and test your project as normal.
The beauty of the all-at-once subproject approach is that you don’t need to change your CTest driver script to reap the benefits of a subproject dashboard.
After you’ve set up your labels and CTEST_LABELS_FOR_SUBPROJECTS you should be able to build and test your project as normal.
Download and run the example
You may want to modify build_and_test.cmake to change the build name, site name, or type of generator to use. Once you’re satisfied, you can run an example build.
ctest -VV -S build_and_test.cmake
View the results here: