Skip to content

Commit 44aa4f0

Browse files
Krzmbrzlsangelovic
andauthored
feat(cmake): add export support (#523)
* 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 * fix(cmake): avoid possibly empty EXPORT_SET EXPORT_SET is empty when SDBUSCPP_INSTALL is OFF, which leads to targets file with no targets. --------- Co-authored-by: Stanislav Angelovič <stanislav.angelovic@protonmail.com>
1 parent 6715ef1 commit 44aa4f0

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

CMakeLists.txt

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,14 +284,23 @@ set(PKGCONFIG_DEPS ${SDBUS_LIB})
284284
configure_file(pkgconfig/sdbus-c++.pc.in pkgconfig/sdbus-c++.pc @ONLY)
285285

286286
#----------------------------------
287-
# INSTALLATION
287+
# EXPORTING BUILD-TREE TARGETS
288+
#----------------------------------
289+
290+
set(EXPORT_SET sdbus-c++)
291+
if(NOT BUILD_SHARED_LIBS)
292+
list(APPEND EXPORT_SET "sdbus-c++-objlib")
293+
endif()
294+
295+
export(TARGETS ${EXPORT_SET}
296+
NAMESPACE SDBusCpp::
297+
FILE sdbus-c++-targets.cmake)
298+
299+
#----------------------------------
300+
# INSTALLATION & EXPORTING INSTALL-TREE TARGETS
288301
#----------------------------------
289302

290303
if(SDBUSCPP_INSTALL)
291-
set(EXPORT_SET sdbus-c++)
292-
if(NOT BUILD_SHARED_LIBS)
293-
list(APPEND EXPORT_SET "sdbus-c++-objlib")
294-
endif()
295304
install(TARGETS ${EXPORT_SET}
296305
EXPORT sdbus-c++-targets
297306
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT sdbus-c++-runtime

0 commit comments

Comments
 (0)