Commit f3e80135 authored by Lukas Riedel's avatar Lukas Riedel

Use Boost Test for DORiE unit tests

* Enable testing in DORiE if dune-testtools and Boost Test are found.
  Both are not required for the build.
* Link Boost Test to all DORiE unit tests. This has no effect if it is
  not enabled with the correct macro.
parent a73adde6
......@@ -48,7 +48,7 @@ add_subdirectory("python")
add_subdirectory("doc")
add_subdirectory("dune")
add_subdirectory("lib")
if(dune-testtools_FOUND)
if(DORIE_TESTING)
add_subdirectory("test")
endif()
......
......@@ -41,11 +41,23 @@ find_package (yaml-cpp 0.5.2 REQUIRED)
# muparser
find_package (muparser REQUIRED)
# BOOST Unit Test framework
find_package(Boost 1.62
COMPONENTS unit_test_framework)
# Report the DUNE libs
message (STATUS "DUNE Libraries: ${DUNE_LIBS}")
# Remove CMake policy stack
cmake_policy(POP)
# Add DORiE testing functions
include(DorieTesting)
# Check if testing is enabled
if (dune-testtools_FOUND AND TARGET Boost::unit_test_framework)
message(STATUS "Testing enabled: dune-testtools and Boost Unit Test found.")
set(DORIE_TESTING TRUE)
# include the DORiE testing macros
include(DorieTesting)
else()
message(STATUS "Testing disabled: dune-testtools and Boost Unit Test "
"not found.")
endif()
......@@ -82,6 +82,13 @@ function(dorie_add_unit_test)
target_link_libraries(${UNIT_TEST_TARGET}
muparser::muparser hdf5 yaml-cpp spdlog)
add_coverage_links(${UNIT_TEST_TARGET})
# add Boost Unit Test links and compile options
target_link_libraries(${UNIT_TEST_TARGET} Boost::unit_test_framework)
# NOTE: Might lead to issues if linked to the static unit test library
target_compile_definitions(${UNIT_TEST_TARGET}
PRIVATE BOOST_TEST_DYN_LINK)
add_dependencies(build_unit_tests ${UNIT_TEST_TARGET})
endfunction()
......
add_subdirectory("common")
add_subdirectory("model")
if(dune-testtools_FOUND)
if(DORIE_TESTING)
add_subdirectory("test")
endif()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment