首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >处理conan和CMake之间编译器版本的版本不匹配

处理conan和CMake之间编译器版本的版本不匹配
EN

Stack Overflow用户
提问于 2021-03-30 18:57:47
回答 2查看 2.6K关注 0票数 1

我正在macOS上开发,通过Xcode安装,Apple v12是默认编译器。由于val差尔仍然不支持Big和Apple版本不支持谷歌杀菌剂,所以我必须通过自制手动安装llvm v11.1,以利用谷歌杀菌剂启用任何内存泄漏检测工具。

不幸的是,这会给conan及其与CMake和CLion (我的IDE )集成带来一些问题。由于我的依赖项没有为我的体系结构提供二进制文件,所以必须在本地构建clang,而不是Apple。不幸的是,当使用两个相互矛盾的错误消息调用conan和CMake错误时:

代码语言:javascript
复制
conan install /Users/near/Code/personal/blight -if=/Users/near/Code/personal/blight/cmake-build-debug -pr=LLVM11Debug --build=missing
Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Debug
compiler=clang
compiler.libcxx=libstdc++
compiler.version=11
os=Macos
os_build=Macos
[options]
[build_requires]
[env]

fmt/7.1.3: WARN: Package binary is corrupted, removing: 2284170e72f485ebb586c7bd784f294475c25e5e
conanfile.txt: Installing package
Requirements
    fmt/7.1.3 from 'conan-center' - Cache
    spdlog/1.8.5 from 'conan-center' - Cache
Packages
    fmt/7.1.3:2284170e72f485ebb586c7bd784f294475c25e5e - Build
    spdlog/1.8.5:b744aef5cdad24eec65bb267843e16ad74c9ad39 - Build

Installing (downloading, building) binaries...
fmt/7.1.3: WARN: Build folder is dirty, removing it: /Users/near/.conan/data/fmt/7.1.3/_/_/build/2284170e72f485ebb586c7bd784f294475c25e5e
fmt/7.1.3: Copying sources to build folder
fmt/7.1.3: Building your package in /Users/near/.conan/data/fmt/7.1.3/_/_/build/2284170e72f485ebb586c7bd784f294475c25e5e
fmt/7.1.3: Generator cmake created conanbuildinfo.cmake
fmt/7.1.3: Calling build()
-- The C compiler identification is AppleClang 12.0.0.12000032
-- The CXX compiler identification is AppleClang 12.0.0.12000032
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Conan: called by CMake conan helper
-- Conan: called inside local cache
-- Conan: Adjusting output directories
-- Conan: Using cmake global configuration
-- Conan: Adjusting default RPATHs Conan policies
-- Conan: Adjusting language standard
-- Conan: Adjusting fPIC flag (ON)
-- Conan: Compiler Clang>=8, checking major version 11
-- Conan: Checking correct version: 12
CMake Error at conanbuildinfo.cmake:402 (message):
  Detected a mismatch for the compiler version between your conan profile
  settings and CMake:

  Compiler version specified in your conan profile: 11

  Compiler version detected in CMake: 12.0

  Please check your conan profile settings (conan profile show
  [default|your_profile_name])

  P.S.  You may set CONAN_DISABLE_CHECK_COMPILER CMake variable in order to
  disable this check.
Call Stack (most recent call first):
  conanbuildinfo.cmake:499 (conan_error_compiler_version)
  conanbuildinfo.cmake:589 (check_compiler_version)
  conanbuildinfo.cmake:141 (conan_check_compiler)
  CMakeLists.txt:5 (conan_basic_setup)


-- Configuring incomplete, errors occurred!
See also "/Users/near/.conan/data/fmt/7.1.3/_/_/build/2284170e72f485ebb586c7bd784f294475c25e5e/build_subfolder/CMakeFiles/CMakeOutput.log".
See also "/Users/near/.conan/data/fmt/7.1.3/_/_/build/2284170e72f485ebb586c7bd784f294475c25e5e/build_subfolder/CMakeFiles/CMakeError.log".
fmt/7.1.3: 
fmt/7.1.3: ERROR: Package '2284170e72f485ebb586c7bd784f294475c25e5e' build failed
fmt/7.1.3: WARN: Build folder /Users/near/.conan/data/fmt/7.1.3/_/_/build/2284170e72f485ebb586c7bd784f294475c25e5e
ERROR: fmt/7.1.3: Error in build() method, line 63
    cmake = self._configure_cmake()
