Skip to content

Commit

Permalink
Merge pull request #263 from MrAnno/cmake-and-macos-build-fixes
Browse files Browse the repository at this point in the history
CMake and macOS build fixes
  • Loading branch information
alltilla authored Sep 2, 2024
2 parents dcc38fd + f0bc0ec commit c158262
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 17 deletions.
1 change: 0 additions & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ jobs:
--with-python=3
--with-systemd-journal=no
--disable-smtp
--disable-grpc
--disable-java
--disable-java-modules
--disable-mqtt
Expand Down
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -377,17 +377,17 @@ 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!")
else()
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
Expand Down
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions contrib/Brewfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ brew "python@3", link: true, force: true
brew "rabbitmq-c"
brew "riemann-client"

brew "grpc"

brew "criterion"
4 changes: 4 additions & 0 deletions libtest/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
if (NOT BUILD_TESTING)
return ()
endif ()

set(LIBTEST_HEADERS
config_parse_lib.h
fake-time.h
Expand Down
2 changes: 2 additions & 0 deletions modules/grpc/otel/tests/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
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 \
modules/grpc/otel/tests/test_syslog_ng_otlp \
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
Expand Down
22 changes: 10 additions & 12 deletions modules/kafka/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 5 additions & 0 deletions modules/mqtt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit c158262

Please sign in to comment.