CMakeDetermineCompilerABI.cmake removes any command line provided -D values before testing the compiler

It appears CMakeDetermineCompilerABI.cmake when it runs the compiler starts with a clean slate. That is it sets



and then sets a very limited set of arguments that it runs essentially a new cmake on.

Thus if I provided a, say -DCMAKE_DEPENDS_USE_COMPILER=FALSE on the command line to running CMake that value is “lost” when CMakeDetermineCompilerABI.cmake tests the compiler. That is it runs the compiler without that flag set to false which means when it calls the compiler it pass the extra compiler arguments to create the dependencies.

I have confirmed this by tracing the value of CMAKE_DEPENDS_USE_COMPILER and sure enough inside the calls in CMakeDetermineCompilerABI.cmake to, for example, Intel-C.cmake, the value is not there and the dependency flags are added to the compiler.

If I change CMakeDetermineCompilerABI.cmake to pass this flag into the cmake call at


SOURCES ${src}



Ignore unused flags when we are just determining the ABI.


Then the flag is defined as false in Intel-C.cmake and so the dependency flags are not added to the compiler when testing the compiler.

This seems a totally wrong model to me. If I ask via -DCMAKE_DEPENDS_USE_COMPILER=FALSE which CMake advertises as turning of the use of the compiler dependency flags it should ALWAYS turn them off, not keep them on when it is testing the basics of the compiler.

What am I missing? Shouldn’t CMakeDetermineCompilerABI.cmake pass down to the compiler tests all the user flags provided? (CMAKE_DEPENDS_USE_COMPILER is just one example)?

In that vain is there a CMake command to list all the -D options passed in at the command line (if there was I could change CMakeDetermineCompilerABI.cmake to pass all the arguments to the running of cmake to test the compilers?


Knowing what flags matter is always fun. But this one seems relevant since it seems fairly core to how the compiler works… I’m assuming that the compiler throws a fit if asked about dependencies?