-
Notifications
You must be signed in to change notification settings - Fork 46
/
CMakeLists.txt
106 lines (83 loc) · 2.99 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
cmake_minimum_required(VERSION 3.12)
project(ozo VERSION 0.0.1)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
# note: boost::coroutine should automatically pull in all the dependencies,
# however, due to changes in boost it doesn't always work until CMake
# is updated. we therefore look for all the dependencies ourselves.
find_package(Boost COMPONENTS coroutine context system thread atomic REQUIRED)
find_package(PostgreSQL REQUIRED)
# Try and find provided resource pool (e.g. from conan), default to vendored version otherwise
find_package(resource_pool 0.1.0 QUIET)
if (NOT resource_pool_FOUND)
add_subdirectory(contrib)
endif()
option(OZO_BUILD_TESTS "Enable tests build" OFF)
option(OZO_COVERAGE "Enable tests coverage" OFF)
option(OZO_BUILD_EXAMPLES "Enable examples build" OFF)
set(CMAKE_CXX_EXTENSIONS OFF)
add_library(ozo INTERFACE)
add_library(yandex::ozo ALIAS ozo)
target_compile_features(ozo INTERFACE cxx_std_17)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
# disable warnings about a compiler-specific option used for gnu-compatible compilers
target_compile_options(ozo INTERFACE $<BUILD_INTERFACE:-Wno-gnu-string-literal-operator-template -Wno-gnu-zero-variadic-macro-arguments>)
endif()
target_include_directories(ozo INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_compile_definitions(ozo INTERFACE -DBOOST_COROUTINES_NO_DEPRECATION_WARNING)
target_compile_definitions(ozo INTERFACE -DBOOST_HANA_CONFIG_ENABLE_STRING_UDL)
# For the time OZO may not support Executor TS
# See https://github.com/yandex/ozo/issues/266
target_compile_definitions(ozo INTERFACE -DBOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
target_link_libraries(ozo INTERFACE Boost::coroutine)
target_link_libraries(ozo INTERFACE PostgreSQL::PostgreSQL)
target_link_libraries(ozo INTERFACE elsid::resource_pool)
install(
DIRECTORY include/ozo
DESTINATION include
)
install(
TARGETS ozo
EXPORT ozo-targets
DESTINATION lib
)
install(
EXPORT ozo-targets
NAMESPACE yandex::
DESTINATION lib/cmake/ozo
)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/ozo/ozo-config-version.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
export(
EXPORT ozo-targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/ozo/ozo-targets.cmake"
NAMESPACE yandex::
)
configure_file(cmake/ozo-config.cmake
"${CMAKE_CURRENT_BINARY_DIR}/ozo/ozo-config.cmake"
COPYONLY
)
install(
FILES
cmake/ozo-config.cmake
cmake/modules/FindPostgreSQL.cmake
"${CMAKE_CURRENT_BINARY_DIR}/ozo/ozo-config-version.cmake"
DESTINATION
lib/cmake/ozo
)
if(OZO_BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif()
if(OZO_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
if(OZO_BUILD_BENCHMARKS)
add_subdirectory(benchmarks)
endif()