summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@gmail.com>2026-06-05 16:52:16 +0200
committerFelix Morgner <felix.morgner@gmail.com>2026-06-05 16:52:16 +0200
commita03409696680e34a860138387651f8257097af41 (patch)
tree2ee0f62ec000bc53252516c586e372a909e903ac /CMakeLists.txt
parent79549aab5b9ca8f0cad4f00bc8ad68b7091ab65f (diff)
downloadcabinet-a03409696680e34a860138387651f8257097af41.tar.xz
cabinet-a03409696680e34a860138387651f8257097af41.zip
magic: add test skeleton
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt32
1 files changed, 32 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f2970ac..2954fc6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,6 +10,10 @@ set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_CXX_EXTENSIONS NO)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
+include("FetchContent")
+include("CTest")
+
+
find_package("PkgConfig")
pkg_check_modules("magic" REQUIRED
@@ -43,3 +47,31 @@ target_sources("cabinet" PRIVATE
target_link_libraries("cabinet" PRIVATE
"cabinet::core"
)
+
+if(BUILD_TESTING)
+ FetchContent_Declare("Catch2"
+ URL "https://github.com/catchorg/Catch2/archive/refs/tags/v3.15.0.tar.gz"
+ URL_HASH "SHA256=9650c55e497759cc39b977e45524bc8acb15256061c112080916ab6cb0b1ea66"
+ EXCLUDE_FROM_ALL
+ FIND_PACKAGE_ARGS "3.15.0"
+ )
+
+ FetchContent_MakeAvailable("Catch2")
+
+ include("Catch")
+
+ add_compile_definitions("CATCH_CONFIG_NO_COUNTER")
+ add_executable("tests")
+ add_executable("cabinet::tests" ALIAS "tests")
+
+ target_sources("tests" PRIVATE
+ "cabinet/magic.tests.cpp"
+ )
+
+ target_link_libraries("tests" PRIVATE
+ "cabinet::core"
+ "Catch2::Catch2WithMain"
+ )
+
+ catch_discover_tests("cabinet::tests")
+endif()