From bd43d3c767b3e36bad43228aa535612ab9d447a5 Mon Sep 17 00:00:00 2001 From: Alexander Damian Date: Fri, 26 Apr 2019 16:19:54 -0400 Subject: [PATCH 1/3] Support for generating pkg-config file --- cppkafka.pc.in | 14 ++++++++++++++ include/cppkafka/CMakeLists.txt | 2 +- src/CMakeLists.txt | 12 +++++++++++- 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 cppkafka.pc.in diff --git a/cppkafka.pc.in b/cppkafka.pc.in new file mode 100644 index 0000000..a3450af --- /dev/null +++ b/cppkafka.pc.in @@ -0,0 +1,14 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=${prefix} +libdir=${prefix}/lib +sharedlibdir=${prefix}/lib +includedir=${prefix}/include + +Name: cppkafka +Url: https://github.com/mfontanini/cppkafka +Description: C++ wrapper library on top of RdKafka +Version: @CPPKAFKA_VERSION@ +Requires: librdkafka >= 0.9.4 +Requires.private: +Libs: -L${libdir} -L${sharedlibdir} -L@RDKAFKA_ROOT_DIR@/lib -lcppkafka -lrdkafka -lpthread -lrt -lssl -lcrypto -ldl -lz +Cflags: -I${includedir} -I${includedir}/cppkafka -I@RDKAFKA_ROOT_DIR@/include diff --git a/include/cppkafka/CMakeLists.txt b/include/cppkafka/CMakeLists.txt index 2faeac6..18bd1bd 100644 --- a/include/cppkafka/CMakeLists.txt +++ b/include/cppkafka/CMakeLists.txt @@ -10,7 +10,7 @@ function(make_cppkafka_header) endforeach() #create file from template - configure_file(${PROJECT_SOURCE_DIR}/cppkafka.h.in ${CPPKAFKA_HEADER}) + configure_file(${PROJECT_SOURCE_DIR}/cppkafka.h.in ${CPPKAFKA_HEADER} @ONLY) endfunction() # Run file generation function diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5d31078..3911fc8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -41,9 +41,19 @@ endif() target_link_libraries(cppkafka ${DEPENDENCIES}) target_include_directories(cppkafka PUBLIC ${PROJECT_SOURCE_DIR}/include) -install( +install( TARGETS cppkafka LIBRARY DESTINATION lib ARCHIVE DESTINATION lib COMPONENT dev ) + +# Generate package configuration file +set(PKG_CONFIG ${PROJECT_SOURCE_DIR}/package/cppkafka.pc) +configure_file(${PROJECT_SOURCE_DIR}/cppkafka.pc.in ${PKG_CONFIG} @ONLY) + +install( + FILES PKG_CONFIG + DESTINATION share/pkgconfig + COMPONENT pkgconfig +) From 24e94fbfbc0adb26475fc99545a16f95fc734426 Mon Sep 17 00:00:00 2001 From: Alexander Damian Date: Wed, 8 May 2019 10:28:49 -0400 Subject: [PATCH 2/3] Added boost include dirs to pkg config file --- cppkafka.pc.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cppkafka.pc.in b/cppkafka.pc.in index a3450af..f0b8214 100644 --- a/cppkafka.pc.in +++ b/cppkafka.pc.in @@ -11,4 +11,4 @@ Version: @CPPKAFKA_VERSION@ Requires: librdkafka >= 0.9.4 Requires.private: Libs: -L${libdir} -L${sharedlibdir} -L@RDKAFKA_ROOT_DIR@/lib -lcppkafka -lrdkafka -lpthread -lrt -lssl -lcrypto -ldl -lz -Cflags: -I${includedir} -I${includedir}/cppkafka -I@RDKAFKA_ROOT_DIR@/include +Cflags: -I${includedir} -I${includedir}/cppkafka -I@RDKAFKA_ROOT_DIR@/include -I@Boost_INCLUDE_DIRS@ From d148fe18d5ef50785918cbb52ec9f65d132e345e Mon Sep 17 00:00:00 2001 From: Alexander Damian Date: Wed, 15 May 2019 13:44:07 -0400 Subject: [PATCH 3/3] Added config option for PKGCONFIG install location --- CMakeLists.txt | 4 ++++ README.md | 1 + cppkafka.pc.in | 2 +- src/CMakeLists.txt | 4 ++-- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1256923..6982697 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,6 +56,10 @@ if (CPPKAFKA_RDKAFKA_STATIC_LIB) add_definitions("-DLIBRDKAFKA_STATICLIB") endif() +if (NOT CPPKAFKA_PKGCONFIG_DIR) + set(CPPKAFKA_PKGCONFIG_DIR share/pkgconfig) +endif() + # Look for Boost (just need boost.optional headers here) find_package(Boost REQUIRED ${FIND_PACKAGE_QUIET}) find_package(RdKafka REQUIRED ${FIND_PACKAGE_QUIET}) diff --git a/README.md b/README.md index f4e6bf9..c9ae7d7 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,7 @@ The following cmake options can be specified: * `CPPKAFKA_BOOST_STATIC_LIBS` : Link with Boost static libraries. Default is `ON`. * `CPPKAFKA_BOOST_USE_MULTITHREADED` : Use Boost multi-threaded libraries. Default is `ON`. * `CPPKAFKA_RDKAFKA_STATIC_LIB` : Link to Rdkafka static library. Default is `OFF`. +* `CPPKAFKA_PKGCONFIG_DIR` : Install location of the .pc file. Default is `share/pkgconfig`. Example: ```Shell diff --git a/cppkafka.pc.in b/cppkafka.pc.in index f0b8214..65c6237 100644 --- a/cppkafka.pc.in +++ b/cppkafka.pc.in @@ -11,4 +11,4 @@ Version: @CPPKAFKA_VERSION@ Requires: librdkafka >= 0.9.4 Requires.private: Libs: -L${libdir} -L${sharedlibdir} -L@RDKAFKA_ROOT_DIR@/lib -lcppkafka -lrdkafka -lpthread -lrt -lssl -lcrypto -ldl -lz -Cflags: -I${includedir} -I${includedir}/cppkafka -I@RDKAFKA_ROOT_DIR@/include -I@Boost_INCLUDE_DIRS@ +Cflags: -I${includedir} -I${includedir}/cppkafka -I@RDKAFKA_INCLUDE_DIR@ -I@Boost_INCLUDE_DIRS@ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3911fc8..ff0fba1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -53,7 +53,7 @@ set(PKG_CONFIG ${PROJECT_SOURCE_DIR}/package/cppkafka.pc) configure_file(${PROJECT_SOURCE_DIR}/cppkafka.pc.in ${PKG_CONFIG} @ONLY) install( - FILES PKG_CONFIG - DESTINATION share/pkgconfig + FILES ${PKG_CONFIG} + DESTINATION ${CPPKAFKA_PKGCONFIG_DIR} COMPONENT pkgconfig )