-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
72 lines (52 loc) · 2.15 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
cmake_minimum_required (VERSION 3.0)
project (liboffkv VERSION 0.0.1)
set (CMAKE_CXX_STANDARD 17)
option (ENABLE_ZK "Build with ZooKeeper support" ON)
option (ENABLE_ETCD "Build with etcd support" ON)
option (ENABLE_CONSUL "Build with Consul support" ON)
option (BUILD_TESTS "Build library tests" ON)
option (BUILD_CLIB "Build C library" OFF)
set(SANITIZE "" CACHE STRING "Build tests with sanitizer")
configure_file (liboffkv/version.hpp.in generated/liboffkv/version.hpp @ONLY)
configure_file (liboffkv/config.hpp.in generated/liboffkv/config.hpp @ONLY)
find_package (Threads REQUIRED)
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wpedantic -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers")
endif ()
add_library (liboffkv INTERFACE)
target_include_directories (liboffkv INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}/generated)
target_link_libraries (liboffkv INTERFACE ${CMAKE_THREAD_LIBS_INIT})
if (BUILD_CLIB)
add_library (liboffkv_c SHARED liboffkv/clib.cpp)
target_link_libraries (liboffkv_c liboffkv)
install(TARGETS liboffkv_c DESTINATION lib)
install(FILES liboffkv/clib.h RENAME liboffkv.h DESTINATION include)
endif ()
set (SERVICE_TEST_ADDRESSES)
if (ENABLE_CONSUL)
find_package (ppconsul REQUIRED)
if (WIN32)
find_package (ZLIB REQUIRED) # weird but works
endif ()
target_link_libraries (liboffkv INTERFACE ppconsul)
list (APPEND SERVICE_TEST_ADDRESSES "consul://localhost:8500")
endif ()
if (ENABLE_ZK)
find_package (zkpp REQUIRED)
target_link_libraries (liboffkv INTERFACE zkpp)
list (APPEND SERVICE_TEST_ADDRESSES "zk://localhost:2181")
endif ()
if (ENABLE_ETCD)
find_package (etcdcpp REQUIRED)
find_package (gRPC CONFIG REQUIRED)
target_link_libraries (liboffkv INTERFACE etcdcpp)
target_link_libraries (liboffkv INTERFACE gRPC::gpr gRPC::grpc gRPC::grpc++ gRPC::grpc_cronet)
list (APPEND SERVICE_TEST_ADDRESSES "etcd://localhost:2379")
endif ()
if (BUILD_TESTS)
# google tests
enable_testing ()
add_subdirectory (tests)
endif ()