0

我正在编写为rabbitmq-c库创建包的方法。当检查其cmake脚本中的enable_ssl_support选项时,它需要OpenSSL库才能构建。

RabbitMQ C 客户端库 CMake GUI 屏幕

如提供的屏幕路径所示,需要libeay.libssleay.lib文件的调试发布版本。

在我conanfile.py的 forrabbitmq-c库中,我有以下描述依赖关系的代码。

def requirements(self):
    if self.options.ssl_support:
        self.requires("OpenSSL/1.0.2l@bobeff/stable")

如何从所需的OpenSSL包中获取正确的值以在RabbitMQ-C配方的CMake配置选项中设置它们?

OpenSSL/1.0.2l@bobeff/stable可以使用不同的设置和选项构建包。在构建RabbitMQ-C时如何选择使用哪个?例如,如何选择是使用静态版本还是动态版本的OpenSSL来链接RabbitMQ-C dll文件?

4

1 回答 1

1

您可以完全访问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)
    ...
于 2017-08-29T16:27:33.880 回答