feat: add CMake build configuration and unit tests for XRabbitMQClient

This commit is contained in:
bing
2026-04-03 15:36:34 +08:00
parent b704b006c1
commit fee1555166
58 changed files with 6183 additions and 8 deletions

View File

@@ -9,11 +9,12 @@ class XRabbitMQClientConan(ConanFile):
author = "XDL"
topics = ("rabbitmq", "amqp", "message-queue")
settings = "os", "compiler", "build_type", "arch"
package_type = "library"
options = {"shared": [True, False], "fPIC": [True, False]}
default_options = {"shared": False, "fPIC": True}
options = {"shared": [True, False], "fPIC": [True, False], "with_test": [True, False]}
default_options = {"shared": False, "fPIC": True, "with_test": True}
exports_sources = "CMakeLists.txt", "src/*", "include/*"
exports_sources = "CMakeLists.txt", "src/*", "include/*", "test/*"
def config_options(self):
if self.settings.os == "Windows":
@@ -28,10 +29,14 @@ class XRabbitMQClientConan(ConanFile):
def requirements(self):
self.requires("simpleamqpclient/2.5.1", transitive_headers=True, transitive_libs=True)
self.requires("boost/1.78.0")
def build_requirements(self):
if self.options.with_test:
self.test_requires("xgoogletest/1.17.1")
def generate(self):
tc = CMakeToolchain(self)
tc.variables["BUILD_TESTING"] = self.options.with_test
tc.generate()
deps = CMakeDeps(self)
deps.generate()
@@ -40,6 +45,8 @@ class XRabbitMQClientConan(ConanFile):
cmake = CMake(self)
cmake.configure()
cmake.build()
if self.options.with_test:
cmake.test()
def package(self):
cmake = CMake(self)
@@ -47,4 +54,4 @@ class XRabbitMQClientConan(ConanFile):
def package_info(self):
self.cpp_info.libs = ["xrabbitmqclient"]
self.cpp_info.requires = ["simpleamqpclient::simpleamqpclient", "boost::boost"]
self.cpp_info.requires = ["simpleamqpclient::simpleamqpclient"]