I use a lot of compiler flags in my default builds - having CMake check all of those when it is being run from scratch takes about 10-15s on my slower laptop, which can be annoying when I'm rebuilding multiple projects from scratch or switching between gcc
and clang
for testing purposes.
I'm using check_cxx_compiler_flag
to check if compiler flags are valid, and every check is run sequentially by CMake.
Assuming what CMake does is attempt to compile a dummy file passing the flag to the compiler and checking whether or not the compilation was successful, I think it would be theoretically possible to spawn multiple compiler processes to test multiple compiler flags in parallel. Unfortunately, I couldn't find a way to do so.
Is there a way to make CMake test compiler flags in parallel (probably by spawning multiple compiler processes)?