CMake CTest single command build and test
Many CMake users have muscle memory for the three-stanza configure, build, test with CMake:
cmake -B build
# configure CMake and generate build files
cmake --build build
# compile and link binaries
ctest --test-dir build
# run program self-tests
This can be reduced to a single command for many programs:
ctest -S setup.cmake
where a single file setup.cmake is added to the project.
Command-line options like “-Dvar=yes” must be aggregated and passed along to ctest_configure(OPTIONS) in setup.cmake.