summaryrefslogtreecommitdiffstats
path: root/cmake/modules/FindRDKafka.cmake
blob: 78f7d825c0315ccef6f2768787d9ec3eee60f5bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
find_package(PkgConfig QUIET)

pkg_search_module(PC_rdkafka
  rdkafka)

find_path(rdkafka_INCLUDE_DIR
  NAMES librdkafka/rdkafka.h
  PATHS ${PC_rdkafka_INCLUDE_DIRS})

find_library(rdkafka_LIBRARY
  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)

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(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()