-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
136 lines (111 loc) · 3.22 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# CMakeLists.txt for pg_async library
#
# @author zmij
# @date Jul 18, 2015
cmake_minimum_required(VERSION 2.6)
if (NOT PROJECT_PREFIX)
set(PROJECT_PREFIX tip)
endif()
if (PROJECT_VERSION)
# Built as a subproject
set(_pversion ${PROJECT_VERSION})
else()
set(_pversion 1.0.0)
endif()
set(_pname ${PROJECT_PREFIX}-pg-async)
if (${CMAKE_VERSION} VERSION_GREATER "3.0")
cmake_policy(SET CMP0048 NEW)
project(${_pname} VERSION ${_pversion})
else()
project(${_pname})
set(PROJECT_VERSION ${_pversion})
endif()
option(USE_TIP_LOG "Use tip::log logger library" OFF)
option(BUILD_TESTS "Build tests for the library" OFF)
option(USE_BOOST_ASIO "Use Boost.Asio instead of Standalone Asio library" ON)
option(WITH_BOOST_FIBER "Build wire with boost::fiber support" OFF)
# Dependencies
set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
"${CMAKE_CURRENT_SOURCE_DIR}/lib/afsm/cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/lib/afsm/lib/meta/cmake")
set(BOOST_COMPONENTS
system
thread
)
set(BOOST_VERSION 1.58)
if (WITH_BOOST_FIBER)
set(BOOST_VERSION 1.61) # Boost.Fiber was introduced in version 1.61
list(APPEND BOOST_COMPONENTS context fiber)
endif()
find_package(Boost ${BOOST_VERSION} COMPONENTS ${BOOST_COMPONENTS} REQUIRED)
set(
ASIO_LIBRARIES
${Boost_SYSTEM_LIBRARIES}
${Boost_THREAD_LIBRARIES}
)
add_definitions(-DWITH_BOOST_ASIO)
if(WITH_BOOST_FIBER)
set(FIBER_LIBS
${Boost_CONTEXT_LIBRARIES}
${Boost_FIBER_LIBRARIES}
)
endif()
find_package(Threads REQUIRED)
find_package(AFSM)
add_definitions("-std=c++11")
if(USE_TIP_LOG)
if(NOT TIP_LOG_INCLUDE_DIRS)
set(_LOG_SUBTREE ON)
endif()
endif()
if(NOT TIP_UTIL_INCLUDE_DIRS)
set(TIP_UTIL_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/lib/util/include)
endif()
if (_LOG_SUBTREE)
add_subdirectory(lib/log)
link_directories(${TIP_LOG_LINK_DIR})
endif()
if(NOT AFSM_FOUND)
add_subdirectory(lib/afsm)
endif()
if (NOT PUSHKIN_ASIO_FIBERS_INCLUDE_DIRECTORIES)
set(_PUSHKIN_ASIO_FIBERS_SUBTREE ON)
endif()
if (_PUSHKIN_ASIO_FIBERS_SUBTREE)
add_subdirectory(lib/asio-fiber)
endif()
include_directories(
SYSTEM
${Boost_INCLUDE_DIRS}
)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_BINARY_DIR}/include
${CMAKE_CURRENT_BINARY_DIR}/src
${METAPUSHKIN_INCLUDE_DIRS}
${AFSM_INCLUDE_DIRS}
${TIP_UTIL_INCLUDE_DIRS}
${TIP_LOG_INCLUDE_DIRS}
${PUSHKIN_ASIO_FIBERS_INCLUDE_DIRECTORIES}
)
if (USE_TIP_LOG)
add_definitions(-DWITH_TIP_LOG)
endif()
set(PGASYNC_LIB_NAME ${PROJECT_PREFIX}-psql)
if(WITH_BOOST_FIBER)
set(PGFIBER_LIB_NAME ${PROJECT_PREFIX}-psql-fiber)
endif()
add_subdirectory(src/tip/db/pg)
add_subdirectory(include/tip/db)
if (BUILD_TESTS)
enable_testing()
add_subdirectory(test)
endif()
get_directory_property(has_parent PARENT_DIRECTORY)
if (has_parent)
set(TIP_DB_LIB ${PGASYNC_LIB_NAME} CACHE INTERNAL "Name of tip psql library target")
set(TIP_DB_FIBER_LIB ${PGFIBER_LIB_NAME} CACHE INTERNAL "Name of tip psql fiber library target")
set(TIP_DB_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include ${TIP_LOG_INCLUDE_DIRS} CACHE INTERNAL "Paths to tip psql library includes")
endif()