From 813a57ef14abb2e692b3776d01036379e4644716 Mon Sep 17 00:00:00 2001 From: Hofi Date: Tue, 30 Jul 2024 16:48:24 +0200 Subject: [PATCH 1/5] cmake: criterion was still a dependency even if BUILD_TESTING=OFF is provided Signed-off-by: Hofi --- CMakeLists.txt | 8 ++++---- libtest/CMakeLists.txt | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index deb298b208..4e0ca72395 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -377,10 +377,6 @@ endif() include(add_tests) -# The inclusion of CTest triggers enable_testing() -# CMake will generate tests only if the enable_testing() command has been invoked. -# The CTest module invokes the command automatically when the BUILD_TESTING option is ON. - if (BUILD_TESTING) if (NOT CRITERION_FOUND) message(FATAL_ERROR "BUILD_TESTING enabled without criterion detected!") @@ -388,6 +384,10 @@ if (BUILD_TESTING) set(CTEST_ENVIRONMENT "G_SLICE=always-malloc,debug-blocks" "G_DEBUG=fatal-warnings,fatal-criticals,gc-friendly") + + # The inclusion of CTest triggers enable_testing() + # CMake will generate tests only if the enable_testing() command has been invoked. + # The CTest module invokes the command automatically when the BUILD_TESTING option is ON. include(CTest) # This flag might be a security issue, do not use in production code, unfortunately we still need it for criterion tests and the current mocking soution diff --git a/libtest/CMakeLists.txt b/libtest/CMakeLists.txt index 17ca1479ba..17872650f8 100644 --- a/libtest/CMakeLists.txt +++ b/libtest/CMakeLists.txt @@ -1,3 +1,7 @@ +if (NOT BUILD_TESTING) + return () +endif () + set(LIBTEST_HEADERS config_parse_lib.h fake-time.h From 6fa55d0dc4b844e66b2977386e79bf5ed5eb6ff0 Mon Sep 17 00:00:00 2001 From: Hofi Date: Wed, 31 Jul 2024 14:42:27 +0200 Subject: [PATCH 2/5] cmake:consolidate modul option and dependency detection/handling Signed-off-by: Hofi --- modules/kafka/CMakeLists.txt | 22 ++++++++++------------ modules/mqtt/CMakeLists.txt | 5 +++++ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/modules/kafka/CMakeLists.txt b/modules/kafka/CMakeLists.txt index 13997f7b54..adb8cfc093 100644 --- a/modules/kafka/CMakeLists.txt +++ b/modules/kafka/CMakeLists.txt @@ -1,23 +1,21 @@ -find_package(rdkafka 1.1.0) +if (NOT DEFINED ENABLE_KAFKA OR ENABLE_KAFKA) + find_package(rdkafka 1.1.0) +endif () -if (RDKAFKA_FOUND) - option(ENABLE_KAFKA "Enable kafka module" ON) -else() - option(ENABLE_KAFKA "Enable kafka module" OFF) -endif() +module_switch (ENABLE_KAFKA "Enable kafka module" RDKAFKA_FOUND) -if (NOT ENABLE_KAFKA) - return() -endif() +if (ENABLE_KAFKA AND NOT RDKAFKA_FOUND) + message (FATAL_ERROR "Kafka enabled but no librdkafka found") +endif () -if (NOT RDKAFKA_FOUND) - message(FATAL_ERROR "Kafka enabled but no librdkafka found") +if (NOT ENABLE_KAFKA) + return() endif() +check_symbol_exists (rd_kafka_init_transactions "librdkafka/rdkafka.h" SYSLOG_NG_HAVE_RD_KAFKA_INIT_TRANSACTIONS) set(CMAKE_REQUIRED_INCLUDES ${RDKAFKA_INCLUDE_DIR}) set(CMAKE_REQUIRED_LIBRARIES ${RDKAFKA_LIBRARY}) -check_symbol_exists(rd_kafka_init_transactions "librdkafka/rdkafka.h" SYSLOG_NG_HAVE_RD_KAFKA_INIT_TRANSACTIONS) set(KAFKA_SOURCES kafka-parser.c diff --git a/modules/mqtt/CMakeLists.txt b/modules/mqtt/CMakeLists.txt index faf4c92ec9..d0092a33ef 100644 --- a/modules/mqtt/CMakeLists.txt +++ b/modules/mqtt/CMakeLists.txt @@ -3,6 +3,11 @@ if (NOT DEFINED ENABLE_MQTT OR ENABLE_MQTT) endif() module_switch(ENABLE_MQTT "Enable mqtt" eclipse-paho-mqtt-c_FOUND) + +if (ENABLE_MQTT AND NOT eclipse-paho-mqtt-c_FOUND) + message (FATAL_ERROR "MQTT enabled but no eclipse-paho-mqtt-c library found") +endif () + if (NOT ENABLE_MQTT) return() endif() From d1eb2d5106ec3d3f44b7ffb914b6a34296ee5b07 Mon Sep 17 00:00:00 2001 From: Hofi Date: Tue, 30 Jul 2024 18:32:28 +0200 Subject: [PATCH 3/5] CI: added grpc dependency to brew Signed-off-by: Hofi --- contrib/Brewfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contrib/Brewfile b/contrib/Brewfile index 4f4dd38ace..a9797418d2 100644 --- a/contrib/Brewfile +++ b/contrib/Brewfile @@ -26,4 +26,6 @@ brew "python@3", link: true, force: true brew "rabbitmq-c" brew "riemann-client" +brew "grpc" + brew "criterion" From 74495991254a401992767243306355bf9180529a Mon Sep 17 00:00:00 2001 From: Hofi Date: Tue, 30 Jul 2024 18:44:55 +0200 Subject: [PATCH 4/5] CI: enable grpc in autotools builds Signed-off-by: Hofi --- .github/workflows/macos.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 00f1430c7a..b38d7e862f 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -58,7 +58,6 @@ jobs: --with-python=3 --with-systemd-journal=no --disable-smtp - --disable-grpc --disable-java --disable-java-modules --disable-mqtt From f0bc0ec844dac61f744c39d3888f8c6a188bd836 Mon Sep 17 00:00:00 2001 From: Hofi Date: Thu, 1 Aug 2024 13:23:01 +0200 Subject: [PATCH 5/5] test: turned off otel tests on macOS that otherwise causes linker errors Signed-off-by: Hofi --- configure.ac | 1 + modules/grpc/otel/tests/Makefile.am | 2 ++ 2 files changed, 3 insertions(+) diff --git a/configure.ac b/configure.ac index 0e9d96c523..77c362ec27 100644 --- a/configure.ac +++ b/configure.ac @@ -2301,6 +2301,7 @@ AM_CONDITIONAL([HAVE_FMEMOPEN], [test x$ac_cv_func_fmemopen = xyes]) AM_CONDITIONAL([HAVE_JAVAH], [test -n "$JAVAH_BIN"]) AM_CONDITIONAL(ENABLE_IPV6, [test $enable_ipv6 = yes]) +AM_CONDITIONAL(OS_TYPE_MACOS, [test $ostype = "Darwin"]) AC_SUBST(PYTHON_VENV) AC_SUBST(PYTHON_VENV_DIR) diff --git a/modules/grpc/otel/tests/Makefile.am b/modules/grpc/otel/tests/Makefile.am index 706734d99b..281d3413df 100644 --- a/modules/grpc/otel/tests/Makefile.am +++ b/modules/grpc/otel/tests/Makefile.am @@ -1,5 +1,6 @@ if ENABLE_GRPC +if ! OS_TYPE_MACOS modules_grpc_otel_tests_TESTS = \ modules/grpc/otel/tests/test_otel_protobuf_parser \ modules/grpc/otel/tests/test_otel_protobuf_formatter \ @@ -7,6 +8,7 @@ modules_grpc_otel_tests_TESTS = \ modules/grpc/otel/tests/test_otel_filterx check_PROGRAMS += ${modules_grpc_otel_tests_TESTS} +endif modules_grpc_otel_tests_test_otel_protobuf_parser_SOURCES = \ modules/grpc/otel/tests/test-otel-protobuf-parser.cpp