[cmake-developers] [PATCH] Let CMake know that clang uses the GCC toolchain.

Brad King brad.king at kitware.com
Wed Aug 3 08:56:38 EDT 2016


On 08/02/2016 06:59 PM, Chaoren Lin wrote:
>> In the gcc-like variant the CMAKE_{C,CXX}_SIMULATE_ID
>> should be detected as GNU and cause the existing code to work.
> 
> Huh, it doesn't look like that variable is set automatically when using
> clang with the gcc toolchain. Is that supposed to happen?
> It should be set manually (say, in a toolchain file)?

It is supposed to be detected automatically.  Whenever Clang is detected
on Windows the _SIMULATE_ID should be detected too.  I found the problem.
The simulate id detection is done here:

  https://gitlab.kitware.com/cmake/cmake/blob/v3.6.1/Modules/Compiler/Clang-DetermineCompilerInternal.cmake#L12-15

and it only looks for MSVC.  Grepping for SIMULATE_ID reveals that it is
used for Intel and Clang but only ever detects when MSVC is simulated.
All consuming code paths are interested in whether SIMULATE_ID==MSVC
and otherwise assume GNU, except cmGlobalNinjaGenerator::EnableLanguage.

It will take some investigation to decide how/whether to set SIMULATE_ID
to GNU.  Alternatively the corresponding test in the Ninja generator could
be changed to look for `COMPILER_ID == Clang && SIMULATE_ID != MSVC`.

-Brad



More information about the cmake-developers mailing list