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

Make find_package work for rmqcpp #15

Merged
merged 2 commits into from
Oct 26, 2023

Conversation

ahsanabbas123
Copy link
Contributor

@ahsanabbas123 ahsanabbas123 commented Oct 25, 2023

Problem statement

Make find_package(rmqcpp REQUIRED) work for applications installing rmqcpp using a package manager like vcpkg.

Proposed changes

* 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::
Comment on lines +26 to +28
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>)
Copy link
Contributor Author

@ahsanabbas123 ahsanabbas123 Oct 25, 2023

Choose a reason for hiding this comment

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

These generator expressions are required if we are creating a relocatable package (with no absolute paths) which uses install(TARGETS) and install(EXPORT) later to produce the rmqcppTargets.cmake file.

Comment on lines +4 to +6
foreach(dep bal;OpenSSL;ZLIB)
find_package(${dep})
endforeach()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are needed so that the consuming upstream application does not need to explicitly do find_package(dep) for deps of rmqcpp.

NAMESPACE rmqcpp::)

include(CMakePackageConfigHelpers)
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This uses Config.cmake.in as input and produces the rmqcppConfig.cmake which find_package looks for.

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

Choose a reason for hiding this comment

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

We decided to go with rmqcpp::rmq be how users link to rmqcpp, with rmqcpp::rmqtestmocks a possibility in future.

@ahsanabbas123 ahsanabbas123 merged commit 093aaa1 into bloomberg:main Oct 26, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants