您可以完全访问build()
方法中的依赖模型,因此您可以访问:
def build(self):
print(self.deps_cpp_info["OpenSSL"].rootpath)
print(self.deps_cpp_info["OpenSSL"].include_paths)
print(self.deps_cpp_info["OpenSSL"].lib_paths)
print(self.deps_cpp_info["OpenSSL"].bin_paths)
print(self.deps_cpp_info["OpenSSL"].libs)
print(self.deps_cpp_info["OpenSSL"].defines)
print(self.deps_cpp_info["OpenSSL"].cflags)
print(self.deps_cpp_info["OpenSSL"].cppflags)
print(self.deps_cpp_info["OpenSSL"].sharedlinkflags)
print(self.deps_cpp_info["OpenSSL"].exelinkflags)
此外,如果您想访问聚合值(对于所有依赖项/要求),您可以执行以下操作:
def build(self):
print(self.deps_cpp_info.include_paths)
print(self.deps_cpp_info.lib_paths)
...
因此,给定这些值,您可以将它们传递给您的构建系统,对于 CMake,您可以执行以下操作:
def build(self):
cmake = CMake(self)
# Assuming there is only 1 include path, otherwise, we could join it
cmake.definitions["SSL_INCLUDE_PATH"] = self.deps_cpp_info["OpenSSL"].include_paths[0]
这将被转换为包含-DSSL_INCLUDE_PATH=<path to openssl include>
标志的 cmake 命令。
如果您选择多配置包,可以查看(http://docs.conan.io/en/latest/packaging/package_info.html#multi-configuration-packages)。他们将定义debug, release
配置,您以后也可以在模型中使用:
def build(self):
# besides the above values, that will contain data for both configs
# you can access information specific for each configuration
print(self.deps_cpp_info["OpenSSL"].debug.rootpath)
print(self.deps_cpp_info["OpenSSL"].debug.include_paths)
...
print(self.deps_cpp_info["OpenSSL"].release.rootpath)
print(self.deps_cpp_info["OpenSSL"].release.include_paths)
...