diff --git a/.github/workflows/pr-compile-check.yaml b/.github/workflows/pr-compile-check.yaml index 999a046df04..5b0c4f94e06 100644 --- a/.github/workflows/pr-compile-check.yaml +++ b/.github/workflows/pr-compile-check.yaml @@ -102,3 +102,26 @@ jobs: echo "$ldd_result" | grep libsqlite3 echo "$ldd_result" | grep libzstd working-directory: build + + # Sanity check for compilation w/ CXX support + pr-compile-without-cxx: + runs-on: ubuntu-22.04 + timeout-minutes: 60 + strategy: + fail-fast: false + steps: + - name: Setup environment + run: | + sudo apt-get update + sudo apt-get install -y bison cmake flex gcc libssl-dev libyaml-dev + + - name: Checkout Fluent Bit code + uses: actions/checkout@v4 + + - name: Compile w/ CXX support + run: | + export CXX=/bin/false + export nparallel=$(( $(getconf _NPROCESSORS_ONLN) > 8 ? 8 : $(getconf _NPROCESSORS_ONLN) )) + cmake ../ + make -j $nparallel + working-directory: build diff --git a/lib/librdkafka-2.8.0/CMakeLists.txt b/lib/librdkafka-2.8.0/CMakeLists.txt index f3d05bad7a8..8ef47053ada 100644 --- a/lib/librdkafka-2.8.0/CMakeLists.txt +++ b/lib/librdkafka-2.8.0/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.8.0/examples/CMakeLists.txt b/lib/librdkafka-2.8.0/examples/CMakeLists.txt index 91851d2cbf2..6874195ce22 100644 --- a/lib/librdkafka-2.8.0/examples/CMakeLists.txt +++ b/lib/librdkafka-2.8.0/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) diff --git a/lib/luajit-cmake/CMakeLists.txt b/lib/luajit-cmake/CMakeLists.txt index 7baf878c775..051a800f524 100644 --- a/lib/luajit-cmake/CMakeLists.txt +++ b/lib/luajit-cmake/CMakeLists.txt @@ -13,7 +13,7 @@ endif() get_directory_property(hasParent PARENT_DIRECTORY) if(LUAJIT_DIR) - project(luajit) + project(luajit LANGUAGES C) include(LuaJIT.cmake) if (hasParent) set(LUA_TARGET $ PARENT_SCOPE) @@ -24,7 +24,7 @@ if(LUAJIT_DIR) endif() endif() elseif(LUA_DIR) - project(lua) + project(lua LANGUAGES C) include(lua.cmake) if (hasParent) set(LUA_TARGET $ PARENT_SCOPE) diff --git a/lib/miniz/CMakeLists.txt b/lib/miniz/CMakeLists.txt index 859133ad085..f3d80f80a0a 100644 --- a/lib/miniz/CMakeLists.txt +++ b/lib/miniz/CMakeLists.txt @@ -7,7 +7,7 @@ if(DEFINED PROJECT_NAME) endif() if(CMAKE_MINOR_VERSION LESS 12) - project(miniz) + project(miniz C) # see issue https://gitlab.kitware.com/cmake/cmake/merge_requests/1799 else() project(miniz C) diff --git a/lib/zstd-1.5.7/build/cmake/CMakeLists.txt b/lib/zstd-1.5.7/build/cmake/CMakeLists.txt index 347d41c0fd1..f08905345f3 100644 --- a/lib/zstd-1.5.7/build/cmake/CMakeLists.txt +++ b/lib/zstd-1.5.7/build/cmake/CMakeLists.txt @@ -37,7 +37,6 @@ project(zstd VERSION "${ZSTD_FULL_VERSION}" LANGUAGES C # Main library is in C ASM # And ASM - CXX # Testing contributed code also utilizes CXX ) message(STATUS "ZSTD VERSION: ${zstd_VERSION}") @@ -54,12 +53,6 @@ endif() include(GNUInstallDirs) -#----------------------------------------------------------------------------- -# Add extra compilation flags -#----------------------------------------------------------------------------- -include(AddZstdCompilationFlags) -ADD_ZSTD_COMPILATION_FLAGS() - # Always hide XXHash symbols add_definitions(-DXXH_NAMESPACE=ZSTD_) @@ -123,6 +116,19 @@ if (MSVC) option(ZSTD_USE_STATIC_RUNTIME "LINK TO STATIC RUN-TIME LIBRARIES" OFF) endif () +# Enable C++ support for testing. +set(ZSTD_ENABLE_CXX ${ZSTD_BUILD_TESTS}) + +if(ZSTD_ENABLE_CXX) + enable_language(CXX) +endif() + +#----------------------------------------------------------------------------- +# Add extra compilation flags +#----------------------------------------------------------------------------- +include(AddZstdCompilationFlags) +ADD_ZSTD_COMPILATION_FLAGS(ON ZSTD_ENABLE_CXX ON) # C CXX LD + #----------------------------------------------------------------------------- # External dependencies #----------------------------------------------------------------------------- diff --git a/lib/zstd-1.5.7/build/cmake/CMakeModules/AddZstdCompilationFlags.cmake b/lib/zstd-1.5.7/build/cmake/CMakeModules/AddZstdCompilationFlags.cmake index 5f381c656cf..25231b5ec32 100644 --- a/lib/zstd-1.5.7/build/cmake/CMakeModules/AddZstdCompilationFlags.cmake +++ b/lib/zstd-1.5.7/build/cmake/CMakeModules/AddZstdCompilationFlags.cmake @@ -49,7 +49,7 @@ function(EnableCompilerFlag _flag _C _CXX _LD) endif () endfunction() -macro(ADD_ZSTD_COMPILATION_FLAGS) +macro(ADD_ZSTD_COMPILATION_FLAGS _C _CXX _LD) # We set ZSTD_HAS_NOEXECSTACK if we are certain we've set all the required # compiler flags to mark the stack as non-executable. set(ZSTD_HAS_NOEXECSTACK false) @@ -63,26 +63,26 @@ macro(ADD_ZSTD_COMPILATION_FLAGS) # EnableCompilerFlag("-std=c99" true false) # Set C compilation to c99 standard if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND MSVC) # clang-cl normally maps -Wall to -Weverything. - EnableCompilerFlag("/clang:-Wall" true true false) + EnableCompilerFlag("/clang:-Wall" _C _CXX false) else () - EnableCompilerFlag("-Wall" true true false) + EnableCompilerFlag("-Wall" _C _CXX false) endif () - EnableCompilerFlag("-Wextra" true true false) - EnableCompilerFlag("-Wundef" true true false) - EnableCompilerFlag("-Wshadow" true true false) - EnableCompilerFlag("-Wcast-align" true true false) - EnableCompilerFlag("-Wcast-qual" true true false) - EnableCompilerFlag("-Wstrict-prototypes" true false false) + EnableCompilerFlag("-Wextra" _C _CXX false) + EnableCompilerFlag("-Wundef" _C _CXX false) + EnableCompilerFlag("-Wshadow" _C _CXX false) + EnableCompilerFlag("-Wcast-align" _C _CXX false) + EnableCompilerFlag("-Wcast-qual" _C _CXX false) + EnableCompilerFlag("-Wstrict-prototypes" _C false false) # Enable asserts in Debug mode if (CMAKE_BUILD_TYPE MATCHES "Debug") - EnableCompilerFlag("-DDEBUGLEVEL=1" true true false) + EnableCompilerFlag("-DDEBUGLEVEL=1" _C _CXX false) endif () # Add noexecstack flags # LDFLAGS - EnableCompilerFlag("-Wl,-z,noexecstack" false false true) + EnableCompilerFlag("-Wl,-z,noexecstack" false false _LD) # CFLAGS & CXXFLAGS - EnableCompilerFlag("-Qunused-arguments" true true false) - EnableCompilerFlag("-Wa,--noexecstack" true true false) + EnableCompilerFlag("-Qunused-arguments" _C _CXX false) + EnableCompilerFlag("-Wa,--noexecstack" _C _CXX false) # NOTE: Using 3 nested ifs because the variables are sometimes # empty if the condition is false, and sometimes equal to false. # This implicitly converts them to truthy values. There may be @@ -99,15 +99,15 @@ macro(ADD_ZSTD_COMPILATION_FLAGS) set(ACTIVATE_MULTITHREADED_COMPILATION "ON" CACHE BOOL "activate multi-threaded compilation (/MP flag)") if (CMAKE_GENERATOR MATCHES "Visual Studio" AND ACTIVATE_MULTITHREADED_COMPILATION) - EnableCompilerFlag("/MP" true true false) + EnableCompilerFlag("/MP" _C _CXX false) endif () # UNICODE SUPPORT - EnableCompilerFlag("/D_UNICODE" true true false) - EnableCompilerFlag("/DUNICODE" true true false) + EnableCompilerFlag("/D_UNICODE" _C _CXX false) + EnableCompilerFlag("/DUNICODE" _C _CXX false) # Enable asserts in Debug mode if (CMAKE_BUILD_TYPE MATCHES "Debug") - EnableCompilerFlag("/DDEBUGLEVEL=1" true true false) + EnableCompilerFlag("/DDEBUGLEVEL=1" _C _CXX false) endif () endif ()