cmake-conan
cmake-conan copied to clipboard
Clang not found
I run into a strange problem:
PS D:\my\cmake-vscode\ibis-conan> cmake --preset windows-clang-release
Preset CMake variables:
CMAKE_BUILD_TYPE="Release"
CMAKE_CXX_COMPILER="clang++"
CMAKE_EXPORT_COMPILE_COMMANDS="ON"
CMAKE_INSTALL_PREFIX="D:/My/cmake-vscode/ibis-conan/build/windows-clang-release/install"
MY_CACHE_VAR="empty"
-- The CXX compiler identification is Clang 13.0.0 with GNU-like command-line
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/Llvm/x64/bin/clang++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- System name: Windows
-- Version: 0.0.1
-- Found Python3: C:/Users/olpetzol/AppData/Local/Programs/Python/Python310/python.exe (found version "3.10.4") found components: Interpreter
-- Downloading conan.cmake from https://github.com/conan-io/cmake-conan
CMake Error at build/windows-clang-release/conan.cmake:233 (message):
Conan: compiler setup not recognized
Call Stack (most recent call first):
build/windows-clang-release/conan.cmake:447 (_conan_detect_compiler)
CMakeLists.txt:100 (conan_cmake_autodetect)
-- Configuring incomplete, errors occurred!
See also "D:/My/cmake-vscode/ibis-conan/build/windows-clang-release/CMakeFiles/CMakeOutput.log".
PS D:\my\cmake-vscode\ibis-conan> clang++.exe --version
clang version 13.0.0
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\Llvm\x64\bin
PS D:\my\cmake-vscode\ibis-conan>
It's using the CLI Clang from VS2020 (not clang-cl). MSVC compiler works as expected, using
cmake_minimum_required(VERSION 3.20)
project(... LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
list(APPEND
CMAKE_MODULE_PATH
${CMAKE_BINARY_DIR} # conan
${PROJECT_SOURCE_DIR}/cmake
${PROJECT_SOURCE_DIR}/cmake/module
)
include(prevent_in_source_builds)
find_package(Python3 COMPONENTS Interpreter REQUIRED)
if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
file(DOWNLOAD
"https://raw.githubusercontent.com/conan-io/cmake-conan/0.18.1/conan.cmake"
"${CMAKE_BINARY_DIR}/conan.cmake"
TLS_VERIFY ON)
endif()
include(${CMAKE_BINARY_DIR}/conan.cmake)
conan_cmake_configure(
REQUIRES
boost/1.78.0
cli11/2.2.0
#fmt/6.1.2
GENERATORS
cmake_find_package
cmake_find_package_multi
virtualenv
IMPORTS "bin, *.dll -> ${CMAKE_BINARY_DIR}/bin"
IMPORTS "lib, *.dylib* -> ${CMAKE_BINARY_DIR}/lib"
OPTIONS ...
)
conan_cmake_autodetect(conan_settings)
message(STATUS "Conan: Detected settings: ${conan_settings}")
conan_cmake_install(
PATH_OR_REFERENCE .
BUILD missing
REMOTE conancenter
SETTINGS ${conan_settings}
)
What happended here?
Hi @opelx,
Looks like conan_cmake_autodetect is not able to detect the compiler in this case. It works for the most used cases but does not implement every os/compiler combination. I would recommend skipping the conan_cmake_autodetect step for this case and explicitly passing the SETTINGS argument or a PROFILE to conan_cmake_install
As far I know, it did work before it was changed for MSVC Clang. Anyway, Linux and Clang combination isn't a very exotic OS/compiler combination.
Looks like conan_cmake_autodetect is not able to detect the compiler in this case. It works for the most used cases but does not implement every os/compiler combination. I would recommend skipping the conan_cmake_autodetect step for this case and explicitly passing the SETTINGS argument or a PROFILE to conan_cmake_install
Tried this, but then conan is trying to use "MinGW Makefiles" for the dependencies. Which will fail obviously.
I think the reason comes from the value of CMAKE_<LANG>_COMPILER_FRONTEND_VARIANT.
- Its value will be
GNUif we specifyclang.exe/clang++.exeas the compiler. - Its value will be
MSVCif we specifyclang-cl.exeas the compiler.
However, it seems that _conan_detect_compiler() only consider the situations using clang-cl.exe:
- https://github.com/conan-io/cmake-conan/blob/0.18.1/conan.cmake#L173-L175
- https://github.com/conan-io/cmake-conan/blob/0.18.1/conan.cmake#L196-L199
I add the following 3 lines in the macro _conan_detect_compiler() to check their values:
message("CMAKE_${LANGUAGE}_COMPILER_ID = ${CMAKE_${LANGUAGE}_COMPILER_ID}")
message("CMAKE_${LANGUAGE}_COMPILER_FRONTEND_VARIANT = ${CMAKE_${LANGUAGE}_COMPILER_FRONTEND_VARIANT}")
message("CMAKE_${LANGUAGE}_SIMULATE_ID = ${CMAKE_${LANGUAGE}_SIMULATE_ID}")
And here are screenshots of the result:
