-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
57 lines (47 loc) · 1.51 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
cmake_minimum_required(VERSION 3.10)
project(memcache LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
# Add source and header files
include_directories(include)
add_library(MemCache SHARED
src/memcache.cpp
src/frequencynode.cpp
src/keynode.cpp
src/mapitem.cpp
utils/memory_info.h
utils/serialization.h
utils/extern_lib.h
utils/extern_lib.cc
)
# Add Snappy
set(SNAPPY_INCLUDE_DIRS "/usr/include")
set(SNAPPY_LIBRARIES "/usr/lib/x86_64-linux-gnu/libsnappy.so")
target_link_libraries(MemCache ${SNAPPY_LIBRARIES})
target_sources(MemCache PRIVATE utils/compression.h)
# Option to use submodule for googletest
option(USE_SUBMODULE_GTEST "Use googletest from submodule" OFF)
# Add Google Test
if(USE_SUBMODULE_GTEST)
# Use googletest from submodule
add_subdirectory(extern/googletest)
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
target_link_libraries(MemCache gtest gtest_main)
else()
# Use system-installed googletest
find_package(GTest REQUIRED)
include_directories(${GTEST_INCLUDE_DIRS})
endif()
# Add test executable
add_executable(run_tests
tests/test_memcache.cpp
tests/test_thread_safety.cpp
tests/test_atomicity.cpp
tests/test_snapshot.cpp
tests/test_serialization.cpp
)
if(USE_SUBMODULE_GTEST)
target_link_libraries(run_tests gtest gtest_main pthread MemCache ${SNAPPY_LIBRARIES})
else()
target_link_libraries(run_tests ${GTEST_LIBRARIES} pthread MemCache ${SNAPPY_LIBRARIES})
endif()