summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorKefu Chai <kchai@redhat.com>2019-12-13 12:02:22 +0100
committerKefu Chai <kchai@redhat.com>2019-12-15 15:16:08 +0100
commit1f8e3bd5e7abee3d8597aaa65fe19430abe23766 (patch)
tree214c6235c1f8f34b9516f392cb707facfea43d9d /cmake
parentMerge PR #32158 into master (diff)
downloadceph-1f8e3bd5e7abee3d8597aaa65fe19430abe23766.tar.xz
ceph-1f8e3bd5e7abee3d8597aaa65fe19430abe23766.zip
cmake: check version of librdkafka
Signed-off-by: Kefu Chai <kchai@redhat.com>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/modules/FindRDKafka.cmake36
1 files changed, 25 insertions, 11 deletions
diff --git a/cmake/modules/FindRDKafka.cmake b/cmake/modules/FindRDKafka.cmake
index 0d2f3b74df5..78f7d825c03 100644
--- a/cmake/modules/FindRDKafka.cmake
+++ b/cmake/modules/FindRDKafka.cmake
@@ -1,19 +1,33 @@
+find_package(PkgConfig QUIET)
+
+pkg_search_module(PC_rdkafka
+ rdkafka)
+
find_path(rdkafka_INCLUDE_DIR
- NAMES librdkafka/rdkafka.h)
+ NAMES librdkafka/rdkafka.h
+ PATHS ${PC_rdkafka_INCLUDE_DIRS})
find_library(rdkafka_LIBRARY
- NAMES rdkafka)
+ NAMES rdkafka
+ PATHS ${PC_rdkafka_LIBRARY_DIRS})
include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(RDKafka
+ REQUIRED_VARS rdkafka_INCLUDE_DIR rdkafka_LIBRARY
+ VERSION_VAR PC_rdkafka_VERSION)
-find_package_handle_standard_args(RDKafka DEFAULT_MSG
- rdkafka_INCLUDE_DIR
- rdkafka_LIBRARY)
+if(RDKafka_FOUND)
+ set(RDKafka_VERSION ${PC_rdkafka_VERSION})
+ string(REPLACE "." ";" version_list ${PC_rdkafka_VERSION})
+ list(GET version_list 0 RDKafka_VERSION_MAJOR)
+ list(GET version_list 1 RDKafka_VERSION_MINOR)
+ list(GET version_list 2 RDKafka_VERSION_PATCH)
-if(RDKafka_FOUND AND NOT (TARGET RDKafka::RDKafka))
- add_library(RDKafka::RDKafka UNKNOWN IMPORTED)
- set_target_properties(RDKafka::RDKafka PROPERTIES
- INTERFACE_INCLUDE_DIRECTORIES "${rdkafka_INCLUDE_DIR}"
- IMPORTED_LINK_INTERFACE_LANGUAGES "C"
- IMPORTED_LOCATION "${rdkafka_LIBRARY}")
+ if(NOT TARGET RDKafka::RDKafka)
+ add_library(RDKafka::RDKafka UNKNOWN IMPORTED)
+ set_target_properties(RDKafka::RDKafka PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${rdkafka_INCLUDE_DIR}"
+ IMPORTED_LINK_INTERFACE_LANGUAGES "C"
+ IMPORTED_LOCATION "${rdkafka_LIBRARY}")
+ endif()
endif()