-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
188 lines (162 loc) · 5.11 KB
/
Copy pathCMakeLists.txt
File metadata and controls
188 lines (162 loc) · 5.11 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
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#
# @file
#
# Copyright 2026, Verizon Media SPDX-License-Identifier: Apache-2.0
#
cmake_minimum_required(VERSION 4.2.3)
project(
ProxyVerifier
VERSION 3.1.3
LANGUAGES C CXX)
include(CTest)
include(GNUInstallDirs)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX
"/usr/local"
CACHE PATH "Install path prefix, prepended onto install directories."
FORCE)
endif()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
option(
PV_BOOTSTRAP_DEPS
"Fetch and build external QUIC/TLS dependencies as part of the CMake build."
OFF)
option(PV_STATIC_BUILD
"Link the verifier binaries with static third-party dependencies." OFF)
option(PV_ENABLE_ASAN
"Build the verifier binaries with AddressSanitizer instrumentation." OFF)
option(PV_RELEASE_LAYOUT
"Install release artifacts into a platform-specific bindir." OFF)
option(
BUILD_PORTABLE
"Enable portable build settings such as conservative Linux amd64 ISA flags."
OFF)
function(pv_detect_portable_amd64_flags out_var)
set(_pv_flags "")
if(BUILD_PORTABLE AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" _pv_portable_arch)
if(_pv_portable_arch MATCHES "^(x86_64|amd64)$")
set(_pv_flags "-march=x86-64 -mtune=generic")
endif()
endif()
set(${out_var}
"${_pv_flags}"
PARENT_SCOPE)
endfunction()
function(_pv_add_portable_compile_options language flags)
if(NOT flags)
return()
endif()
separate_arguments(_pv_flag_list NATIVE_COMMAND "${flags}")
foreach(_pv_flag IN LISTS _pv_flag_list)
add_compile_options("$<$<COMPILE_LANGUAGE:${language}>:${_pv_flag}>")
endforeach()
endfunction()
set(PV_DEPS_ROOT
""
CACHE
PATH
"Common dependency root containing openssl/nghttp2/ngtcp2/nghttp3 subdirectories."
)
set(PV_OPENSSL_ROOT
""
CACHE PATH "Explicit OpenSSL root.")
set(PV_NGHTTP2_ROOT
""
CACHE PATH "Explicit nghttp2 root.")
set(PV_NGTCP2_ROOT
""
CACHE PATH "Explicit ngtcp2 root.")
set(PV_NGHTTP3_ROOT
""
CACHE PATH "Explicit nghttp3 root.")
set(PV_RELEASE_TARGET
""
CACHE STRING
"Release artifact target name such as linux-amd64 or darwin-arm64.")
pv_detect_portable_amd64_flags(PV_PORTABLE_C_FLAGS)
set(PV_PORTABLE_CXX_FLAGS "${PV_PORTABLE_C_FLAGS}")
if(BUILD_PORTABLE)
_pv_add_portable_compile_options(C "${PV_PORTABLE_C_FLAGS}")
_pv_add_portable_compile_options(CXX "${PV_PORTABLE_CXX_FLAGS}")
endif()
function(pv_detect_release_target out_var)
string(TOLOWER "${CMAKE_SYSTEM_NAME}" _pv_release_os)
if(_pv_release_os STREQUAL "linux")
set(_pv_release_os "linux")
elseif(_pv_release_os STREQUAL "darwin")
set(_pv_release_os "darwin")
else()
message(
FATAL_ERROR
"Unsupported release platform \"${CMAKE_SYSTEM_NAME}\" for PV_RELEASE_LAYOUT."
)
endif()
string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" _pv_release_arch)
if(_pv_release_arch MATCHES "^(x86_64|amd64)$")
set(_pv_release_arch "amd64")
elseif(_pv_release_arch MATCHES "^(aarch64|arm64)$")
set(_pv_release_arch "arm64")
else()
message(
FATAL_ERROR
"Unsupported release architecture \"${CMAKE_SYSTEM_PROCESSOR}\" for PV_RELEASE_LAYOUT."
)
endif()
set(${out_var}
"${_pv_release_os}-${_pv_release_arch}"
PARENT_SCOPE)
endfunction()
if(PV_ENABLE_ASAN AND PV_STATIC_BUILD)
message(
FATAL_ERROR
"PV_ENABLE_ASAN and PV_STATIC_BUILD cannot both be enabled in this build."
)
endif()
if(PV_RELEASE_LAYOUT)
pv_detect_release_target(_pv_detected_release_target)
if(CMAKE_INSTALL_PREFIX STREQUAL "/tmp")
set(CMAKE_INSTALL_PREFIX
"/tmp/proxy-verifier-v${PROJECT_VERSION}"
CACHE PATH "Install path prefix, prepended onto install directories."
FORCE)
endif()
if(NOT PV_RELEASE_TARGET)
set(PV_RELEASE_TARGET
"${_pv_detected_release_target}"
CACHE
STRING
"Release artifact target name such as linux-amd64 or darwin-arm64."
FORCE)
elseif(NOT PV_RELEASE_TARGET STREQUAL _pv_detected_release_target)
message(
FATAL_ERROR
"PV_RELEASE_TARGET=\"${PV_RELEASE_TARGET}\" does not match the current build target "
"\"${_pv_detected_release_target}\". Release presets are native-only unless you provide "
"an explicit cross-compilation toolchain.")
endif()
set(CMAKE_INSTALL_BINDIR
"${PV_RELEASE_TARGET}"
CACHE STRING "Install directory for runtime targets." FORCE)
endif()
include(PVFetchDependencies)
pv_fetch_dependencies()
include(HttpDependencies)
pv_define_http_dependencies(
OUT_LIBRARIES
PV_EXTERNAL_DEPENDENCY_TARGETS
OUT_RPATH_DIRS
PV_EXTERNAL_RPATH_DIRS
OUT_BOOTSTRAP_TARGETS
PV_BOOTSTRAP_TARGETS
OUT_BOOTSTRAP_PREFIX
PV_BOOTSTRAP_PREFIX)
add_subdirectory(src)
add_subdirectory(tests/autests)
add_subdirectory(tests/unit_tests)