Skip to content

Commit

Permalink
Find package rmqcpp (#1)
Browse files Browse the repository at this point in the history
* find_package?

* cmake_install_libdir

* use CMAKE_CURRENT_SOURCE_DIR for BUILD_INTERFACE

* export target command

* export config

* export dest

* test install to multiple locations

* export config to prefix/share/rmqcpp

* rm export and only install

* export targets

* add Config.cmake.in

* make target_link_libraries interface instead of public

* find_dependency ZLIB

* find_dependency in cmake.in, change ns

* revert explicit find_dependency

* find_package in cmake.in

* namespace rmqcpp::
  • Loading branch information
ahsanabbas123 committed Oct 26, 2023
1 parent cb27b7a commit 093aaa1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/rmq/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,17 @@ endif()

target_compile_definitions(rmq PRIVATE USES_LIBRMQ_EXPERIMENTAL_FEATURES)

target_include_directories(rmq PUBLIC rmqt rmqp rmqa)
target_include_directories(rmq PUBLIC $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/rmqt>)
target_include_directories(rmq PUBLIC $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/rmqp>)
target_include_directories(rmq PUBLIC $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/rmqa>)


file(GLOB RMQ_PUBLIC_HEADERS rmqa/*h rmqp/*h rmqt/*h)
set_target_properties(rmq PROPERTIES PUBLIC_HEADER "${RMQ_PUBLIC_HEADERS}")

install(
TARGETS rmq
EXPORT rmqcppTargets
ARCHIVE
DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT librmq-dev
Expand All @@ -38,6 +42,17 @@ install(
COMPONENT librmq-dev
)

install(EXPORT rmqcppTargets
FILE rmqcppTargets.cmake
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/rmqcpp
NAMESPACE rmqcpp::)

include(CMakePackageConfigHelpers)
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/rmqcppConfig.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}/share/rmqcpp)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/rmqcppConfig.cmake" DESTINATION ${CMAKE_INSTALL_PREFIX}/share/rmqcpp)

# Emit some metadata required internally
set(RMQ_PC_DEP_NAMES bsl bdl bal openssl)
find_package(GenBDEMetadata QUIET)
Expand All @@ -47,4 +62,4 @@ endif()
find_package(EmitPkgConfigFile QUIET)
if (EmitPkgConfigFile_FOUND)
emit_pkgconfig_file(PKG rmq INSTALL_COMPONENT librmq-dev DEPS "${RMQ_PC_DEP_NAMES}")
endif()
endif()
11 changes: 11 additions & 0 deletions src/rmq/Config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@PACKAGE_INIT@

if(NOT TARGET rmqcpp)
foreach(dep bal;OpenSSL;ZLIB)
find_package(${dep})
endforeach()
endif()

include("${CMAKE_CURRENT_LIST_DIR}/rmqcppTargets.cmake")

check_required_components(rmqcpp)

0 comments on commit 093aaa1

Please sign in to comment.