From bbb6cd5888e601ecc1dad14d77c065131b9b449c Mon Sep 17 00:00:00 2001 From: Thomas Devoogdt Date: Tue, 25 Jul 2023 09:10:41 +0200 Subject: [PATCH 1/2] lib: librdkafka: only require a C compiler Upstream: https://github.com/confluentinc/librdkafka/pull/4366 Signed-off-by: Thomas Devoogdt --- lib/librdkafka-2.10.1/CMakeLists.txt | 22 +++++++++++-- lib/librdkafka-2.10.1/examples/CMakeLists.txt | 31 ++++++++++++------- 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/lib/librdkafka-2.10.1/CMakeLists.txt b/lib/librdkafka-2.10.1/CMakeLists.txt index f3d05bad7a8..8ef47053ada 100644 --- a/lib/librdkafka-2.10.1/CMakeLists.txt +++ b/lib/librdkafka-2.10.1/CMakeLists.txt @@ -3,7 +3,16 @@ cmake_minimum_required(VERSION 3.5) include("packaging/cmake/parseversion.cmake") parseversion("src/rdkafka.h") -project(RdKafka VERSION ${RDKAFKA_VERSION}) +project(RdKafka VERSION ${RDKAFKA_VERSION} LANGUAGES C) + +# Check for CXX support +include(CheckLanguage) +check_language(CXX) +if(CMAKE_CXX_COMPILER) + enable_language(CXX) +else() + message(STATUS "C++ compiler not found, skipping C++ support") +endif() set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/packaging/cmake/Modules/") @@ -181,7 +190,11 @@ endif() option(RDKAFKA_BUILD_STATIC "Build static rdkafka library" OFF) option(RDKAFKA_BUILD_EXAMPLES "Build examples" ON) -option(RDKAFKA_BUILD_TESTS "Build tests" ON) + +if(CMAKE_CXX_COMPILER) + option(RDKAFKA_BUILD_TESTS "Build tests" ON) +endif() + if(WIN32) option(WITHOUT_WIN32_CONFIG "Avoid including win32_config.h on cmake builds" ON) endif(WIN32) @@ -279,7 +292,10 @@ install( ) add_subdirectory(src) -add_subdirectory(src-cpp) + +if(CMAKE_CXX_COMPILER) + add_subdirectory(src-cpp) +endif() if(RDKAFKA_BUILD_EXAMPLES) add_subdirectory(examples) diff --git a/lib/librdkafka-2.10.1/examples/CMakeLists.txt b/lib/librdkafka-2.10.1/examples/CMakeLists.txt index 91851d2cbf2..6874195ce22 100644 --- a/lib/librdkafka-2.10.1/examples/CMakeLists.txt +++ b/lib/librdkafka-2.10.1/examples/CMakeLists.txt @@ -5,8 +5,10 @@ endif(WIN32) add_executable(producer producer.c ${win32_sources}) target_link_libraries(producer PUBLIC rdkafka) -add_executable(producer_cpp producer.cpp ${win32_sources}) -target_link_libraries(producer_cpp PUBLIC rdkafka++) +if(CMAKE_CXX_COMPILER) + add_executable(producer_cpp producer.cpp ${win32_sources}) + target_link_libraries(producer_cpp PUBLIC rdkafka++) +endif() add_executable(consumer consumer.c ${win32_sources}) target_link_libraries(consumer PUBLIC rdkafka) @@ -14,14 +16,20 @@ target_link_libraries(consumer PUBLIC rdkafka) add_executable(rdkafka_performance rdkafka_performance.c ${win32_sources}) target_link_libraries(rdkafka_performance PUBLIC rdkafka) -add_executable(rdkafka_example_cpp rdkafka_example.cpp ${win32_sources}) -target_link_libraries(rdkafka_example_cpp PUBLIC rdkafka++) +if(CMAKE_CXX_COMPILER) + add_executable(rdkafka_example_cpp rdkafka_example.cpp ${win32_sources}) + target_link_libraries(rdkafka_example_cpp PUBLIC rdkafka++) +endif() -add_executable(rdkafka_complex_consumer_example_cpp rdkafka_complex_consumer_example.cpp ${win32_sources}) -target_link_libraries(rdkafka_complex_consumer_example_cpp PUBLIC rdkafka++) +if(CMAKE_CXX_COMPILER) + add_executable(rdkafka_complex_consumer_example_cpp rdkafka_complex_consumer_example.cpp ${win32_sources}) + target_link_libraries(rdkafka_complex_consumer_example_cpp PUBLIC rdkafka++) +endif() -add_executable(openssl_engine_example_cpp openssl_engine_example.cpp ${win32_sources}) -target_link_libraries(openssl_engine_example_cpp PUBLIC rdkafka++) +if(CMAKE_CXX_COMPILER) + add_executable(openssl_engine_example_cpp openssl_engine_example.cpp ${win32_sources}) + target_link_libraries(openssl_engine_example_cpp PUBLIC rdkafka++) +endif() add_executable(misc misc.c ${win32_sources}) target_link_libraries(misc PUBLIC rdkafka) @@ -73,7 +81,8 @@ if(NOT WIN32) add_executable(rdkafka_complex_consumer_example rdkafka_complex_consumer_example.c) target_link_libraries(rdkafka_complex_consumer_example PUBLIC rdkafka) - add_executable(kafkatest_verifiable_client kafkatest_verifiable_client.cpp) - target_link_libraries(kafkatest_verifiable_client PUBLIC rdkafka++) - + if(CMAKE_CXX_COMPILER) + add_executable(kafkatest_verifiable_client kafkatest_verifiable_client.cpp) + target_link_libraries(kafkatest_verifiable_client PUBLIC rdkafka++) + endif() endif(NOT WIN32) From 16d53c5a9e5998ed9fd1aa7ce6e32542ef36ee8f Mon Sep 17 00:00:00 2001 From: Thomas Devoogdt Date: Sat, 4 Oct 2025 09:11:02 +0200 Subject: [PATCH 2/2] Revert "workflows: exclude librdkafka-dev from pr-compile-without-cxx" This reverts commit 32fc9dd9ba7afd9221826912644da4f2df284d53. Not needed anymore since librdkafka has been fixed. Signed-off-by: Thomas Devoogdt --- .github/workflows/pr-compile-check.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-compile-check.yaml b/.github/workflows/pr-compile-check.yaml index 1cffd508b51..35b35c093a1 100644 --- a/.github/workflows/pr-compile-check.yaml +++ b/.github/workflows/pr-compile-check.yaml @@ -135,7 +135,7 @@ jobs: run: | sudo apt-get update sudo apt-get install -y bison cmake flex gcc libssl-dev libyaml-dev - sudo apt-get install -y libzstd-dev librdkafka-dev + sudo apt-get install -y libzstd-dev - name: Install cmake uses: jwlawson/actions-setup-cmake@v2 @@ -149,6 +149,6 @@ jobs: run: | export CXX=/bin/false export nparallel=$(( $(getconf _NPROCESSORS_ONLN) > 8 ? 8 : $(getconf _NPROCESSORS_ONLN) )) - cmake -DFLB_PREFER_SYSTEM_LIB_ZSTD=ON -DFLB_PREFER_SYSTEM_LIB_KAFKA=ON ../ + cmake -DFLB_PREFER_SYSTEM_LIB_ZSTD=ON ../ make -j $nparallel working-directory: build