From 107cff7ed7eee9783fe77ab7b71670dde0621862 Mon Sep 17 00:00:00 2001 From: Alexander Damian Date: Mon, 20 May 2019 09:55:23 -0400 Subject: [PATCH 1/2] Removed dependency from rdkafka since it has its own pkg_config file. Also added BITNESS detection --- CMakeLists.txt | 10 ++++++++++ cppkafka.pc.in | 12 ++++++------ src/CMakeLists.txt | 4 ++-- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 758e7810..3ebe9db0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,6 +38,16 @@ option(CPPKAFKA_BOOST_STATIC_LIBS "Link with Boost static libraries." ON) option(CPPKAFKA_BOOST_USE_MULTITHREADED "Use Boost multithreaded libraries." ON) option(CPPKAFKA_RDKAFKA_STATIC_LIB "Link with Rdkafka static library." OFF) +# Determine if this is a 32 or 64 bit build +string(FIND ${CMAKE_CXX_FLAGS} "-m64" BITNESS) + +# Properly set the output directory +if (${BITNESS} EQUAL -1) + set(LIBDIR "lib") +else() + set(LIBDIR "lib64") +endif() + # Disable output from find_package macro if (NOT CPPKAFKA_CMAKE_VERBOSE) set(FIND_PACKAGE_QUIET QUIET) diff --git a/cppkafka.pc.in b/cppkafka.pc.in index 9a4489db..7d573257 100644 --- a/cppkafka.pc.in +++ b/cppkafka.pc.in @@ -1,14 +1,14 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} -libdir=${prefix}/lib -sharedlibdir=${prefix}/lib +libdir=${prefix}/@LIBDIR@ +sharedlibdir=${prefix}/@LIBDIR@ includedir=${prefix}/include Name: cppkafka Url: https://github.com/mfontanini/cppkafka Description: C++ wrapper library on top of RdKafka Version: @CPPKAFKA_VERSION@ -Requires: rdkafka >= 0.9.4 boost -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_INCLUDE_DIR@ -I@Boost_INCLUDE_DIRS@ +Requires: +Requires.private: rdkafka >= 0.9.4, boost +Libs: -L${libdir} -L${sharedlibdir} -lcppkafka +Cflags: -I${includedir} -I${includedir}/cppkafka diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ff0fba18..d5d50fe9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -43,8 +43,8 @@ target_include_directories(cppkafka PUBLIC ${PROJECT_SOURCE_DIR}/include) install( TARGETS cppkafka - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib + LIBRARY DESTINATION ${LIBDIR} + ARCHIVE DESTINATION ${LIBDIR} COMPONENT dev ) From 07b3c4957d46ec3f2d92fdbd4e5f2bb86663b115 Mon Sep 17 00:00:00 2001 From: Alexander Damian Date: Tue, 21 May 2019 08:52:03 -0400 Subject: [PATCH 2/2] Changed method to determine bitness --- CMakeLists.txt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ebe9db0..eebfa5f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,14 +38,13 @@ option(CPPKAFKA_BOOST_STATIC_LIBS "Link with Boost static libraries." ON) option(CPPKAFKA_BOOST_USE_MULTITHREADED "Use Boost multithreaded libraries." ON) option(CPPKAFKA_RDKAFKA_STATIC_LIB "Link with Rdkafka static library." OFF) -# Determine if this is a 32 or 64 bit build -string(FIND ${CMAKE_CXX_FLAGS} "-m64" BITNESS) +math(EXPR BITS "8*${CMAKE_SIZEOF_VOID_P}") # Properly set the output directory -if (${BITNESS} EQUAL -1) - set(LIBDIR "lib") -else() +if (${BITS} EQUAL 64) set(LIBDIR "lib64") +else() + set(LIBDIR "lib") endif() # Disable output from find_package macro