diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ad1f01..c25b0a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,7 @@ -cmake_minimum_required(VERSION 3.28) -project(raiiSafeCuda) +cmake_minimum_required(VERSION 3.28 FATAL_ERROR) +project(raiiSafeCuda CXX) + +option(ENABLE_TESTS "Enable tests' cmake target." ON) find_package(CUDAToolkit REQUIRED) @@ -13,3 +15,7 @@ set_target_properties(raiiSafeCuda PROPERTIES CXX_EXTENSIONS OFF INTERPROCEDURAL_OPTIMIZATION ON ) + +if (ENABLE_TESTS) + add_subdirectory(tests) +endif () diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..0f967ee --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,26 @@ +project(testsRaiiSafeCuda CXX) + +find_package(Catch2) +if (NOT Catch2_FOUND) + message(STATUS "Using FetchContent to download and use Catch2") + include(FetchContent) + fetchcontent_declare( + Catch2 + GIT_REPOSITORY https://github.com/catchorg/Catch2 + GIT_TAG v3.5.3 + EXCLUDE_FROM_ALL + OVERRIDE_FIND_PACKAGE + ) + fetchcontent_makeavailable(Catch2) + find_package(Catch2 3 REQUIRED) +endif () + +include(CTest) +enable_testing() +include(Catch) +include(CatchAddTests) + +add_executable(tests tests_stream.cpp) +target_link_libraries(tests Catch2::Catch2WithMain) + +catch_discover_tests(tests WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/tests/tests_stream.cpp b/tests/tests_stream.cpp new file mode 100644 index 0000000..2e71430 --- /dev/null +++ b/tests/tests_stream.cpp @@ -0,0 +1,9 @@ +// +// Created by postaron on 21/03/24. +// + +#include + +TEST_CASE("hello", "world") { + +}