while calling '_configure_cmake', line 56
    self._cmake.configure(build_folder=self._build_subfolder)
    ConanException: Error 1 while executing cd '/Users/near/.conan/data/fmt/7.1.3/_/_/build/2284170e72f485ebb586c7bd784f294475c25e5e/build_subfolder' && cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE="Debug" -DCMAKE_OSX_ARCHITECTURES="x86_64" -DCMAKE_OSX_SYSROOT="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk" -DCONAN_IN_LOCAL_CACHE="ON" -DCONAN_COMPILER="clang" -DCONAN_COMPILER_VERSION="11" -DCONAN_CXX_FLAGS="-m64" -DCONAN_SHARED_LINKER_FLAGS="-m64" -DCONAN_C_FLAGS="-m64" -DCONAN_LIBCXX="libstdc++" -DBUILD_SHARED_LIBS="OFF" -DCMAKE_INSTALL_PREFIX="/Users/near/.conan/data/fmt/7.1.3/_/_/package/2284170e72f485ebb586c7bd784f294475c25e5e" -DCMAKE_INSTALL_BINDIR="bin" -DCMAKE_INSTALL_SBINDIR="bin" -DCMAKE_INSTALL_LIBEXECDIR="bin" -DCMAKE_INSTALL_LIBDIR="lib" -DCMAKE_INSTALL_INCLUDEDIR="include" -DCMAKE_INSTALL_OLDINCLUDEDIR="include" -DCMAKE_INSTALL_DATAROOTDIR="share" -DCONAN_CMAKE_POSITION_INDEPENDENT_CODE="ON" -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON" -DCONAN_EXPORTED="1" -DFMT_DOC="False" -DFMT_TEST="False" -DFMT_INSTALL="True" -DFMT_LIB_DIR="lib" -Wno-dev '/Users/near/.conan/data/fmt/7.1.3/_/_/build/2284170e72f485ebb586c7bd784f294475c25e5e'
"/Users/near/Library/Application Support/JetBrains/Toolbox/apps/CLion/ch-0/203.7717.62/CLion.app/Contents/bin/cmake/mac/bin/cmake" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=clang++ -G "CodeBlocks - Unix Makefiles" /Users/near/Code/personal/blight
-- The CXX compiler identification is Clang 11.1.0
-- Check for working CXX compiler: /usr/local/opt/llvm/bin/clang++
-- Check for working CXX compiler: /usr/local/opt/llvm/bin/clang++ - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Conan: Adjusting output directories
-- Conan: Using cmake global configuration
-- Conan: Adjusting default RPATHs Conan policies
-- Conan: Adjusting language standard
-- Current conanbuildinfo.cmake directory: /Users/near/Code/personal/blight/cmake-build-debug
CMake Error at cmake-build-debug/conanbuildinfo.cmake:626 (message):
  Detected a mismatch for the compiler version between your conan profile
  settings and CMake:

  Compiler version specified in your conan profile: 12.0

  Compiler version detected in CMake: 11.1

  Please check your conan profile settings (conan profile show
  [default|your_profile_name])

  P.S.  You may set CONAN_DISABLE_CHECK_COMPILER CMake variable in order to
  disable this check.
Call Stack (most recent call first):
  cmake-build-debug/conanbuildinfo.cmake:728 (conan_error_compiler_version)
  cmake-build-debug/conanbuildinfo.cmake:813 (check_compiler_version)
  cmake-build-debug/conanbuildinfo.cmake:365 (conan_check_compiler)
  CMakeLists.txt:13 (conan_basic_setup)


-- Configuring incomplete, errors occurred!
See also "/Users/near/Code/personal/blight/cmake-build-debug/CMakeFiles/CMakeOutput.log".

这是在CMake输出窗口CLion中看到的输出。第一次调用有CMake,认为Apple是我的编译器,而conan被配置为使用llvm版本,在第二步(很可能是由conan_basic_setup在我的CMakeLists.txt中调用),选择了正确的CMake编译器,但是Conan最终没有配置文件,因此版本不匹配。

在CLion设置中,我已经用llvmv11.1编译器覆盖了c++编译器:

什么是正确的解决方案,以正确地配置这两个使用llvmv11.1编译器?我个人不想启用CONAN_DISABLE_CHECK_COMPILER CMake变量,因为还不清楚最终将使用哪个编译器来编译依赖项。

以前发布的问题只建议故意使用更高的版本,这不是我想要的:

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2021-03-31 13:02:22

我找到了一个解决方案,尽管首先禁用了Conan集成。使用一个干净的构建目录,我进入了其中,必须手动调用Conan,如下所示:

代码语言:javascript
复制
CC=clang CXX=clang++ conan install .. -pr=LLVM11Debug --build=missing

之后,可以使用CMake和clang 11在CLion的UI中进行运行构建。问题是没有提供使用环境变量设置编译器的直接方法,也没有从CLion中的工具链选项中获取编译器。

票数 0
EN

Stack Overflow用户

发布于 2021-03-31 06:45:49

我在日志文件中看到的两个包spdlog和fmt都可以作为标头配置使用。因此,如果这些是您唯一的依赖项,您可以简单地设置只使用它们头的选项,这将消除问题,因为这些包没有什么可构建的。

这样做的一种方法是将设置添加到您使用的配置文件中,添加到选项部分,如下所示

代码语言:javascript
复制
[options]
fmt:header_only=True
spdlog:header_only=True
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66876929

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档