Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add recipe for dbus-cxx #24251

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions recipes/dbus-cxx/2.x.x/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
sources:
"2.5.1":
url: "https://github.com/dbus-cxx/dbus-cxx/archive/refs/tags/2.5.1.tar.gz"
sha256: "848467b14db37710ac3ad31cc6474b2d65b9b24e6cdcbb7e88c7637c0ad7b388"
"2.4.0":
url: "https://github.com/dbus-cxx/dbus-cxx/archive/refs/tags/2.4.0.tar.gz"
sha256: "c38456ed70023d93e6e689087e4bbe030f1650bbda9de7c035d6f4ebac788379"
89 changes: 89 additions & 0 deletions recipes/dbus-cxx/2.x.x/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
from conan import ConanFile
from conan.tools.build import check_min_cppstd
from conan.tools.cmake import cmake_layout, CMake, CMakeToolchain
from conan.tools.gnu import PkgConfigDeps
from conan.tools.files import get
from conan.tools.scm import Version

class DbusCXX(ConanFile):
name = "dbus-cxx"
license = "LGPL-3.0-only", "BSD-3-Clause"
url = "https://github.com/conan-io/conan-center-index"
homepage = "http://dbus-cxx.github.io"
description = "DBus-cxx provides an object-oriented interface to DBus"
topics = "bus", "interprocess", "message"
package_type = "static-library"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this correct? this seems to be unconditionally shared
https://github.com/dbus-cxx/dbus-cxx/blob/master/CMakeLists.txt#L250

settings = "os", "compiler", "build_type", "arch"

options = {
"fPIC": [True, False],
"with_glib": [True, False],
"with_qt": [True, False],
"with_uv": [True, False],
}

@property
def _min_cppstd(self):
return 17

# Default to a relocatable static library with only the default
# standalone dispatcher
default_options = {
"fPIC": True,
"with_glib": False,
"with_qt": False,
"with_uv": False,
}

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
if Version(self.version) < "2.5.0":
del self.options.with_uv

def validate(self):
if self.settings.compiler.get_safe("cppstd"):
check_min_cppstd(self, self._min_cppstd)

def requirements(self):
self.requires("libsigcpp/3.0.7", transitive_headers=True)
self.requires("expat/[>=2.6.2 <3]")

if self.options.get_safe("with_uv"):
self.requires("libuv/[>=1.0 <2.0]")
AbrilRBS marked this conversation as resolved.
Show resolved Hide resolved

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def layout(self):
cmake_layout(self, src_folder="src")

def generate(self):
tc = CMakeToolchain(self)
tc.cache_variables["ENABLE_GLIB_SUPPORT"] = self.options.with_glib
tc.cache_variables["ENABLE_QT_SUPPORT"] = self.options.with_qt
if Version(self.version) >= "2.5.0":
tc.cache_variables["ENABLE_UV_SUPPORT"] = self.options.with_uv
tc.generate()
deps = PkgConfigDeps(self)
deps.generate()

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def package(self):
cmake = CMake(self)
cmake.install()

def package_info(self):
if self.options.with_glib:
self.cpp_info.libs.append("dbus-cxx-glib")
if self.options.with_qt:
self.cpp_info.libs.append("dbus-cxx-qt")
if self.options.get_safe("with_uv"):
self.cpp_info.libs.append("dbus-cxx-uv")

self.cpp_info.libs.append("dbus-cxx")
self.cpp_info.includedirs = ['include/dbus-cxx-2.0']
8 changes: 8 additions & 0 deletions recipes/dbus-cxx/2.x.x/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required (VERSION 3.15)
project (dbus_cxx_package_test CXX)

find_package (dbus-cxx REQUIRED CONFIG)

add_executable (test test.cpp)
target_link_libraries (test dbus-cxx::dbus-cxx)

26 changes: 26 additions & 0 deletions recipes/dbus-cxx/2.x.x/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import os

from conan import ConanFile
from conan.tools.cmake import CMake, cmake_layout
from conan.tools.build import can_run

class DbusCXXTest(ConanFile):
settings = "os", "compiler", "build_type", "arch"

def requirements(self):
self.requires(self.tested_reference_str)

generators = "CMakeToolchain", "CMakeDeps"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def layout(self):
cmake_layout(self)

def test(self):
if can_run(self):
cmd = os.path.join(self.cpp.build.bindir, "test")
self.run(cmd, env="conanrun")
7 changes: 7 additions & 0 deletions recipes/dbus-cxx/2.x.x/test_package/test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <dbus-cxx.h>

int main()
{
auto connection = DBus::Connection::create( DBus::BusType::SESSION );
return 0;
}
5 changes: 5 additions & 0 deletions recipes/dbus-cxx/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
versions:
"2.5.1":
folder: 2.x.x
"2.4.0":
folder: 2.x.x