rust-rdkafka icon indicating copy to clipboard operation
rust-rdkafka copied to clipboard

CMake 4.x breaks compatibility with librdkafka 2.3.0

Open fabiandiez opened this issue 9 months ago • 3 comments

Problem Description

CMake 4.0 was recently released, which enforces that versions that do not advertise compatibility with version 3.5 or newer will not build. Since librdkafka 2.3.0 uses CMake 3.2, we are currently unable to build rdkafka with the CMake feature enabled, which we rely upon.

Possible Solutions

The best approach would be to update rdkafka-sys to use a more recent version of librdkafka, which would be preferable. However, the old version of librdkafka seems to work just fine as long as you manually set the cmake_minimum_required to 3.5 or higher. So a temporary solution could also be to use a patched version of librdkafka until time permits to properly update.

fabiandiez avatar Apr 14 '25 12:04 fabiandiez

A temporary workaround, if you don't have the option to fork and modify, is to downgrade cmake.

I am using cmake 3.31.7 and it worked out of the box.

On mac, you can enable the CLI commands for cmake by going to Tools -> How to install for command line use and copy the most appropriate command. This will likely be sudo "/Applications/CMake.app/Contents/bin/cmake-gui" --install

HughKaznowskiCoralogix avatar Apr 14 '25 16:04 HughKaznowskiCoralogix

Additionally, to build the specific CMake version from source on macOS (since brew doesn't support versions on this formula):

# 1. Download the source tarball
curl -LO https://github.com/Kitware/CMake/releases/download/v3.31.7/cmake-3.31.7.tar.gz

# 2. Extract the tarball
tar -xzf cmake-3.31.7.tar.gz

# 3. Change to the extracted directory
cd cmake-3.31.7

# 4. Configure the build
./bootstrap

# 5. Build CMake (the -j flag parallels the build using available CPU cores)
make -j$(sysctl -n hw.ncpu)

# 6. Install CMake (requires admin privileges)
sudo make install

cmackenzie1 avatar Apr 15 '25 20:04 cmackenzie1

this worked for me and I neither had to install a new version of cmake not downgrade the existing one

CMAKE_POLICY_VERSION_MINIMUM="3.10" cargo build

Masber avatar May 10 '25 17:05 Masber

I believe https://github.com/fede1024/rust-rdkafka/pull/766, which is part of release 0.38.0, addressed this issue. Please let me know if that is not the case.

fede1024 avatar Jul 05 '25 10:07 fede1024

@fede1024 Works for me!

fabiandiez avatar Oct 08 '25 07:10 fabiandiez