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

build: Add pkg-config and cmake config #222

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,23 @@ if (BUILD_OPTION_GEN_COVERAGE)
message(STATUS "Enable code coverage data generation")
endif ()

set(MODERN_CPP_KAFKA_CMAKE_DESTINATION share/cmake/modern-cpp-kafka)

include(CMakePackageConfigHelpers)
configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/modern-cpp-kafka-config.cmake.in"
${CMAKE_CURRENT_BINARY_DIR}/cmake/modern-cpp-kafka-config.cmake
INSTALL_DESTINATION share/cmake/modern-cpp-kafka
NO_CHECK_REQUIRED_COMPONENTS_MACRO)

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/cmake/modern-cpp-kafka-config.cmake"
DESTINATION "${MODERN_CPP_KAFKA_CMAKE_DESTINATION}")

configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/modern-cpp-kafka.pc.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake/modern-cpp-kafka.pc" @ONLY)

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/cmake/modern-cpp-kafka.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")


#---------------------------
# Build Sub-directories
Expand Down
8 changes: 8 additions & 0 deletions cmake/modern-cpp-kafka-config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
set(MODERN_CPP_KAFKA_VERSION 2023.03.07)
...
@PACKAGE_INIT@
...
set_and_check(MODERN_CPP_KAFKA_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@")
# set_and_check(MODERN_CPP_KAFKA_SYSCONFIG_DIR "@PACKAGE_SYSCONFIG_INSTALL_DIR@")

check_required_components(ModernCppKafka)
10 changes: 10 additions & 0 deletions cmake/modern-cpp-kafka.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
includedir=${prefix}/include

Name: modern-cpp-kafka
Description: A C++ API for Kafka clients (i.e. KafkaProducer, KafkaConsumer, AdminClient)
Version: @PROJECT_VERSION@
URL: https://github.com/morganstanley/modern-cpp-kafka
Requires: @MODERN_CPP_KAFKA_DEPENDS@
Cflags: -I${includedir}