Files
rabbitmq-c/conanfile.py

90 lines
2.9 KiB
Python

from conan import ConanFile
from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout
from conan.tools.files import copy
import os
class RabbitmqCConan(ConanFile):
name = "rabbitmq-c"
version = "0.11.0"
description = "C RabbitMQ AMQP client library"
url = "https://github.com/alanxz/rabbitmq-c"
license = "MIT"
author = "Alan Antonuk and the rabbitmq-c contributors"
topics = ("rabbitmq", "amqp", "client", "message-queue")
settings = "os", "compiler", "build_type", "arch"
package_type = "library"
options = {
"shared": [True, False],
"fPIC": [True, False],
"ssl": [True, False],
"build_tools": [True, False],
"build_examples": [True, False]
}
default_options = {
"shared": False,
"fPIC": True,
"ssl": False,
"build_tools": False,
"build_examples": False
}
exports_sources = "CMakeLists.txt", "cmake/*", "librabbitmq/*", "fuzz/*", "tests/*", "tools/*", "examples/*", "docs/*"
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
# Pure C library
self.settings.rm_safe("compiler.libcxx")
self.settings.rm_safe("compiler.cppstd")
def layout(self):
cmake_layout(self)
def requirements(self):
if self.options.ssl:
self.requires("openssl/[>=1.1.1]")
def generate(self):
tc = CMakeToolchain(self)
tc.variables["ENABLE_SSL_SUPPORT"] = self.options.ssl
tc.variables["BUILD_SHARED_LIBS"] = self.options.shared
tc.variables["BUILD_STATIC_LIBS"] = not self.options.shared
tc.variables["BUILD_TOOLS"] = self.options.build_tools
tc.variables["BUILD_EXAMPLES"] = self.options.build_examples
tc.variables["BUILD_TESTING"] = False
tc.generate()
deps = CMakeDeps(self)
deps.generate()
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def package(self):
cmake = CMake(self)
cmake.install()
copy(self, "LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder)
def package_info(self):
self.cpp_info.set_property("cmake_file_name", "rabbitmq-c")
target = "rabbitmq" if self.options.shared else "rabbitmq-static"
self.cpp_info.set_property("cmake_target_name", f"rabbitmq::{target}")
self.cpp_info.libs = [target]
if self.settings.os == "Windows":
self.cpp_info.system_libs.extend(["ws2_32"])
elif self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.system_libs.extend(["pthread", "rt"])
if self.options.ssl:
self.cpp_info.requires = ["openssl::ssl", "openssl::crypto"]