Skip to content

Commit

Permalink
refactor(tests): Make the unit tests compile on FreeBSD
Browse files Browse the repository at this point in the history
  • Loading branch information
jpfr committed Oct 15, 2024
1 parent 0da4ed5 commit 62b6fa3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
10 changes: 6 additions & 4 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
15 changes: 8 additions & 7 deletions tools/cmake/FindCheck.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,29 @@ 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 )

IF ( CHECK_INCLUDE_DIR AND CHECK_LIBRARIES )
IF ( CHECK_INCLUDE_DIRS AND CHECK_LIBRARIES )
SET( CHECK_FOUND 1 )
IF ( NOT Check_FIND_QUIETLY )
MESSAGE ( STATUS "Found CHECK: ${CHECK_LIBRARIES}" )
ENDIF ( NOT Check_FIND_QUIETLY )
ELSE ( CHECK_INCLUDE_DIR AND CHECK_LIBRARIES )
ELSE ( CHECK_INCLUDE_DIRS AND CHECK_LIBRARIES )
IF ( Check_FIND_REQUIRED )
MESSAGE( FATAL_ERROR "Could NOT find CHECK" )
ELSE ( Check_FIND_REQUIRED )
IF ( NOT Check_FIND_QUIETLY )
MESSAGE( STATUS "Could NOT find CHECK" )
ENDIF ( NOT Check_FIND_QUIETLY )
ENDIF ( Check_FIND_REQUIRED )
ENDIF ( CHECK_INCLUDE_DIR AND CHECK_LIBRARIES )
ENDIF ( CHECK_INCLUDE_DIRS AND CHECK_LIBRARIES )
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 )

0 comments on commit 62b6fa3

Please sign in to comment.