Skip to content

Ninja: On Windows, select the compiler occurring first in PATH

Brad King requested to merge brad.king/cmake:ninja-compiler-PATH-windows into master

On Windows, toolchains like MSVC require a set of environment variables to be configured for the compiler to work correctly. The scripts that prepare these environments typically put the compiler's directory ahead of others in the PATH. Teach the Ninja generators to use this as a heuristic to select the compiler when none is explicitly specified.

This is not necessary with Makefile generators because each toolchain's environment comes with its own make tool variant, and the corresponding Makefile generator (e.g. "NMake Makefiles") automatically implies the matching compiler.

Fixes: #20585 (closed)

Merge request reports