-
Notifications
You must be signed in to change notification settings - Fork 31
/
CMakeLists.txt
96 lines (78 loc) · 2.81 KB
/
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#Preamble
cmake_minimum_required(VERSION 3.15)
# Detect if we are bundled and skip building of tests in that case
IF (NOT DEFINED PROJECT_NAME)
SET(NOT_SUBPROJECT ON)
ENDIF ()
project(STLCache
LANGUAGES CXX
VERSION 0.4)
#Environment detection
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
IF(MSVC)
add_definitions(-D_ENFORCE_MATCHING_ALLOCATORS=0)
ENDIF()
#Check for libraries presence
FIND_PACKAGE(Boost 1.58.0)
#Documentation stuff
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
include(UseDoxygen)
set(DOXYFILE_LATEX OFF)
#Build configuration
include_directories(${CMAKE_BINARY_DIR}
${CMAKE_SOURCE_DIR}/include
)
add_library(STLCache INTERFACE)
target_include_directories(STLCache INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
install(DIRECTORY include/stlcache DESTINATION include)
IF (NOT_SUBPROJECT)
# Set standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Compile Boost specific tests
if (Boost_FOUND)
add_compile_definitions(USE_BOOST)
include_directories(${Boost_INCLUDE_DIRS})
endif ()
# Retrieve the Catch2
Include(FetchContent)
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.3.2
)
FetchContent_MakeAvailable(Catch2)
# Retrieve Google Benchmark
SET(BENCHMARK_ENABLE_TESTING OFF)
SET(BENCHMARK_DOWNLOAD_DEPENDENCIES ON)
FetchContent_Declare(
Benchmark
GIT_REPOSITORY https://github.com/google/benchmark.git
GIT_TAG v1.7.1
)
FetchContent_MakeAvailable(Benchmark)
# Unit tests binary
add_executable(tests
tests/test_main.cpp tests/test_map.cpp tests/test_map_interface.cpp tests/test_iterator.cpp tests/test_optional.cpp tests/test_insert_assign.cpp
tests/test_victim.cpp tests/test_policy.cpp
tests/test_lru.cpp tests/test_mru.cpp
tests/test_lfu.cpp tests/test_lfustar.cpp tests/test_lfuaging.cpp tests/test_lfuagingstar.cpp tests/test_lfu_multi.cpp
tests/test_adaptive.cpp)
target_link_libraries(tests PRIVATE Catch2::Catch2WithMain ${LIBS})
# Add tests auto discovery
list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras)
include(CTest)
include(Catch)
enable_testing()
catch_discover_tests(tests)
# Benchmarks
add_executable(insert_perf benchmarks/insert_perf.cpp)
target_link_libraries(insert_perf benchmark::benchmark)
add_executable(insdel_perf benchmarks/insdel_perf.cpp)
target_link_libraries(insdel_perf benchmark::benchmark)
add_executable(eviction_perf benchmarks/eviction_perf.cpp)
target_link_libraries(eviction_perf benchmark::benchmark)
ENDIF ()