1
0
mirror of https://github.com/lefticus/6502-cpp.git synced 2024-07-12 13:28:54 +00:00
6502-cpp/test/CMakeLists.txt
2021-05-19 14:28:05 -06:00

69 lines
1.9 KiB
CMake

# Automatically enable catch2 to generate ctest targets
if(CONAN_CATCH2_ROOT_DEBUG)
include(${CONAN_CATCH2_ROOT_DEBUG}/lib/cmake/Catch2/Catch.cmake)
else()
include(${CONAN_CATCH2_ROOT}/lib/cmake/Catch2/Catch.cmake)
endif()
add_library(catch_main STATIC catch_main.cpp)
target_link_libraries(catch_main PUBLIC CONAN_PKG::catch2 CONAN_PKG::fmt)
target_link_libraries(catch_main PRIVATE project_options)
add_executable(tests tests.cpp)
target_link_libraries(tests PRIVATE project_warnings project_options catch_main)
# automatically discover tests that are defined in catch based test files you can modify the unittests. Set TEST_PREFIX
# to whatever you want, or use different for different binaries
catch_discover_tests(
tests
TEST_PREFIX
"approval_tests."
PROPERTIES
ENVIRONMENT CXX_6502=$<TARGET_FILE:6502-c++> ENVIRONMENT X64=/usr/bin/x64
REPORTER
xml
OUTPUT_DIR
.
OUTPUT_PREFIX
"approval_tests."
OUTPUT_SUFFIX
.xml
)
# Add a file containing a set of constexpr tests
add_executable(constexpr_tests constexpr_tests.cpp)
target_link_libraries(constexpr_tests PRIVATE project_options project_warnings catch_main)
catch_discover_tests(
constexpr_tests
TEST_PREFIX
"constexpr."
REPORTER
xml
OUTPUT_DIR
.
OUTPUT_PREFIX
"constexpr."
OUTPUT_SUFFIX
.xml)
# Disable the constexpr portion of the test, and build again this allows us to have an executable that we can debug when
# things go wrong with the constexpr testing
add_executable(relaxed_constexpr_tests constexpr_tests.cpp)
target_link_libraries(relaxed_constexpr_tests PRIVATE project_options project_warnings catch_main)
target_compile_definitions(relaxed_constexpr_tests PRIVATE -DCATCH_CONFIG_RUNTIME_STATIC_REQUIRE)
catch_discover_tests(
relaxed_constexpr_tests
TEST_PREFIX
"relaxed_constexpr."
REPORTER
xml
OUTPUT_DIR
.
OUTPUT_PREFIX
"relaxed_constexpr."
OUTPUT_SUFFIX
.xml)