-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
37 lines (28 loc) · 1019 Bytes
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
cmake_minimum_required(VERSION 3.10)
project(DSA VERSION 1.0)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
file(GLOB SOURCES "src/*.cpp")
add_library(dsa ${SOURCES})
target_include_directories(dsa PUBLIC ${PROJECT_SOURCE_DIR}/include)
file(GLOB DEMO_SOURCES "demos/*.cpp")
foreach(demo_source ${DEMO_SOURCES})
get_filename_component(demo_name ${demo_source} NAME_WE)
add_executable(${demo_name} ${demo_source})
target_link_libraries(${demo_name} dsa)
endforeach()
enable_testing()
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.15.2
)
FetchContent_MakeAvailable(googletest)
file(GLOB TEST_SOURCES "tests/*.cpp")
foreach(test_source ${TEST_SOURCES})
get_filename_component(test_name ${test_source} NAME_WE)
add_executable(${test_name} ${test_source})
target_link_libraries(${test_name} gtest_main dsa)
add_test(NAME ${test_name}Tests COMMAND ${test_name})
endforeach()