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
However, 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.
To specify command-line build options -Dfoo
then either specify them in setup.cmake by _opts
variable, or do like:
cmake -B build -Dfoo
ctest -S setup.cmake