Skip to content

Commit 40b6355

Browse files
authored
Merge pull request syslog-ng#5047 from HofiOne/cmake-test-switching-fixes
cmake: fixed multiple testing related issues
2 parents 00b87ef + 0fe2a14 commit 40b6355

File tree

4 files changed

+23
-16
lines changed

4 files changed

+23
-16
lines changed

CMakeLists.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -379,17 +379,17 @@ endif()
379379

380380
include(add_tests)
381381

382-
# The inclusion of CTest triggers enable_testing()
383-
# CMake will generate tests only if the enable_testing() command has been invoked.
384-
# The CTest module invokes the command automatically when the BUILD_TESTING option is ON.
385-
386382
if (BUILD_TESTING)
387383
if (NOT CRITERION_FOUND)
388384
message(FATAL_ERROR "BUILD_TESTING enabled without criterion detected!")
389385
else()
390386
set(CTEST_ENVIRONMENT
391387
"G_SLICE=always-malloc,debug-blocks"
392388
"G_DEBUG=fatal-warnings,fatal-criticals,gc-friendly")
389+
390+
# The inclusion of CTest triggers enable_testing()
391+
# CMake will generate tests only if the enable_testing() command has been invoked.
392+
# The CTest module invokes the command automatically when the BUILD_TESTING option is ON.
393393
include(CTest)
394394

395395
# 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

libtest/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
if (NOT BUILD_TESTING)
2+
return ()
3+
endif ()
4+
15
set(LIBTEST_HEADERS
26
config_parse_lib.h
37
fake-time.h

modules/kafka/CMakeLists.txt

+10-12
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
1-
find_package(rdkafka 1.1.0)
1+
if (NOT DEFINED ENABLE_KAFKA OR ENABLE_KAFKA)
2+
find_package(rdkafka 1.1.0)
3+
endif ()
24

3-
if (RDKAFKA_FOUND)
4-
option(ENABLE_KAFKA "Enable kafka module" ON)
5-
else()
6-
option(ENABLE_KAFKA "Enable kafka module" OFF)
7-
endif()
5+
module_switch (ENABLE_KAFKA "Enable kafka module" RDKAFKA_FOUND)
86

9-
if (NOT ENABLE_KAFKA)
10-
return()
11-
endif()
7+
if (ENABLE_KAFKA AND NOT RDKAFKA_FOUND)
8+
message (FATAL_ERROR "Kafka enabled but no librdkafka found")
9+
endif ()
1210

13-
if (NOT RDKAFKA_FOUND)
14-
message(FATAL_ERROR "Kafka enabled but no librdkafka found")
11+
if (NOT ENABLE_KAFKA)
12+
return()
1513
endif()
1614

15+
check_symbol_exists (rd_kafka_init_transactions "librdkafka/rdkafka.h" SYSLOG_NG_HAVE_RD_KAFKA_INIT_TRANSACTIONS)
1716

1817
set(CMAKE_REQUIRED_INCLUDES ${RDKAFKA_INCLUDE_DIR})
1918
set(CMAKE_REQUIRED_LIBRARIES ${RDKAFKA_LIBRARY})
20-
check_symbol_exists(rd_kafka_init_transactions "librdkafka/rdkafka.h" SYSLOG_NG_HAVE_RD_KAFKA_INIT_TRANSACTIONS)
2119

2220
set(KAFKA_SOURCES
2321
kafka-parser.c

modules/mqtt/CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ if (NOT DEFINED ENABLE_MQTT OR ENABLE_MQTT)
33
endif()
44

55
module_switch(ENABLE_MQTT "Enable mqtt" eclipse-paho-mqtt-c_FOUND)
6+
7+
if (ENABLE_MQTT AND NOT eclipse-paho-mqtt-c_FOUND)
8+
message (FATAL_ERROR "MQTT enabled but no eclipse-paho-mqtt-c library found")
9+
endif ()
10+
611
if (NOT ENABLE_MQTT)
712
return()
813
endif()

0 commit comments

Comments
 (0)