Files
mosquitto/cmake/FindCUnit.cmake
Kai Buschulte a883bda9c1 Add CMake test target
Use `ctest` or `make test` to run all tests.
With this it's also possible to run tests on a Mac.

Relative paths used in tests become absolute ones to make tests
executable from any build folder.

Also fixed race condition in
  test/broker/11-persistent-subscription-no-local.py

Signed-off-by: Kai Buschulte <kai.buschulte@cedalo.com>
2022-06-22 23:56:50 +01:00

37 lines
884 B
CMake

find_package(PkgConfig)
pkg_check_modules(PC_CUnit QUIET cunit)
find_path(CUnit_INCLUDE_DIR
NAMES CUnit/CUnit.h
PATHS ${PC_CUnit_INCLUDE_DIRS}
)
find_library(CUnit_LIBRARY
NAMES cunit
PATHS ${PC_CUnit_LIBRARY_DIRS}
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(CUnit
FOUND_VAR CUnit_FOUND
REQUIRED_VARS
CUnit_LIBRARY
CUnit_INCLUDE_DIR
VERSION_VAR CUnit_VERSION
)
if(CUnit_FOUND)
set(CUnit_LIBRARIES ${CUnit_LIBRARY})
set(CUnit_INCLUDE_DIRS ${CUnit_INCLUDE_DIR})
set(CUnit_DEFINITIONS ${PC_CUnit_CFLAGS_OTHER})
endif()
if(CUnit_FOUND AND NOT TARGET CUnit::CUnit)
add_library(CUnit::CUnit UNKNOWN IMPORTED)
set_target_properties(CUnit::CUnit PROPERTIES
IMPORTED_LOCATION "${CUnit_LIBRARY}"
INTERFACE_COMPILE_OPTIONS "${PC_CUnit_CFLAGS_OTHER}"
INTERFACE_INCLUDE_DIRECTORIES "${CUnit_INCLUDE_DIR}"
)
endif()