Mixing MSVC-like and GNU-like compiler frontends on Windows
We currently have this check that all enabled languages' compilers use the same frontend command-line style: either all MSVC-like or all GNU-like. The explicit enforcement provides an early diagnostic for users trying to mix these compilers because we don't currently support mixing them.
One of the main problems is that CMAKE_EXE_LINKER_FLAGS
and friends are used on link lines for all languages. For MSVC-like compiler frontends we use link.exe
to drive linking. For GNU-like compiler frontends we use the compiler to drive linking. The linker command-line fragments in CMAKE_EXE_LINKER_FLAGS
and friends cannot work for both. This has been raised in a few places recently, including:
- #25598
- !9107 (comment 1468168)
- https://discourse.cmake.org/t/handling-of-linker-flags-inconsistent/9827
In order to support mixing frontend styles we need to know more about the flags in CMAKE_EXE_LINKER_FLAGS
and friends. One possibility is to add LINKER:
prefixes in that string as needed, but that will break existing use cases where the values of those variables are forwarded by projects to other build systems or scripts.
We need to consider alternative ways of expressing such platform-wide linker flags.