File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ project(cppkafka)
55set (CPPKAFKA_VERSION_MAJOR 0)
66set (CPPKAFKA_VERSION_MINOR 1)
77set (CPPKAFKA_VERSION "${CPPKAFKA_VERSION_MAJOR} .${CPPKAFKA_VERSION_MINOR} " )
8+ set (RDKAFKA_MIN_VERSION 0x00090400)
89
910if (MSVC )
1011 # Don't always use Wall, since VC's /Wall is ridiculously verbose.
@@ -30,6 +31,7 @@ option(CPPKAFKA_DISABLE_TESTS "Disable build of cppkafka tests." OFF)
3031option (CPPKAFKA_DISABLE_EXAMPLES "Disable build of cppkafka examples." OFF )
3132option (CPPKAFKA_BOOST_STATIC_LIBS "Link with Boost static libraries." ON )
3233option (CPPKAFKA_BOOST_USE_MULTITHREADED "Use Boost multithreaded libraries." ON )
34+ option (CPPKAFKA_RDKAFKA_STATIC_LIB "Link with Rdkafka static library." OFF )
3335
3436# Disable output from find_package macro
3537if (NOT CPPKAFKA_CMAKE_VERBOSE)
Original file line number Diff line number Diff line change @@ -77,20 +77,25 @@ The following cmake options can be specified:
7777* ` CPPKAFKA_DISABLE_EXAMPLES ` : Disable build of cppkafka examples. Default is ` OFF ` .
7878* ` CPPKAFKA_BOOST_STATIC_LIBS ` : Link with Boost static libraries. Default is ` ON ` .
7979* ` CPPKAFKA_BOOST_USE_MULTITHREADED ` : Use Boost multi-threaded libraries. Default is ` ON ` .
80+ * ` CPPKAFKA_RDKAFKA_STATIC_LIB ` : Link to Rdkafka static library. Default is ` OFF ` .
8081
8182Example:
8283``` Shell
8384cmake -DRDKAFKA_ROOT_DIR=/some/other/dir -DCPPKAFKA_BUILD_SHARED=OFF ...
8485```
8586
86- Note that the ` RDKAFKA_ROOT_DIR ` must contain the following structure:
87+ The ` RDKAFKA_ROOT_DIR ` must contain the following structure. If the system
88+ architecture is 64-bit and both ` lib ` and ` lib64 ` folders are available, the ` lib64 `
89+ folder location will be selected by cmake.
8790
8891``` Shell
8992${RDKAFKA_ROOT_DIR} /
9093 |
9194 + include/librdkafka/rdkafka.h
9295 |
9396 + lib/librdkafka.a
97+ |
98+ + lib64/librdkafka.a (optional)
9499```
95100
96101# Using
Original file line number Diff line number Diff line change 1+ # Override default CMAKE_FIND_LIBRARY_SUFFIXES
2+ if (CPPKAFKA_RDKAFKA_STATIC_LIB)
3+ if (MSVC )
4+ set (RDKAFKA_SUFFIX lib)
5+ else ()
6+ set (RDKAFKA_SUFFIX a)
7+ endif ()
8+ else ()
9+ if (MSVC )
10+ set (RDKAFKA_SUFFIX dll)
11+ else ()
12+ set (RDKAFKA_SUFFIX so)
13+ endif ()
14+ endif ()
15+
16+ # Check property
17+ if (CPPKAFKA_CMAKE_VERBOSE)
18+ get_property (FIND_LIBRARY_64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS )
19+ MESSAGE (STATUS "RDKAFKA search 64-bit library paths: ${FIND_LIBRARY_64} " )
20+ endif ()
21+
122find_path (RDKAFKA_ROOT_DIR
223 NAMES include /librdkafka/rdkafka.h
324)
@@ -7,11 +28,9 @@ find_path(RDKAFKA_INCLUDE_DIR
728 HINTS ${RDKAFKA_ROOT_DIR} /include
829)
930
10- set (HINT_DIR ${RDKAFKA_ROOT_DIR} /lib)
11-
1231find_library (RDKAFKA_LIBRARY
13- NAMES rdkafka librdkafka
14- HINTS ${HINT_DIR}
32+ NAMES rdkafka.${RDKAFKA_SUFFIX} librdkafka.${RDKAFKA_SUFFIX} rdkafka
33+ HINTS ${RDKAFKA_ROOT_DIR} /lib
1534)
1635
1736include (FindPackageHandleStandardArgs )
@@ -20,7 +39,7 @@ find_package_handle_standard_args(RDKAFKA DEFAULT_MSG
2039 RDKAFKA_INCLUDE_DIR
2140)
2241
23- set (CONTENTS "#include <librdkafka/rdkafka.h>\n #if RD_KAFKA_VERSION >= 0x00090400 \n int main() { }\n #endif" )
42+ set (CONTENTS "#include <librdkafka/rdkafka.h>\n #if RD_KAFKA_VERSION >= ${RDKAFKA_MIN_VERSION} \n int main() { }\n #endif" )
2443set (FILE_NAME ${CMAKE_CURRENT_BINARY_DIR} /rdkafka_version_test.c)
2544file (WRITE ${FILE_NAME} ${CONTENTS} )
2645
You can’t perform that action at this time.
0 commit comments