cmake-conan
cmake-conan copied to clipboard
[bug] v0.18.0+ does not recognize Clang with GNU-like command-line on Windows
I've noticed that a compiler setup with clang (not clang-cl) is not auto-detected on windows any more.
This bug was introduced in the v0.18.0, while on v0.17.0 it works correctly.
The configuration is recognized by cmake like this:
CMAKE_C_COMPILER_ID = Clang
CMAKE_C_COMPILER_FRONTEND_VARIANT = GNU
CMAKE_C_SIMULATE_ID = MSVC
This setup is not recognized by the condition for clang:
...
elseif (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL Clang
AND NOT "${CMAKE_${LANGUAGE}_COMPILER_FRONTEND_VARIANT}" STREQUAL "MSVC"
AND NOT "${CMAKE_${LANGUAGE}_SIMULATE_ID}" STREQUAL "MSVC")
...
I think that the last condition can simply be dropped- clang that produces MSVC-ABI code should be recognized as clang.
Without this condition the setup is recognized correctly.
Agree. However, there is something I need to clarify.
If we install Clang/LLVM from llvm-project, we can see the following two types of Clang compilers:
C:\Program Files\LLVM\bin\clang++.exeC:\Program Files\LLVM\bin\clang-cl.exe
According to the issue (https://github.com/conan-io/conan/issues/12424) that I posted previously, both of them should use the SAME the [settings] section since they use the SAME C++ stdlib and runtime dependencies. For example:
[settings]
os=Windows
arch=x86_64
build_type=Release
compiler=clang
compiler.version=13
compiler.cppstd=gnu14
compiler.runtime=dynamic
compiler.runtime_type=Release
compiler.runtime_version=v143
We should call them MSVC-based Clang compilers. The only difference between them is their FRONTEND. Therefore, the condition statement should be like:
elseif ("${CMAKE_${LANGUAGE}_COMPILER_ID}" STREQUAL "Clang"
AND "${CMAKE_${LANGUAGE}_SIMULATE_ID}" STREQUAL "MSVC")
# using MSVC-based Clang compilers
# For example:
# C:\Program Files\LLVM\bin\clang.exe
# C:\Program Files\LLVM\bin\clang++.exe
# C:\Program Files\LLVM\bin\clang-cl.exe
endif ()
I already planned to fulfill the detection of MSVC-based Clang and ClangCL. However, it is required to detect compiler.runtime and compiler.runtime_type settings, which can be detected by the macros implemented in the following PR:
- https://github.com/conan-io/cmake-conan/pull/454
I'm still waiting this PR to be merged, so that I can start to implement the dection of MSVC-based Clang.
It seems that MSVC and Clang are not detected as of 0.18.1. It worked fine in 0.17.0 https://github.com/aminya/project_options/pull/184
Any update on this issue? It is blocking project_options' Cmake conan update to 0.18.1
You can see the list of all failing compilers in project_options' testing matrix https://github.com/aminya/project_options/pull/184
No updates here, sorry, we are prioritizing at this moment the cmake-conan for Conan 2.0 here: https://github.com/conan-io/cmake-conan/tree/develop2, based on the new CMake dependency providers. Reports and contributions for the develop2 branch are more likely to be able to get some more priority.