From 97e0bf34e6135a5dfaa6a9bcea37f657f4c06be7 Mon Sep 17 00:00:00 2001 From: Julius Pfrommer Date: Mon, 14 Oct 2024 22:33:40 +0200 Subject: [PATCH] refactor(tests): Make the unit tests compile on FreeBSD --- tests/CMakeLists.txt | 10 ++++++---- tools/cmake/FindCheck.cmake | 9 +++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 13d06b7e6b5..6338e4d88fc 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -2,17 +2,19 @@ if(MSVC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W1") # Reduce warnings level else() add_compile_options(-Wno-unused-variable -Wno-unused-function) + add_compile_options(-Wno-gnu-zero-variadic-macro-arguments) # silence warning for the check library endif() -# Load CMake Packages +# Check dependency find_package(Check REQUIRED) set(LIBS ${CHECK_LIBRARIES} ${open62541_LIBRARIES}) -if(NOT WIN32 AND NOT APPLE AND NOT (CMAKE_HOST_SYSTEM_NAME MATCHES "OpenBSD")) +if(NOT WIN32 AND NOT APPLE AND NOT (CMAKE_HOST_SYSTEM_NAME MATCHES "OpenBSD") AND NOT (CMAKE_HOST_SYSTEM_NAME MATCHES "FreeBSD")) list(APPEND LIBS subunit) endif() +include_directories(${CHECK_INCLUDE_DIRS}) +link_directories(${CHECK_LIBRARY_DIRS}) -include_directories(${CHECK_INCLUDE_DIR}) -#find_package(Threads REQUIRED) +# Valgrind dependency if(NOT MSVC AND UA_ENABLE_UNIT_TESTS_MEMCHECK) find_package(Valgrind REQUIRED) endif() diff --git a/tools/cmake/FindCheck.cmake b/tools/cmake/FindCheck.cmake index 3eccef70061..1c7b6321547 100644 --- a/tools/cmake/FindCheck.cmake +++ b/tools/cmake/FindCheck.cmake @@ -32,10 +32,11 @@ endif() IF( NOT CHECK_FOUND ) IF ( CHECK_INSTALL_DIR ) MESSAGE ( STATUS "Using override CHECK_INSTALL_DIR to find check" ) - SET ( CHECK_INCLUDE_DIR "${CHECK_INSTALL_DIR}/include" ) - FIND_LIBRARY( CHECK_LIBRARIES NAMES check PATHS "${CHECK_INSTALL_DIR}/lib" ) + SET ( CHECK_INCLUDE_DIRS "${CHECK_INSTALL_DIR}/include" ) + SET ( CHECK_LIBRARY_DIRS "${CHECK_INSTALL_DIR}/lib" ) + FIND_LIBRARY( CHECK_LIBRARIES NAMES check PATHS ${CHECK_LIBRARY_DIRS} ) ELSE ( CHECK_INSTALL_DIR ) - FIND_PATH( CHECK_INCLUDE_DIR check.h ) + FIND_PATH( CHECK_INCLUDE_DIRS check.h ) FIND_LIBRARY( CHECK_LIBRARIES NAMES check ) ENDIF ( CHECK_INSTALL_DIR ) @@ -56,4 +57,4 @@ IF( NOT CHECK_FOUND ) ENDIF( NOT CHECK_FOUND ) # Hide advanced variables from CMake GUIs -MARK_AS_ADVANCED( CHECK_INCLUDE_DIR CHECK_LIBRARIES ) +MARK_AS_ADVANCED( CHECK_INCLUDE_DIRS CHECK_LIBRARY_DIRS CHECK_LIBRARIES )