在conan install . -s arch=x86
系统上运行x86_64
时,我希望生成的CONAN_CXXFLAGS_MYLIB=-m32
文件中有conanbuildinfo.mak
之类的编译器选项,但没有这样的选项。>
首先,conanfile.txt
的内容:
[requires]
mylib/1.0@demo/dev
[generators]
make
以下是install
命令的输出(cmake具有特殊处理,因为它只是一种工具):
$ conan install . -s cmake:arch=x86_64 -s arch=x86
Configuration:
[settings]
arch=x86
arch_build=x86_64
build_type=Release
compiler=gcc
compiler.libcxx=libstdc++11
compiler.version=9
os=Linux
os_build=Linux
cmake:arch=x86_64
[options]
[build_requires]
[env]
conanfile.txt: Installing package
Requirements
mylib/1.0@demo/dev from local cache - Cache
Packages
mylib/1.0@demo/dev:eb79ce42f6e6b4359bd7d0a65a238a4dae953257 - Cache
'''
Cross-build from 'Linux:x86_64' to 'Linux:x86'
Installing (downloading, building) binaries...
mylib/1.0@demo/dev: Already installed!
conanfile.txt: Generator make created conanbuildinfo.mak
conanfile.txt: Generator txt created conanbuildinfo.txt
conanfile.txt: Generated conaninfo.txt
conanfile.txt: Generated graphinfo
生成的makfe文件如下:
#-------------------------------------------------------------------#
# Makefile variables from Conan Dependencies #
#-------------------------------------------------------------------#
CONAN_ROOT_MYLIB ?= \
/home/username/.conan/data/mylib/1.0/demo/dev/package/eb79ce42f6e6b4359bd7d0a65a238a4dae953257
CONAN_SYSROOT_MYLIB ?= \
CONAN_INCLUDE_DIRS_MYLIB += \
/home/username/.conan/data/mylib/1.0/demo/dev/package/eb79ce42f6e6b4359bd7d0a65a238a4dae953257/include
CONAN_LIB_DIRS_MYLIB += \
/home/username/.conan/data/mylib/1.0/demo/dev/package/eb79ce42f6e6b4359bd7d0a65a238a4dae953257/lib
CONAN_BIN_DIRS_MYLIB += \
CONAN_BUILD_DIRS_MYLIB += \
/home/username/.conan/data/mylib/1.0/demo/dev/package/eb79ce42f6e6b4359bd7d0a65a238a4dae953257/
CONAN_RES_DIRS_MYLIB += \
CONAN_LIBS_MYLIB += \
mylib
CONAN_SYSTEM_LIBS_MYLIB += \
CONAN_DEFINES_MYLIB += \
CONAN_CFLAGS_MYLIB += \
CONAN_CXXFLAGS_MYLIB += \
CONAN_SHAREDLINKFLAGS_MYLIB += \
CONAN_EXELINKFLAGS_MYLIB += \
CONAN_FRAMEWORKS_MYLIB += \
CONAN_FRAMEWORK_PATHS_MYLIB += \
CONAN_ROOTPATH += \
$(CONAN_ROOTPATH_MYLIB)
CONAN_SYSROOT += \
$(CONAN_SYSROOT_MYLIB)
CONAN_INCLUDE_DIRS += \
$(CONAN_INCLUDE_DIRS_MYLIB)
CONAN_LIB_DIRS += \
$(CONAN_LIB_DIRS_MYLIB)
CONAN_BIN_DIRS += \
$(CONAN_BIN_DIRS_MYLIB)
CONAN_BUILD_DIRS += \
$(CONAN_BUILD_DIRS_MYLIB)
CONAN_RES_DIRS += \
$(CONAN_RES_DIRS_MYLIB)
CONAN_LIBS += \
$(CONAN_LIBS_MYLIB)
CONAN_DEFINES += \
$(CONAN_DEFINES_MYLIB)
CONAN_CFLAGS += \
$(CONAN_CFLAGS_MYLIB)
CONAN_CXXFLAGS += \
$(CONAN_CXXFLAGS_MYLIB)
CONAN_SHAREDLINKFLAGS += \
$(CONAN_SHAREDLINKFLAGS_MYLIB)
CONAN_EXELINKFLAGS += \
$(CONAN_EXELINKFLAGS_MYLIB)
CONAN_FRAMEWORKS += \
$(CONAN_FRAMEWORKS_MYLIB)
CONAN_FRAMEWORK_PATHS += \
$(CONAN_FRAMEWORK_PATHS_MYLIB)
CONAN_SYSTEM_LIBS += \
$(CONAN_SYSTEM_LIBS_MYLIB)
#-------------------------------------------------------------------#
柯南知道,这是一个交叉构建,它知道编译器,它以32位(或在仓库中找到32位二进制文件)构建mylib。因此很明显,我的应用程序需要使用-m32
进行编译。
我的期望为什么错了?
更新:
我自己找到了解决方案。如果将conanfile.py
与自动工具/ make辅助程序一起使用,而不是简单的conanfile.txt
,则可以使用conan build .
构建应用程序,并且柯南可以设置所有编译器选项并正确定义。这是此类消费者收据的示例:
from conans import ConanFile, AutoToolsBuildEnvironment
from conans import tools
class AppConan(ConanFile):
name = "mayapp"
version = "1.0"
settings = "os", "compiler", "build_type", "arch"
requires = "mylib/1.0@demo/dev"
generators = "make", "virtualrunenv"
def build(self):
atools = AutoToolsBuildEnvironment(self)
atools.make()