forked from userver-framework/userver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
147 lines (117 loc) · 4.89 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
137
138
139
140
141
142
143
144
145
146
147
cmake_minimum_required(VERSION 3.12)
cmake_policy(SET CMP0025 NEW)
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.15")
cmake_policy(SET CMP0093 NEW)
endif()
project(userver)
set(USERVER_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}")
set(USERVER_NOT_INCLUDED_AS_SUBDIR OFF)
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(USERVER_NOT_INCLUDED_AS_SUBDIR ON)
endif()
option(USERVER_FEATURE_UTEST "Provide 'utest' and 'ubench' for unit testing and benchmarking coroutines" ON)
if (USERVER_FEATURE_UTEST)
message(STATUS "Building utest with gtest and ubench with gbench")
endif()
option(USERVER_IS_THE_ROOT_PROJECT "Build tests, samples and helper tools" ${USERVER_NOT_INCLUDED_AS_SUBDIR})
if (USERVER_IS_THE_ROOT_PROJECT)
message(STATUS "Building userver as a primary project")
if (NOT USERVER_FEATURE_UTEST)
message(FATAL_ERROR "Cannot build tests without utest")
endif()
else()
message(STATUS "Building userver as a subproject")
endif()
set(USERVER_BUILD_PLATFORM_X86 OFF)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^x86")
set(USERVER_BUILD_PLATFORM_X86 ON)
endif()
execute_process(
COMMAND bash -c "(apt-key finger '7FCD11186050CD1A' | grep Yandex) || (brew tap | grep 'yandex')"
RESULT_VARIABLE USERVER_NOT_YANDEX_ENV
OUTPUT_QUIET
ERROR_QUIET
)
option(USERVER_OPEN_SOURCE_BUILD "Build without Yandex and MLU packages" ${USERVER_NOT_YANDEX_ENV})
if (NOT USERVER_OPEN_SOURCE_BUILD)
message(STATUS "Using internal to Yandex build setup")
endif()
option(USERVER_DOWNLOAD_PACKAGES "Download missing third party packages and use the downloaded versions" ${USERVER_OPEN_SOURCE_BUILD})
option(USERVER_FEATURE_CRYPTOPP_BLAKE2 "Provide wrappers for blake2 algorithms of crypto++" ON)
if (NOT USERVER_FEATURE_CRYPTOPP_BLAKE2)
add_definitions("-DUSERVER_NO_CRYPTOPP_BLAKE2=1")
endif()
option(USERVER_FEATURE_CRYPTOPP_BASE64_URL "Provide wrappers for Base64 URL decoding and encoding algorithms of crypto++" ON)
if (NOT USERVER_FEATURE_CRYPTOPP_BASE64_URL)
add_definitions("-DUSERVER_NO_CRYPTOPP_BASE64_URL=1")
endif()
option(USERVER_FEATURE_JEMALLOC "Enable linkage with jemalloc memory allocator" ON)
option(USERVER_CHECK_PACKAGE_VERSIONS "Check package versions" ON)
include(cmake/SetupEnvironment.cmake)
include(AddGoogleTests)
include(CheckSubmodule)
include(Sanitizers)
include(FindPackageRequired)
include(IncludeWhatYouUse)
include(FindPython)
message(STATUS "Generating cmake files ...")
execute_process(
COMMAND
${PYTHON} -u ${CMAKE_CURRENT_SOURCE_DIR}/plugins/external_deps/impl/cmake_generator.py
--repo-dir=${CMAKE_CURRENT_SOURCE_DIR}
--build-dir=${CMAKE_BINARY_DIR}
RESULT_VARIABLE RESULT
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
if (RESULT)
message(FATAL_ERROR
"Generating cmake files failed with exit code: ${RESULT}"
)
endif(RESULT)
set(USERVER_THIRD_PARTY_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/third_party CACHE INTERNAL "")
init_debian_depends()
option(USERVER_FEATURE_MONGODB "Provide asynchronous driver for MongoDB" ${USERVER_BUILD_PLATFORM_X86})
option(USERVER_FEATURE_POSTGRESQL "Provide asynchronous driver for PostgreSQL" ON)
option(USERVER_FEATURE_REDIS "Provide asynchronous driver for Redis" ON)
option(USERVER_FEATURE_GRPC "Provide asynchronous driver for gRPC" ON)
option(USERVER_FEATURE_CLICKHOUSE "Provide asynchronous driver for ClickHouse" ${USERVER_BUILD_PLATFORM_X86})
option(USERVER_FEATURE_RABBITMQ "Provide asynchronous driver for RabbitMQ" ${USERVER_OPEN_SOURCE_BUILD})
option(USERVER_FEATURE_UNIVERSAL "Provide a universal utilities library that does not use coroutines" ON)
add_subdirectory(core "${CMAKE_BINARY_DIR}/userver/core")
add_subdirectory("${USERVER_THIRD_PARTY_DIRS}/boost_stacktrace")
add_subdirectory("${USERVER_THIRD_PARTY_DIRS}/compiler-rt")
add_subdirectory(uboost_coro)
if (USERVER_IS_THE_ROOT_PROJECT)
include(testsuite/SetupUserverTestsuiteEnv.cmake)
add_subdirectory(testsuite)
add_subdirectory(tools/engine)
add_subdirectory(tools/json2yaml)
add_subdirectory(tools/httpclient)
add_subdirectory(tools/netcat)
add_subdirectory(tools/dns_resolver)
add_subdirectory(tools/congestion_control_emulator)
endif()
if (USERVER_FEATURE_MONGODB)
add_subdirectory(mongo "${CMAKE_BINARY_DIR}/userver/mongo")
endif()
if (USERVER_FEATURE_POSTGRESQL)
add_subdirectory(postgresql "${CMAKE_BINARY_DIR}/userver/postgresql")
endif()
if (USERVER_FEATURE_REDIS)
add_subdirectory(redis "${CMAKE_BINARY_DIR}/userver/redis")
endif()
if (USERVER_FEATURE_GRPC)
add_subdirectory(grpc "${CMAKE_BINARY_DIR}/userver/grpc")
endif()
if (USERVER_FEATURE_CLICKHOUSE)
add_subdirectory(clickhouse "${CMAKE_BINARY_DIR}/userver/clickhouse")
endif()
if (USERVER_FEATURE_RABBITMQ)
add_subdirectory(rabbitmq "${CMAKE_BINARY_DIR}/userver/rabbitmq")
endif()
if (USERVER_FEATURE_UNIVERSAL)
add_subdirectory(universal "${CMAKE_BINARY_DIR}/userver/universal")
endif()
if (USERVER_IS_THE_ROOT_PROJECT)
add_subdirectory(samples)
endif()