File tree 3 files changed +32
-6
lines changed
3 files changed +32
-6
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ project(cppkafka)
5
5
set (CPPKAFKA_VERSION_MAJOR 0)
6
6
set (CPPKAFKA_VERSION_MINOR 1)
7
7
set (CPPKAFKA_VERSION "${CPPKAFKA_VERSION_MAJOR} .${CPPKAFKA_VERSION_MINOR} " )
8
+ set (RDKAFKA_MIN_VERSION 0x00090400)
8
9
9
10
if (MSVC )
10
11
# 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)
30
31
option (CPPKAFKA_DISABLE_EXAMPLES "Disable build of cppkafka examples." OFF )
31
32
option (CPPKAFKA_BOOST_STATIC_LIBS "Link with Boost static libraries." ON )
32
33
option (CPPKAFKA_BOOST_USE_MULTITHREADED "Use Boost multithreaded libraries." ON )
34
+ option (CPPKAFKA_RDKAFKA_STATIC_LIB "Link with Rdkafka static library." OFF )
33
35
34
36
# Disable output from find_package macro
35
37
if (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:
77
77
* ` CPPKAFKA_DISABLE_EXAMPLES ` : Disable build of cppkafka examples. Default is ` OFF ` .
78
78
* ` CPPKAFKA_BOOST_STATIC_LIBS ` : Link with Boost static libraries. Default is ` ON ` .
79
79
* ` 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 ` .
80
81
81
82
Example:
82
83
``` Shell
83
84
cmake -DRDKAFKA_ROOT_DIR=/some/other/dir -DCPPKAFKA_BUILD_SHARED=OFF ...
84
85
```
85
86
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.
87
90
88
91
``` Shell
89
92
${RDKAFKA_ROOT_DIR} /
90
93
|
91
94
+ include/librdkafka/rdkafka.h
92
95
|
93
96
+ lib/librdkafka.a
97
+ |
98
+ + lib64/librdkafka.a (optional)
94
99
```
95
100
96
101
# 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
+
1
22
find_path (RDKAFKA_ROOT_DIR
2
23
NAMES include /librdkafka/rdkafka.h
3
24
)
@@ -7,11 +28,9 @@ find_path(RDKAFKA_INCLUDE_DIR
7
28
HINTS ${RDKAFKA_ROOT_DIR} /include
8
29
)
9
30
10
- set (HINT_DIR ${RDKAFKA_ROOT_DIR} /lib)
11
-
12
31
find_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
15
34
)
16
35
17
36
include (FindPackageHandleStandardArgs)
@@ -20,7 +39,7 @@ find_package_handle_standard_args(RDKAFKA DEFAULT_MSG
20
39
RDKAFKA_INCLUDE_DIR
21
40
)
22
41
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" )
24
43
set (FILE_NAME ${CMAKE_CURRENT_BINARY_DIR} /rdkafka_version_test.c)
25
44
file (WRITE ${FILE_NAME} ${CONTENTS} )
26
45
You can’t perform that action at this time.
0 commit comments