Skip to content

Commit b522592

Browse files
committed
Make FindRdKafka.cmake work on Windows
1 parent 9c9d1e4 commit b522592

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

cmake/FindRdKafka.cmake

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ find_path(RDKAFKA_INCLUDE_DIR
77
HINTS ${RDKAFKA_ROOT_DIR}/include
88
)
99

10-
set (HINT_DIR ${RDKAFKA_ROOT_DIR}/lib)
10+
set(HINT_DIR ${RDKAFKA_ROOT_DIR}/lib)
1111

1212
find_library(RDKAFKA_LIBRARY
13-
NAMES rdkafka
13+
NAMES rdkafka librdkafka
1414
HINTS ${HINT_DIR}
1515
)
1616

@@ -20,11 +20,13 @@ find_package_handle_standard_args(RDKAFKA DEFAULT_MSG
2020
RDKAFKA_INCLUDE_DIR
2121
)
2222

23-
include(CheckFunctionExists)
23+
set(CONTENTS "#include <librdkafka/rdkafka.h>\n #if RD_KAFKA_VERSION >= 0x00090400\n int main() { }\n #endif")
24+
set(FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/rdkafka_version_test.c)
25+
file(WRITE ${FILE_NAME} ${CONTENTS})
2426

25-
set(CMAKE_REQUIRED_LIBRARIES ${RDKAFKA_LIBRARY})
26-
check_function_exists(rd_kafka_offsets_for_times HAVE_VALID_KAFKA_VERSION)
27-
set(CMAKE_REQUIRED_LIBRARIES)
27+
try_compile(HAVE_VALID_KAFKA_VERSION ${CMAKE_CURRENT_BINARY_DIR}
28+
SOURCES ${FILE_NAME}
29+
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${RDKAFKA_INCLUDE_DIR}")
2830

2931
if (HAVE_VALID_KAFKA_VERSION)
3032
message(STATUS "Found valid rdkafka version")

0 commit comments

Comments
 (0)