你有你的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]
這將被翻譯成cmake命令,其中包括-DSSL_INCLUDE_PATH=<path to openssl include>
標誌。
如果你需要多配置包,你可以檢查(http://docs.conan.io/en/latest/packaging/package_info.html#multi-configuration-packages)。它們將定義debug, release
CONFIGS,你也可以在你隨後的模型中使用:
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)
...
如果你的意思是,如何訪問依賴模型,從消費者的食譜(RabbitMQ的),你可以通過''self.deps_cpp_info訪問[ 「OpenSSL的」]''。該對象將包含「include_paths」,「lib_paths」等信息。您可以檢查:http://conanio.readthedocs.io/en/latest/integrations/other.html。請告訴我,如果這是有道理的,我會詳述一個擴展的答案 – drodri
@drodri +1 10x它非常有意義,但此外還需要兩個不同的OpenSSL包。一個用於調試,一個用於發佈。現在我爲RabbitMQ-C的Debug和Release變體創建了不同的包,因此我可以使用相同的值,但是如果我要爲RabbitMQ-C的調試和發行版本創建一個包,該如何處理? – bobeff