CMakeLists.txt
3.1 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
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
97
98
99
100
101
102
103
104
105
106
107
108
109
cmake_minimum_required(VERSION 2.8.4)
project(redox)
option(library "Build Redox as a library." ON)
option(tests "Build all tests." ON)
option(examples "Build all examples." ON)
# Use RelWithDebInfo if no configuration specified
if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC -Wall")
# Print out compiler commands
# set(CMAKE_VERBOSE_MAKEFILE ON)
# ---------------------------------------------------------
# Source files
# ---------------------------------------------------------
set(SRC_DIR ${CMAKE_SOURCE_DIR}/src)
set(SRC_CORE
${SRC_DIR}/client.cpp
${SRC_DIR}/command.cpp
${SRC_DIR}/subscriber.cpp
)
set(SRC_LOGGER ${SRC_DIR}/utils/logger.cpp)
set(SRC_ALL ${SRC_CORE} ${SRC_LOGGER})
include_directories(${SRC_DIR})
# ---------------------------------------------------------
# Linked libraries
# ---------------------------------------------------------
set(LIB_REDOX redox hiredis ev pthread)
# ---------------------------------------------------------
# Library generation
# ---------------------------------------------------------
if (library)
add_library(redox SHARED ${SRC_ALL})
add_library(redox_static STATIC ${SRC_ALL})
endif()
# ---------------------------------------------------------
# Test suite
# ---------------------------------------------------------
if (tests)
enable_testing()
find_package(GTest REQUIRED)
add_executable(test_redox test/test.cpp)
target_include_directories(test_redox PUBLIC ${GTEST_INCLUDE_DIRS})
target_link_libraries(test_redox ${LIB_REDOX} gtest)
# So that we can run 'make test'
add_test(test_redox test_redox)
endif()
# ---------------------------------------------------------
# Examples
# ---------------------------------------------------------
if (examples)
add_executable(basic examples/basic.cpp)
target_link_libraries(basic ${LIB_REDOX})
add_executable(basic_threaded examples/basic_threaded.cpp)
target_link_libraries(basic_threaded ${LIB_REDOX})
add_executable(lpush_benchmark examples/lpush_benchmark.cpp)
target_link_libraries(lpush_benchmark ${LIB_REDOX})
add_executable(speed_test_async examples/speed_test_async.cpp)
target_link_libraries(speed_test_async ${LIB_REDOX})
add_executable(speed_test_sync examples/speed_test_sync.cpp)
target_link_libraries(speed_test_sync ${LIB_REDOX})
add_executable(speed_test_async_multi examples/speed_test_async_multi.cpp)
target_link_libraries(speed_test_async_multi ${LIB_REDOX})
add_executable(data_types examples/data_types.cpp)
target_link_libraries(data_types ${LIB_REDOX})
add_executable(multi_client examples/multi-client.cpp)
target_link_libraries(multi_client ${LIB_REDOX})
add_executable(binary_data examples/binary_data.cpp)
target_link_libraries(binary_data ${LIB_REDOX})
add_executable(pub_sub examples/pub_sub.cpp)
target_link_libraries(pub_sub ${LIB_REDOX})
add_executable(speed_test_pubsub examples/speed_test_pubsub ${SRC_ALL})
target_link_libraries(speed_test_pubsub ${LIB_REDOX})
endif()