Skip to content

Commit 6715ef1

Browse files
authored
feat: create cmake alias for consistent downstream usage (#522)
At the moment, downstream projects will have to differentiate based off the way the obtained sdbus-c++ in CMake. If they use `find_package`, the target they have to use is `SDBusCpp::sdbus-c++`, whereas the target is merely `sdbus-c++` if they use `FetchContent` (i.e. use without installation). By creating an alias target, it is now always possible to use the `DBusCpp::sdbus-c++` target regardless of how the library was obtained.
1 parent 28b7882 commit 6715ef1

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,9 @@ target_link_libraries(sdbus-c++-objlib
216216
Threads::Threads)
217217

218218
add_library(sdbus-c++)
219+
# Create alias to allow consistent target use regardless whether used in-source or found via find_package
220+
add_library(SDBusCpp::sdbus-c++ ALIAS sdbus-c++)
221+
219222
target_include_directories(sdbus-c++ PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
220223
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
221224
set_target_properties(sdbus-c++

0 commit comments

Comments
 (0)