1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
cmake_minimum_required(VERSION 3.21)
project(dolfinx-tests LANGUAGES C CXX)
if (PROJECT_IS_TOP_LEVEL)
include(CTest) # enables testing
find_package(DOLFINX REQUIRED)
set(DOLFINX_CXX_DEVELOPER_FLAGS -Wall -Wextra -pedantic -g -O2)
endif()
find_package(Catch2 3 REQUIRED)
# FFCx compile: expr.py -> expr.c
add_custom_command(
OUTPUT expr.c
COMMAND ffcx ${CMAKE_CURRENT_SOURCE_DIR}/fem/expr.py
VERBATIM
DEPENDS fem/expr.py
COMMENT "Compile expr.py using FFCx"
)
# FFCx compile: poisson.py -> poisson.c
add_custom_command(
OUTPUT poisson.c
COMMAND ffcx ${CMAKE_CURRENT_SOURCE_DIR}/poisson.py
VERBATIM
DEPENDS poisson.py
COMMENT "Compile poisson.py using FFCx"
)
add_executable(
unittests
main.cpp
graph.cpp
vector.cpp
matrix.cpp
io.cpp
common/CIFailure.cpp
common/sub_systems_manager.cpp
common/index_map.cpp
common/sort.cpp
fem/form.cpp
fem/functionspace.cpp
mesh/branching_manifold.cpp
mesh/distributed_mesh.cpp
mesh/generation.cpp
mesh/read_named_meshtags.cpp
mesh/refinement/interval.cpp
mesh/refinement/option.cpp
mesh/refinement/rectangle.cpp
${CMAKE_CURRENT_BINARY_DIR}/expr.c
${CMAKE_CURRENT_BINARY_DIR}/poisson.c
)
target_link_libraries(unittests PRIVATE Catch2::Catch2 dolfinx)
# UUID requires bcrypt to be linked on Windows, broken in vcpkg.
# https://github.com/microsoft/vcpkg/issues/4481
if(WIN32)
target_link_libraries(unittests PRIVATE bcrypt)
endif()
# Required to find FFCx generated headers.
target_include_directories(
unittests PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
)
if (NOT PROJECT_IS_TOP_LEVEL)
# Required to find version.h
target_include_directories(
unittests PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/../>
)
endif()
set_target_properties(
unittests
PROPERTIES CMAKE_C_STANDARD 17 # For FFCx generated .c files.
CMAKE_CXX_STANDARD 20
CMAKE_CXX_STANDARD_REQUIRED ON
CMAKE_CXX_EXTENSIONS OFF
)
if (DEFINED DOLFINX_CXX_DEVELOPER_FLAGS)
target_compile_options(
unittests
PRIVATE
$<$<AND:$<CONFIG:Developer>,$<COMPILE_LANGUAGE:CXX>>:${DOLFINX_CXX_DEVELOPER_FLAGS}>
)
endif()
if(ENABLE_CLANG_TIDY)
find_program(CLANG_TIDY NAMES clang-tidy REQUIRED)
set_target_properties(
unittests
PROPERTIES
CXX_CLANG_TIDY
"${CLANG_TIDY};--config-file=${CMAKE_CURRENT_SOURCE_DIR}/../../.clang-tidy"
)
endif()
# Uncommenting line allows for debugging individual tests, but slow.
#catch_discover_tests(unittests)
add_test(NAME unittests COMMAND $<TARGET_FILE:unittests>)
|