CMake 4.x breaks compatibility with librdkafka 2.3.0
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.
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
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
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
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 Works for me!