Search code examples
c++cmakelibrdkafka

librdkafka not found by CMake


I'm trying to use Kafka in a project that uses CMake to be built.

I have librdkafka-dev (version 0.8.6-1.1) installed.

I also tried downloading the project from Git and building it manually, which seem to be successful.

I noticed a README.md file in the librdkafka/packaging/cmake and followed its instructions, successfully creating a CMake build of librdkafka in the directory.

Running the 'cmake' command in my project results in the following error:

CMake Error at CMakeLists.txt:8 (find_package):
  By not providing "Findlibrdkafka.cmake" in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file provided by
  "librdkafka", but CMake did not find one.

  Could not find a package configuration file provided by "librdkafka" with
  any of the following names:

    librdkafkaConfig.cmake
    librdkafka-config.cmake

  Add the installation prefix of "librdkafka" to CMAKE_PREFIX_PATH or set
  "librdkafka_DIR" to a directory containing one of the above files.  If
  "librdkafka" provides a separate development package or SDK, be sure it has
  been installed.

It is possible that librdkafka is simply the wrong package name to look for rdkafka in a CMakeLists.txt file, but I haven't found out how to add it to CMake without using the Cppkafka wrapper.

So I tried downloading and building Cppkafka (running the cmake .. inside its directory's folder), and it results in the following error:

-- Build will generate a shared library. Use CPPKAFKA_BUILD_SHARED=0 to perform a static build
-- RdKafkaConfig.cmake not found. Attempting to find module instead...
-- Could NOT find RDKAFKA (missing: RdKafka_LIBRARY_DIR) 
-- Found valid rdkafka version
-- RdKafka module found.
-- Disabling tests because submodule Catch2 isn't checked out
-- Configuring done
CMake Error in src/CMakeLists.txt:
  Target "RdKafka::rdkafka" contains relative path in its
  INTERFACE_LINK_DIRECTORIES:

    "RdKafka_LIBRARY_DIR-NOTFOUND"

Thank you for any help!


Solution

  • This solved itself. Apparently, this was a bug with the CppKafka library and was already solved by the developers.