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

cd build
ctest  # 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.

Option selection

If you need 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