Skip to content

Commit b060e88

Browse files
committed
Configure Tests With CMake.
branch: [feature/restructuring] - Root CMakeLists.txt added. - FetchContent was used to get the testing library and CTest was used to integrate with the IDE. Signed-off-by: Ghasem Ramezani (Personal GCCORE GPG) <g1999ramezani@gmail.com>
1 parent 3fb8d72 commit b060e88

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
cmake_minimum_required(VERSION 3.11)
2+
project(SortingAlgorithms LANGUAGES CXX)
3+
4+
include(cmake/ConfigureProjectTests.cmake)
5+
Core_ConfigureProjectTests()

cmake/ConfigureProjectTests.cmake

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
function(Core_ConfigureProjectTests)
2+
include(FetchContent)
3+
FetchContent_Declare(
4+
Catch2
5+
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
6+
GIT_TAG v2.13.8
7+
)
8+
FetchContent_MakeAvailable(Catch2)
9+
10+
add_executable(${PROJECT_NAME}Tests test/sort_test.cpp)
11+
target_link_libraries(${PROJECT_NAME}Tests PRIVATE Catch2::Catch2)
12+
13+
include(CTest)
14+
include(${Catch2_SOURCE_DIR}/contrib/Catch.cmake)
15+
catch_discover_tests(${PROJECT_NAME}Tests)
16+
endfunction()

0 commit comments

Comments
 (0)