54 lines
1.2 KiB
CMake
54 lines
1.2 KiB
CMake
# Copyright (c) 2024 Saul D. Beniquez
|
|
# License: MIT
|
|
|
|
add_executable(test-runner
|
|
exception-test.cpp
|
|
Result-test.cpp
|
|
Application-test.cpp
|
|
CgiApplication-test.cpp
|
|
MarkdownRouteHandler-test.cpp
|
|
)
|
|
|
|
set_target_properties(test-runner PROPERTIES
|
|
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tests"
|
|
)
|
|
|
|
target_link_directories(test-runner PRIVATE ${Catch2_LIBRARY_DIRS})
|
|
target_include_directories(test-runner PRIVATE ${Catch2_INCLUDE_DIRS})
|
|
|
|
# Link the test executable with libmdml and Catch2
|
|
target_link_libraries(test-runner
|
|
PRIVATE
|
|
mdml
|
|
Catch2::Catch2WithMain
|
|
)
|
|
|
|
add_custom_target(test_bin)
|
|
add_dependencies(test_bin
|
|
test-runner
|
|
)
|
|
|
|
# Extras: Catch2 Ctest integration. @{
|
|
# add catch2's ctest CMake module and register the tests defined by test-runner
|
|
# using catch_discover_tests
|
|
include(CTest)
|
|
include(Catch)
|
|
catch_discover_tests(test-runner)
|
|
# @}
|
|
|
|
add_data_target(NAME test-data
|
|
PATH "${mdml_CMAKE_SOURCE_DIR}/data"
|
|
DESTINATION ${CMAKE_BINARY_DIR}/tests/data
|
|
)
|
|
|
|
# Add a custom ctest target to the build system
|
|
add_custom_target(ctest
|
|
COMMAND ctest -C $CONFIGURATION --test-dir . --output-on-failure
|
|
)
|
|
|
|
add_dependencies(ctest
|
|
test_bin
|
|
copy_test-data
|
|
)
|
|
# vim: ft=cmake sw=4 ts=4 noet sts=4 foldmethod=marker foldmarker=@{,@} :
|