Added RdKafka hex version so that FindRdKafka.cmake can compile the test code. Changed find_dependency to find_package for the RdKafka config so that the script is not automatically exited on failure

This commit is contained in:
Alexander Damian
2019-07-02 15:30:33 -04:00
parent 4bddb2241c
commit ad800a5765
3 changed files with 5 additions and 3 deletions

View File

@@ -54,7 +54,7 @@ find_package_handle_standard_args(RDKAFKA DEFAULT_MSG
)
set(CONTENTS "#include <librdkafka/rdkafka.h>\n #if RD_KAFKA_VERSION >= ${RDKAFKA_MIN_VERSION_HEX}\n int main() { }\n #endif")
set(FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/rdkafka_version_test.c)
set(FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/rdkafka_version_test.cpp)
file(WRITE ${FILE_NAME} ${CONTENTS})
try_compile(RdKafka_FOUND ${CMAKE_CURRENT_BINARY_DIR}

View File

@@ -5,12 +5,14 @@ include(CMakeFindDependencyMacro)
# Add FindRdKafka.cmake
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}")
set(RDKAFKA_MIN_VERSION_HEX "@RDKAFKA_MIN_VERSION_HEX@")
# Find boost optional
find_dependency(Boost REQUIRED)
# Try to find the RdKafka configuration file if present.
# This will search default system locations as well as RdKafka_ROOT and RdKafka_Dir paths if specified.
find_dependency(RdKafka QUIET CONFIG)
find_package(RdKafka QUIET CONFIG)
set(RDKAFKA_TARGET_IMPORTS ${RdKafka_FOUND})
if (NOT RdKafka_FOUND)
find_dependency(RdKafka REQUIRED MODULE)

View File

@@ -86,7 +86,7 @@ configure_package_config_file(
"${PROJECT_SOURCE_DIR}/cmake/config.cmake.in"
"${CONFIG_FILE}"
INSTALL_DESTINATION "${CPPKAFKA_CONFIG_DIR}"
PATH_VARS CMAKE_INSTALL_PREFIX CMAKE_INSTALL_INCLUDEDIR CMAKE_INSTALL_LIBDIR
PATH_VARS RDKAFKA_MIN_VERSION_HEX CMAKE_INSTALL_PREFIX CMAKE_INSTALL_INCLUDEDIR CMAKE_INSTALL_LIBDIR
)
# Generate version file