-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
47 lines (38 loc) · 1.48 KB
/
Copy pathCMakeLists.txt
File metadata and controls
47 lines (38 loc) · 1.48 KB
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
cmake_minimum_required(VERSION 3.16)
project(ConcurrentCacheSystem VERSION 0.1.0 LANGUAGES CXX)
option(CONCURRENT_CACHE_BUILD_TESTS "Build the test executable" ON)
option(CONCURRENT_CACHE_ENABLE_SANITIZERS "Enable AddressSanitizer and UBSan" OFF)
add_library(concurrent_cache INTERFACE)
add_library(ConcurrentCacheSystem::concurrent_cache ALIAS concurrent_cache)
target_include_directories(
concurrent_cache
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>
)
target_compile_features(concurrent_cache INTERFACE cxx_std_17)
if(CONCURRENT_CACHE_BUILD_TESTS)
enable_testing()
find_package(Threads REQUIRED)
add_executable(cache_tests tests/cache_tests.cpp)
target_link_libraries(cache_tests PRIVATE concurrent_cache Threads::Threads)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
target_compile_options(cache_tests PRIVATE -Wall -Wextra -Wpedantic -Werror)
endif()
if(CONCURRENT_CACHE_ENABLE_SANITIZERS)
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
message(FATAL_ERROR "Sanitizers require Clang or GCC")
endif()
target_compile_options(
cache_tests PRIVATE
-fsanitize=address,undefined
-fno-omit-frame-pointer
)
target_link_options(
cache_tests PRIVATE
-fsanitize=address,undefined
-fno-omit-frame-pointer
)
endif()
add_test(NAME cache_tests COMMAND cache_tests)
endif()