From 5ae3d6a9af07e479fe122b533ad80bb4f60d15fa Mon Sep 17 00:00:00 2001 From: Robert Adam Date: Sat, 3 Jan 2026 19:15:25 +0100 Subject: [PATCH 1/2] feat: add export support This makes sdbus-c++ consumable from the build tree without the need for an explicit installation. This can be very handy for e.g. testing purposes. Crucially, downstream projects will depend on upstream to properly export everything. Otherwise, they can't be built as static libraries, even if sdbus-c++ is only a private dependency. See also https://runebook.dev/en/docs/cmake/command/export --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index cbb614bc..b6761d33 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -313,6 +313,11 @@ if(SDBUSCPP_INSTALL) endif() endif() +export(TARGETS ${EXPORT_SET} + NAMESPACE SDBusCpp:: + FILE sdbus-c++-targets.cmake +) + #---------------------------------- # CPACK #---------------------------------- From b6baba33283796b6e28b44e6dc78803695c75289 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanislav=20Angelovi=C4=8D?= Date: Mon, 5 Jan 2026 20:09:49 +0100 Subject: [PATCH 2/2] fix(cmake): avoid possibly empty EXPORT_SET EXPORT_SET is empty when SDBUSCPP_INSTALL is OFF, which leads to targets file with no targets. --- CMakeLists.txt | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b6761d33..1888ea98 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -284,14 +284,23 @@ set(PKGCONFIG_DEPS ${SDBUS_LIB}) configure_file(pkgconfig/sdbus-c++.pc.in pkgconfig/sdbus-c++.pc @ONLY) #---------------------------------- -# INSTALLATION +# EXPORTING BUILD-TREE TARGETS +#---------------------------------- + +set(EXPORT_SET sdbus-c++) +if(NOT BUILD_SHARED_LIBS) + list(APPEND EXPORT_SET "sdbus-c++-objlib") +endif() + +export(TARGETS ${EXPORT_SET} + NAMESPACE SDBusCpp:: + FILE sdbus-c++-targets.cmake) + +#---------------------------------- +# INSTALLATION & EXPORTING INSTALL-TREE TARGETS #---------------------------------- if(SDBUSCPP_INSTALL) - set(EXPORT_SET sdbus-c++) - if(NOT BUILD_SHARED_LIBS) - list(APPEND EXPORT_SET "sdbus-c++-objlib") - endif() install(TARGETS ${EXPORT_SET} EXPORT sdbus-c++-targets RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT sdbus-c++-runtime @@ -313,11 +322,6 @@ if(SDBUSCPP_INSTALL) endif() endif() -export(TARGETS ${EXPORT_SET} - NAMESPACE SDBusCpp:: - FILE sdbus-c++-targets.cmake -) - #---------------------------------- # CPACK #----------------------------------