首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >将编译环境打包为配置文件的build_requires,取而代之的是系统编译器。

将编译环境打包为配置文件的build_requires,取而代之的是系统编译器。
EN

Stack Overflow用户
提问于 2020-10-02 12:25:50
回答 1查看 1.3K关注 0票数 1

我将尝试首先描述我的设置:

带有1.29.2

  • Official
  • conan cmake/3.18.2
  • 自定义gcc包,其中包括它在 PATH 中的bin目录,并设置E 217 CC E 121E 222 CXX E 126env变量< package_info >E 227:def包(Self):autotools = AutoToolsBuildEnvironment(self) autotools.make(target=‘install-条带) def package_info(self):bin_folder = os.path.join(self.package_folder,self.env_info.path.append(bin_folder) self.env_info.CXX = os.path.join(bin_folder,'g++') self.env_info.CC = os.path.join(bin_folder,'gcc')

  • linux-x86_64 conan配置文件表示Linux 64位环境,如下所示:设置os=Linux os_build=Linux arch=x86_64 arch_build=x86_64

  • linux-x86_64-Debug conan配置文件表示Linux64位发布环境,如下所示:包含(Linux86_ 64 )设置build_type=Debug

使用我的

  • gcc-10.1.0包构建软件包的gcc conan配置文件:设置compiler=gcc compiler.version=10.1 compiler.libcxx=libstdc++11 build_requires gcc/10.1.0

  • cmake-3.18.2 conan配置文件使用正式的cmake包构建包: build_requires cmake/3.18.2

  • default conan profile与gcc 7

如果我试图构建一个包,如下所示:

代码语言:javascript
运行
复制
$ conan create . foo/version --build=missing -pr linux-x86_64-Debug -pr cmake-3.18.2 -pr gcc-10.1.0

产生的配置是:

代码语言:javascript
运行
复制
Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Debug
compiler=gcc
compiler.libcxx=libstdc++11
compiler.version=10.1
os=Linux
os_build=Linux
[options]
[build_requires]
*: gcc/10.1.0, cmake/3.18.2
[env]

在我看来就像..。

然后conan开始为gcc 10.1 cmake配置构建x86_64包:

代码语言:javascript
运行
复制
cmake/3.18.2: WARN: Build folder is dirty, removing it: /home/manuel/.conan/data/cmake/3.18.2/_/_/build/46c0026dddc0e0537a797652343e8e1e9d0e39e7
cmake/3.18.2: Copying sources to build folder
cmake/3.18.2: Building your package in /home/manuel/.conan/data/cmake/3.18.2/_/_/build/46c0026dddc0e0537a797652343e8e1e9d0e39e7
cmake/3.18.2: Generator cmake created conanbuildinfo.cmake
cmake/3.18.2: Calling build()

但是生成失败,因为cmake包config 正在使用系统编译器。

代码语言:javascript
运行
复制
-- The C compiler identification is GNU 7.4.0
-- The CXX compiler identification is GNU 7.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /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: /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: Compiler GCC>=5, checking major version 10.1
-- Conan: Checking correct version: 7.4
CMake Error at ../conanbuildinfo.cmake:510 (message):
  Detected a mismatch for the compiler version between your conan profile
  settings and CMake:

  Compiler version specified in your conan profile: 10.1

  Compiler version detected in CMake: 7.4

  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:592 (conan_error_compiler_version)
  ../conanbuildinfo.cmake:695 (check_compiler_version)
  ../conanbuildinfo.cmake:249 (conan_check_compiler)
  CMakeLists.txt:9 (conan_basic_setup)

这看起来非常类似于https://github.com/conan-io/conan/issues/1842,但这个问题发生在3年前。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-10-02 14:37:31

Conan在以前学习了一些关于主机和构建上下文的版本,并且能够为这些上下文管理不同的配置。这比旧的os_buildarch_build设置更好,ConanCenter中的包正朝着这一新特性发展。

在您的场景中,您正在根据构建需要使用包librarycmake来构建一个cmake。您正在为主机构建library,并使用包gcccmake,这些包提供了应该在构建机中运行的工具。即使您没有交叉编译,我们也可以同意,本机构建只是一个特定的用例,其中主机和构建是相同的机器,因此,它们使用相同的Conan配置。

回到你的例子。您需要主机平台的配置文件,即要为其生成library的配置文件。这些都是你在问题中列出的个人资料。但是您还需要用于构建上下文的配置文件,Conan将用于构建(或检索) gcccmake包的配置文件。例如,您可能希望使用profile linux-x86_64-Debug在调试模式下编译library,同时在发行版中使用gcccmake

通常,构建上下文的配置文件可以是Conan检测到的默认配置文件。

尝试以下命令,而不是您的命令(请注意--profile:build=default):

代码语言:javascript
运行
复制
conan create <library/conanfile.py> foo/version --build=missing --profile:host linux-x86_64-Debug --profile:host cmake-3.18.2 --profile:host gcc-10.1.0 --profile:build=default 

现在Conan将使用新特性并将包分配到相应的上下文:

  • library及其所有依赖项都将分配给主机上下文,并将使用来自所有--profile:host配置文件的信息: Debug和Conan将将cmakegcc添加为build-requires.
  • gcccmake,就像构建一样--此命令中的要求将分配给构建上下文,并将使用来自--profile:build的信息。如果Conan需要构建这些包,它将使用该配置文件中的设置,而不是主机配置文件的设置。

使用此设置,您可以在单个运行的中构建跨构建场景中的所有包:宿主上下文中的包将使用您的构建--需要构建gcc,而构建上下文中的包将使用--profile:build中定义的工具。

是的,在这个场景中,构建上下文中的包将使用来自系统的编译器.除非您在[build_requires]中声明--profile:build

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64171510

复制
相关文章

相似问题

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