Environment variable used by CMake to detect Visual C++ compiler tools for Ninja

You can also use the inverted approach and exclude all compilers you don’t want with CMAKE_IGNORE_PATH. It takes a list of paths to ignore, but be aware that it needs to be an exact string match. The advantage would be that you can declare those directly from the command line.

So what I did is to take the path from the compiler found but “not to be taken” into CMAKE_IGNORE_PATH.

And on my system there were actually three GCC compilers in my PATH (just make sure to start from an empty binary output directory with each try):

> cmake -G"Ninja" ..
...
-- Check for working C compiler: C:/MinGW/bin/cc.exe
...

> cmake -DCMAKE_IGNORE_PATH="C:/MinGW/bin" -G"Ninja" ..
...
-- Check for working C compiler: C:/Strawberry/c/bin/gcc.exe
...

> cmake -DCMAKE_IGNORE_PATH="C:/MinGW/bin;C:/Strawberry/c/bin" -G"Ninja" ..
...
-- Check for working C compiler: C:/Program Files (x86)/LLVM/bin/clang.exe
...

> cmake -DCMAKE_IGNORE_PATH="C:/MinGW/bin;C:/Strawberry/c/bin;C:/Program Files (x86)/LLVM/bin" -G"Ninja" ..
...
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
...

Leave a Comment