| 7 | # https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 |
| 15 | cmake_minimum_required(VERSION 3.16) |
| 16 |
| 17 | # Defer enabling C and CXX languages. |
| 18 | project(BoringSSL NONE) |
| 19 |
| 20 | # Don't install BoringSSL to system directories by default; it has no stable |
| 21 | # ABI. Instead, default to an "install" directory under the source. |
| 22 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) |
| 23 | set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/install CACHE PATH "" FORCE) |
| 24 | endif() |
| 25 |
| 26 | if(WIN32) |
| 27 | # On Windows, prefer cl over gcc if both are available. By default most of |
| 28 | # the CMake generators prefer gcc, even on Windows. |
| 29 | set(CMAKE_GENERATOR_CC cl) |
| 30 | endif() |
| 31 |
| 32 | include(cmake/go.cmake) |
| 33 | include(cmake/paths.cmake) |
| 34 | include(gen/sources.cmake) |
| 35 |
| 36 | enable_language(C) |
| 37 | enable_language(CXX) |
| 38 |
| 39 | include(GNUInstallDirs) |
| 40 |
| 41 | set(INSTALL_ENABLED 1) |
| 42 |
| 43 | if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT CMAKE_CROSSCOMPILING) |
| 44 | find_package(PkgConfig QUIET) |
| 45 | if (PkgConfig_FOUND) |
| 46 | pkg_check_modules(LIBUNWIND libunwind-generic>=1.3.0) |
| 47 | if(LIBUNWIND_FOUND) |
| 48 | add_definitions(-DBORINGSSL_HAVE_LIBUNWIND) |
| 49 | else() |
| 50 | message("libunwind not found. Disabling unwind tests.") |
| 51 | endif() |
| 52 | else() |
| 53 | message("pkgconfig not found. Disabling unwind tests.") |
| 54 | endif() |
| 55 | endif() |
| 56 |
| 57 | string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER) |
| 58 | if(NOT FIPS) |
| 59 | if(CMAKE_BUILD_TYPE_LOWER STREQUAL "relwithassert" OR |
| 60 | NOT CMAKE_BUILD_TYPE_LOWER MATCHES "rel") |
| 61 | add_definitions(-DBORINGSSL_DISPATCH_TEST) |
| 62 | # CMake automatically connects include_directories to the NASM |
| 63 | # command-line, but not add_definitions. |
| 64 | set(CMAKE_ASM_NASM_FLAGS "${CMAKE_ASM_NASM_FLAGS} -DBORINGSSL_DISPATCH_TEST") |
| 65 | endif() |
| 66 | endif() |
| 67 |
| 68 | # Add a RelWithAsserts build configuration. It is the same as Release, except it |
| 69 | # does not define NDEBUG, so asserts run. |
| 70 | foreach(VAR CMAKE_C_FLAGS CMAKE_CXX_FLAGS CMAKE_ASM_FLAGS) |
| 71 | string(REGEX REPLACE "(^| )[/-]DNDEBUG( |$)" " " "${VAR}_RELWITHASSERTS" |
| 72 | "${${VAR}_RELEASE}") |
| 73 | endforeach() |
| 74 |
| 75 | if(BORINGSSL_PREFIX AND BORINGSSL_PREFIX_SYMBOLS) |
| 76 | require_go() |
| 77 | add_definitions(-DBORINGSSL_PREFIX=${BORINGSSL_PREFIX}) |
| 78 | # CMake automatically connects include_directories to the NASM command-line, |
| 79 | # but not add_definitions. |
| 80 | set(CMAKE_ASM_NASM_FLAGS "${CMAKE_ASM_NASM_FLAGS} -DBORINGSSL_PREFIX=${BORINGSSL_PREFIX}") |
| 81 |
| 82 | # Use "symbol_prefix_include" to store generated header files |
| 83 | include_directories(${CMAKE_CURRENT_BINARY_DIR}/symbol_prefix_include) |
| 84 | add_custom_command( |
| 85 | OUTPUT symbol_prefix_include/boringssl_prefix_symbols.h |
| 86 | symbol_prefix_include/boringssl_prefix_symbols_asm.h |
| 87 | symbol_prefix_include/boringssl_prefix_symbols_nasm.inc |
| 88 | COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/symbol_prefix_include |
| 89 | COMMAND ${GO_EXECUTABLE} run ${CMAKE_CURRENT_SOURCE_DIR}/util/make_prefix_headers.go -out ${CMAKE_CURRENT_BINARY_DIR}/symbol_prefix_include ${BORINGSSL_PREFIX_SYMBOLS} |
| 90 | DEPENDS util/make_prefix_headers.go |
| 91 | ${BORINGSSL_PREFIX_SYMBOLS}) |
| 92 |
| 93 | # add_dependencies needs a target, not a file, so we add an intermediate |
| 94 | # target. |
| 95 | add_custom_target( |
| 96 | boringssl_prefix_symbols |
| 97 | DEPENDS symbol_prefix_include/boringssl_prefix_symbols.h |
| 98 | symbol_prefix_include/boringssl_prefix_symbols_asm.h |
| 99 | symbol_prefix_include/boringssl_prefix_symbols_nasm.inc) |
| 100 | elseif(BORINGSSL_PREFIX OR BORINGSSL_PREFIX_SYMBOLS) |
| 101 | message(FATAL_ERROR "Must specify both or neither of BORINGSSL_PREFIX and BORINGSSL_PREFIX_SYMBOLS") |
| 102 | else() |
| 103 | add_custom_target(boringssl_prefix_symbols) |
| 104 | endif() |
| 105 |
| 106 | if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") |
| 107 | set(CLANG 1) |
| 108 | endif() |
| 109 |
| 110 | if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten") |
| 111 | set(EMSCRIPTEN 1) |
| 112 | endif() |
| 113 |
| 114 | set(CMAKE_CXX_STANDARD 17) |
| 115 | set(CMAKE_CXX_STANDARD_REQUIRED ON) |
| 116 | set(CMAKE_C_STANDARD 11) |
| 117 | set(CMAKE_C_STANDARD_REQUIRED ON) |
| 118 |
| 119 | if(CMAKE_COMPILER_IS_GNUCXX OR CLANG) |
| 120 | # Note clang-cl is odd and sets both CLANG and MSVC. We base our configuration |
| 121 | # primarily on our normal Clang one. |
| 122 | set(C_CXX_FLAGS "-Werror -Wformat=2 -Wsign-compare -Wwrite-strings -Wvla -Wshadow -Wtype-limits -Wmissing-field-initializers") |
| 123 | if(MSVC) |
| 124 | # clang-cl sets different default warnings than clang. It also treats -Wall |
| 125 | # as -Weverything, to match MSVC. Instead -W3 is the alias for -Wall. |
| 126 | # See http://llvm.org/viewvc/llvm-project?view=revision&revision=319116 |
| 127 | set(C_CXX_FLAGS "${C_CXX_FLAGS} -W3 -Wno-unused-parameter -fmsc-version=1900") |
| 128 | else() |
| 129 | if(EMSCRIPTEN) |
| 130 | # emscripten's emcc/clang does not accept the "-ggdb" flag. |
| 131 | set(C_CXX_FLAGS "${C_CXX_FLAGS} -g") |
| 132 | else() |
| 133 | set(C_CXX_FLAGS "${C_CXX_FLAGS} -ggdb") |
| 134 | endif() |
| 135 |
| 136 | set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wall -fvisibility=hidden -fno-common") |
| 137 | endif() |
| 138 |
| 139 | if(CLANG) |
| 140 | set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wnewline-eof -Wextra-semi -fcolor-diagnostics") |
| 141 | else() |
| 142 | # GCC (at least 4.8.4) has a bug where it'll find unreachable free() calls |
| 143 | # and declare that the code is trying to free a stack pointer. |
| 144 | set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wno-free-nonheap-object") |
| 145 | endif() |
| 146 |
| 147 | # -Wstring-concatenation was added in Clang 12.0.0, which corresponds to |
| 148 | # AppleClang 13.0.0 per the table in |
| 149 | # https://en.wikipedia.org/wiki/Xcode#Toolchain_versions |
| 150 | if((CMAKE_C_COMPILER_ID STREQUAL "Clang" AND |
| 151 | CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "12.0.0") OR |
| 152 | (CMAKE_C_COMPILER_ID STREQUAL "AppleClang" AND |
| 153 | CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "13.0.0")) |
| 154 | set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wstring-concatenation") |
| 155 | endif() |
| 156 |
| 157 | # Clang 12's -Wframe-larger-than reportedly does not work in clang-cl. See |
| 158 | # https://crbug.com/boringssl/709. Clang 13 includes the following fix, which |
| 159 | # may be related. Speculatively gate on Clang 13. That corresponds to |
| 160 | # AppleClang 13.1.6. |
| 161 | # https://github.com/llvm/llvm-project/commit/6aaf4fa2885600b0e31042071ad06f78218ab0f2 |
| 162 | if((CMAKE_C_COMPILER_ID STREQUAL "Clang" AND |
| 163 | CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "13.0.0") OR |
| 164 | (CMAKE_C_COMPILER_ID STREQUAL "AppleClang" AND |
| 165 | CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "13.1.6")) |
| 166 | set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wframe-larger-than=25344") |
| 167 | endif() |
| 168 |
| 169 | # -Wctad-maybe-unsupported was added in Clang 10, which is AppleClang 12.0.0. |
| 170 | if((CMAKE_C_COMPILER_ID STREQUAL "Clang" AND |
| 171 | CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "10.0.0") OR |
| 172 | (CMAKE_C_COMPILER_ID STREQUAL "AppleClang" AND |
| 173 | CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "12.0.0")) |
| 174 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wctad-maybe-unsupported") |
| 175 | endif() |
| 176 |
| 177 | if(CLANG OR CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "7.0.0") |
| 178 | set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wimplicit-fallthrough") |
| 179 | endif() |
| 180 |
| 181 | if(CMAKE_COMPILER_IS_GNUCXX) |
| 182 | set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wformat-signedness") |
| 183 | endif() |
| 184 |
| 185 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${C_CXX_FLAGS} -Wmissing-prototypes -Wold-style-definition -Wstrict-prototypes") |
| 186 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${C_CXX_FLAGS} -Wmissing-declarations -Wnon-virtual-dtor") |
| 187 |
| 188 | # In GCC, -Wmissing-declarations is the C++ spelling of -Wmissing-prototypes |
| 189 | # and using the wrong one is an error. In Clang, -Wmissing-prototypes is the |
| 190 | # spelling for both and -Wmissing-declarations is some other warning. |
| 191 | # |
| 192 | # https://gcc.gnu.org/onlinedocs/gcc-7.1.0/gcc/Warning-Options.html#Warning-Options |
| 193 | # https://clang.llvm.org/docs/DiagnosticsReference.html#wmissing-prototypes |
| 194 | # https://clang.llvm.org/docs/DiagnosticsReference.html#wmissing-declarations |
| 195 | if(CLANG) |
| 196 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wmissing-prototypes") |
| 197 | endif() |
| 198 | elseif(MSVC) |
| 199 | set(MSVC_DISABLED_WARNINGS_LIST |
| 200 | "C4100" # 'exarg' : unreferenced formal parameter |
| 201 | "C4127" # conditional expression is constant |
| 202 | "C4244" # 'function' : conversion from 'int' to 'uint8_t', |
| 203 | # possible loss of data |
| 204 | "C4267" # conversion from 'size_t' to 'int', possible loss of data |
| 205 | "C4702" # unreachable code; MSVC's warning is too aggressive. See |
| 206 | # https://crbug.com/385161043 |
| 207 | "C4706" # assignment within conditional expression |
| 208 | ) |
| 209 | string(REPLACE "C" " -wd" MSVC_DISABLED_WARNINGS_STR |
| 210 | ${MSVC_DISABLED_WARNINGS_LIST}) |
| 211 | set(CMAKE_C_FLAGS "-utf-8 -W4 -WX ${MSVC_DISABLED_WARNINGS_STR}") |
| 212 | # Without /Zc:__cplusplus, MSVC does not define the right value for |
| 213 | # __cplusplus. See https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ |
| 214 | # If this becomes too problematic for downstream code, we can look at |
| 215 | # _MSVC_LANG. |
| 216 | set(CMAKE_CXX_FLAGS "-utf-8 -W4 -WX ${MSVC_DISABLED_WARNINGS_STR} -Zc:__cplusplus") |
| 217 | endif() |
| 218 |
| 219 | if(WIN32) |
| 220 | add_definitions(-D_HAS_EXCEPTIONS=0) |
| 221 | add_definitions(-DWIN32_LEAN_AND_MEAN) |
| 222 | add_definitions(-DNOMINMAX) |
| 223 | # Allow use of fopen. |
| 224 | add_definitions(-D_CRT_SECURE_NO_WARNINGS) |
| 225 | endif() |
| 226 |
| 227 | # pthread_rwlock_t on Linux requires a feature flag. We limit this to Linux |
| 228 | # because, on Apple platforms, it instead disables APIs we use. See compat(5) |
| 229 | # and sys/cdefs.h. Reportedly, FreeBSD also breaks when this is set. See |
| 230 | # https://crbug.com/boringssl/471. |
| 231 | if(CMAKE_SYSTEM_NAME STREQUAL "Linux") |
| 232 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_XOPEN_SOURCE=700") |
| 233 | endif() |
| 234 |
| 235 | if(FUZZ) |
| 236 | if(NOT CLANG) |
| 237 | message(FATAL_ERROR "You need to build with Clang for fuzzing to work") |
| 238 | endif() |
| 239 |
| 240 | if(CMAKE_C_COMPILER_VERSION VERSION_LESS "6.0.0") |
| 241 | message(FATAL_ERROR "You need Clang ≥ 6.0.0") |
| 242 | endif() |
| 243 |
| 244 | add_definitions(-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION) |
| 245 | set(RUNNER_ARGS "-deterministic" "-fuzzer" "-shim-config" "fuzzer_mode.json") |
| 246 |
| 247 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address,fuzzer-no-link -fsanitize-coverage=edge,indirect-calls") |
| 248 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address,fuzzer-no-link -fsanitize-coverage=edge,indirect-calls") |
| 249 | endif() |
| 250 |
| 251 | add_definitions(-DBORINGSSL_IMPLEMENTATION) |
| 252 |
| 253 | if(BUILD_SHARED_LIBS) |
| 254 | add_definitions(-DBORINGSSL_SHARED_LIBRARY) |
| 255 | # Enable position-independent code globally. This is needed because |
| 256 | # some library targets are OBJECT libraries. |
| 257 | set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) |
| 258 | endif() |
| 259 |
| 260 | if(MSAN) |
| 261 | if(NOT CLANG) |
| 262 | message(FATAL_ERROR "Cannot enable MSAN unless using Clang") |
| 263 | endif() |
| 264 |
| 265 | if(ASAN) |
| 266 | message(FATAL_ERROR "ASAN and MSAN are mutually exclusive") |
| 267 | endif() |
| 268 |
| 269 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer") |
| 270 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer") |
| 271 | set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer") |
| 272 | endif() |
| 273 |
| 274 | if(ASAN) |
| 275 | if(NOT CLANG) |
| 276 | message(FATAL_ERROR "Cannot enable ASAN unless using Clang") |
| 277 | endif() |
| 278 |
| 279 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fsanitize-address-use-after-scope -fno-omit-frame-pointer") |
| 280 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize-address-use-after-scope -fno-omit-frame-pointer") |
| 281 | endif() |
| 282 |
| 283 | if(CFI) |
| 284 | if(NOT CLANG) |
| 285 | message(FATAL_ERROR "Cannot enable CFI unless using Clang") |
| 286 | endif() |
| 287 |
| 288 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=cfi -fno-sanitize-trap=cfi -flto=thin") |
| 289 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=cfi -fno-sanitize-trap=cfi -flto=thin") |
| 290 | # We use Chromium's copy of clang, which requires -fuse-ld=lld if building |
| 291 | # with -flto. That, in turn, can't handle -ggdb. |
| 292 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=lld") |
| 293 | string(REPLACE "-ggdb" "-g" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") |
| 294 | string(REPLACE "-ggdb" "-g" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") |
| 295 | # -flto causes object files to contain LLVM bitcode. Mixing those with |
| 296 | # assembly output in the same static library breaks the linker. |
| 297 | set(OPENSSL_NO_ASM "1") |
| 298 | endif() |
| 299 |
| 300 | if(TSAN) |
| 301 | if(NOT CLANG) |
| 302 | message(FATAL_ERROR "Cannot enable TSAN unless using Clang") |
| 303 | endif() |
| 304 |
| 305 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread") |
| 306 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread") |
| 307 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=thread") |
| 308 | endif() |
| 309 |
| 310 | if(UBSAN) |
| 311 | if(NOT CLANG) |
| 312 | message(FATAL_ERROR "Cannot enable UBSAN unless using Clang") |
| 313 | endif() |
| 314 |
| 315 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined") |
| 316 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined") |
| 317 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined") |
| 318 |
| 319 | if(NOT UBSAN_RECOVER) |
| 320 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-sanitize-recover=undefined") |
| 321 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-sanitize-recover=undefined") |
| 322 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-sanitize-recover=undefined") |
| 323 | endif() |
| 324 | endif() |
| 325 |
| 326 | if(GCOV) |
| 327 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage") |
| 328 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage") |
| 329 | endif() |
| 330 |
| 331 | if(FIPS) |
| 332 | require_go() |
| 333 | add_definitions(-DBORINGSSL_FIPS) |
| 334 | if(FIPS_BREAK_TEST) |
| 335 | add_definitions("-DBORINGSSL_FIPS_BREAK_${FIPS_BREAK_TEST}=1") |
| 336 | endif() |
| 337 | # The FIPS integrity check does not work for ASan and MSan builds. |
| 338 | if(NOT ASAN AND NOT MSAN) |
| 339 | if(BUILD_SHARED_LIBS) |
| 340 | set(FIPS_SHARED "1") |
| 341 | else() |
| 342 | set(FIPS_DELOCATE "1") |
| 343 | endif() |
| 344 | endif() |
| 345 | if(FIPS_SHARED) |
| 346 | # The Android CMake files set -ffunction-sections and -fdata-sections, |
| 347 | # which is incompatible with FIPS_SHARED. |
| 348 | set(CMAKE_C_FLAGS |
| 349 | "${CMAKE_C_FLAGS} -fno-function-sections -fno-data-sections") |
| 350 | set(CMAKE_CXX_FLAGS |
| 351 | "${CMAKE_CXX_FLAGS} -fno-function-sections -fno-data-sections") |
| 352 | endif() |
| 353 | endif() |
| 354 |
| 355 | if(OPENSSL_SMALL) |
| 356 | add_definitions(-DOPENSSL_SMALL) |
| 357 | endif() |
| 358 |
| 359 | if(CONSTANT_TIME_VALIDATION) |
| 360 | add_definitions(-DBORINGSSL_CONSTANT_TIME_VALIDATION) |
| 361 | endif() |
| 362 |
| 363 | if(MALLOC_FAILURE_TESTING) |
| 364 | add_definitions(-DBORINGSSL_MALLOC_FAILURE_TESTING) |
| 365 | endif() |
| 366 |
| 367 | if(OPENSSL_NO_ASM) |
| 368 | add_definitions(-DOPENSSL_NO_ASM) |
| 369 | endif() |
| 370 |
| 371 | if(FIPS_DELOCATE OR NOT OPENSSL_NO_ASM) |
| 372 | # On x86 and x86_64 Windows, we use the NASM output. |
| 373 | if(WIN32 AND CMAKE_SYSTEM_PROCESSOR MATCHES "AMD64|x86_64|amd64|x86|i[3-6]86") |
| 374 | enable_language(ASM_NASM) |
| 375 | set(OPENSSL_NASM TRUE) |
| 376 | set(CMAKE_ASM_NASM_FLAGS "${CMAKE_ASM_NASM_FLAGS} -gcv8") |
| 377 | else() |
| 378 | enable_language(ASM) |
| 379 | if (NOT OPENSSL_NO_ASM) |
| 380 | set(OPENSSL_ASM TRUE) |
| 381 | endif() |
| 382 | # Work around https://gitlab.kitware.com/cmake/cmake/-/issues/20771 in older |
| 383 | # CMake versions. |
| 384 | if(APPLE AND CMAKE_VERSION VERSION_LESS 3.19) |
| 385 | if(CMAKE_OSX_SYSROOT) |
| 386 | set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -isysroot \"${CMAKE_OSX_SYSROOT}\"") |
| 387 | endif() |
| 388 | foreach(arch ${CMAKE_OSX_ARCHITECTURES}) |
| 389 | set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -arch ${arch}") |
| 390 | endforeach() |
| 391 | endif() |
| 392 | if(NOT WIN32) |
| 393 | set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -Wa,--noexecstack") |
| 394 | endif() |
| 395 | # Clang's integerated assembler does not support debug symbols. |
| 396 | if(NOT CMAKE_ASM_COMPILER_ID MATCHES "Clang") |
| 397 | set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -Wa,-g") |
| 398 | endif() |
| 399 | endif() |
| 400 | endif() |
| 401 |
| 402 | if(OPENSSL_NO_SSE2_FOR_TESTING) |
| 403 | add_definitions(-DOPENSSL_NO_SSE2_FOR_TESTING) |
| 404 | endif() |
| 405 |
| 406 | if(USE_CUSTOM_LIBCXX) |
| 407 | if(NOT CLANG) |
| 408 | message(FATAL_ERROR "USE_CUSTOM_LIBCXX only supported with Clang") |
| 409 | endif() |
| 410 |
| 411 | # CMake does not allow installing a library without installing dependencies. |
| 412 | # If we installed libcrypto, we'd have to install our custom libc++, which |
| 413 | # does not make sense. As this is a test-only configuration, disable |
| 414 | # installing. |
| 415 | set(INSTALL_ENABLED 0) |
| 416 |
| 417 | # CMAKE_CXX_FLAGS ends up in the linker flags as well, so use |
| 418 | # add_compile_options. There does not appear to be a way to set |
| 419 | # language-specific compile-only flags. |
| 420 | add_compile_options("-nostdinc++") |
| 421 | set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -nostdlib++") |
| 422 | include_directories( |
| 423 | SYSTEM |
| 424 | util/bot/libcxx-config |
| 425 | util/bot/libcxx/include |
| 426 | util/bot/libcxxabi/include |
| 427 | ) |
| 428 |
| 429 | # This is patterned after buildtools/third_party/libc++/BUILD.gn and |
| 430 | # buildtools/third_party/libc++abi/BUILD.gn in Chromium. |
| 431 |
| 432 | file(GLOB LIBCXX_SOURCES "util/bot/libcxx/src/*.cpp") |
| 433 | file(GLOB LIBCXXABI_SOURCES "util/bot/libcxxabi/src/*.cpp") |
| 434 |
| 435 | # This file is meant for exception-less builds. |
| 436 | list(REMOVE_ITEM LIBCXXABI_SOURCES "trunk/src/cxa_noexception.cpp") |
| 437 | # libc++ also defines new and delete. |
| 438 | list(REMOVE_ITEM LIBCXXABI_SOURCES "trunk/src/stdlib_new_delete.cpp") |
| 439 | if(TSAN) |
| 440 | # ThreadSanitizer tries to intercept these symbols. Skip them to avoid |
| 441 | # symbol conflicts. |
| 442 | list(REMOVE_ITEM LIBCXXABI_SOURCES "trunk/src/cxa_guard.cpp") |
| 443 | endif() |
| 444 |
| 445 | add_library(libcxxabi ${LIBCXXABI_SOURCES}) |
| 446 | target_compile_definitions( |
| 447 | libcxxabi PRIVATE |
| 448 | -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS |
| 449 | ) |
| 450 |
| 451 | add_library(libcxx ${LIBCXX_SOURCES}) |
| 452 | if(ASAN OR MSAN OR TSAN) |
| 453 | # Sanitizers try to intercept new and delete. |
| 454 | target_compile_definitions( |
| 455 | libcxx PRIVATE |
| 456 | -D_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS |
| 457 | ) |
| 458 | endif() |
| 459 | target_compile_definitions( |
| 460 | libcxx PRIVATE |
| 461 | -D_LIBCPP_BUILDING_LIBRARY |
| 462 | -DLIBCXX_BUILDING_LIBCXXABI |
| 463 | -DLIBC_NAMESPACE=bssl_llvm_libc |
| 464 | ) |
| 465 | # LLVM libc++ depends on some shared headers from LLVM libc. |
| 466 | target_include_directories(libcxx PRIVATE util/bot/llvm-libc) |
| 467 | set_target_properties( |
| 468 | libcxx libcxxabi PROPERTIES |
| 469 | COMPILE_FLAGS "-Wno-missing-prototypes -Wno-implicit-fallthrough" |
| 470 | # libc++ and libc++abi must be built in C++23 mode. |
| 471 | CXX_STANDARD 23 |
| 472 | CXX_STANDARD_REQUIRED TRUE |
| 473 | ) |
| 474 | # libc++abi depends on libc++ internal headers. |
| 475 | set_property(TARGET libcxx libcxxabi APPEND PROPERTY INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/util/bot/libcxx/src") |
| 476 | target_link_libraries(libcxx libcxxabi) |
| 477 | endif() |
| 478 |
| 479 | # Add minimal googletest targets. The provided one has many side-effects, and |
| 480 | # googletest has a very straightforward build. |
| 481 | add_library( |
| 482 | boringssl_gtest |
| 483 | third_party/googletest/googlemock/src/gmock-all.cc |
| 484 | third_party/googletest/googletest/src/gtest-all.cc |
| 485 | ) |
| 486 | if(USE_CUSTOM_LIBCXX) |
| 487 | target_link_libraries(boringssl_gtest libcxx) |
| 488 | endif() |
| 489 | target_include_directories( |
| 490 | boringssl_gtest |
| 491 | PUBLIC |
| 492 | third_party/googletest/googlemock/include |
| 493 | third_party/googletest/googletest/include |
| 494 | PRIVATE |
| 495 | third_party/googletest/googlemock |
| 496 | third_party/googletest/googletest |
| 497 | ) |
| 498 |
| 499 | # Declare a dummy target to build all unit tests. Test targets should inject |
| 500 | # themselves as dependencies next to the target definition. |
| 501 | add_custom_target(all_tests) |
| 502 |
| 503 | add_subdirectory(ssl/test) |
| 504 | add_subdirectory(util/fipstools) |
| 505 | add_subdirectory(util/fipstools/acvp/modulewrapper) |
| 506 |
| 507 | if(OPENSSL_ASM) |
| 508 | set(CRYPTO_SOURCES_ASM_USED ${CRYPTO_SOURCES_ASM}) |
| 509 | set(BCM_SOURCES_ASM_USED ${BCM_SOURCES_ASM}) |
| 510 | set(TEST_SUPPORT_SOURCES_ASM_USED ${TEST_SUPPORT_SOURCES_ASM}) |
| 511 | elseif(OPENSSL_NASM) |
| 512 | set(CRYPTO_SOURCES_ASM_USED ${CRYPTO_SOURCES_NASM}) |
| 513 | set(BCM_SOURCES_ASM_USED ${BCM_SOURCES_NASM}) |
| 514 | set(TEST_SUPPORT_SOURCES_ASM_USED ${TEST_SUPPORT_SOURCES_NASM}) |
| 515 | endif() |
| 516 |
| 517 | if(FIPS_DELOCATE AND FIPS_SHARED) |
| 518 | message(FATAL_ERROR "Can't set both delocate and shared mode for FIPS build") |
| 519 | endif() |
| 520 |
| 521 | # OSS-Fuzz relies on BORINGSSL_ALLOW_CXX_RUNTIME because -fno-rtti and |
| 522 | # -fsanitize=vptr are incompatible. |
| 523 | set(NO_CXX_RUNTIME_FLAGS) |
| 524 | if(NOT MSVC AND NOT BORINGSSL_ALLOW_CXX_RUNTIME) |
| 525 | # Without -fno-exceptions, use of std::unique_ptr emits a call to |
| 526 | # std::terminate. |
| 527 | set(NO_CXX_RUNTIME_FLAGS -fno-exceptions -fno-rtti) |
| 528 | endif() |
| 529 |
| 530 | if(FIPS_DELOCATE) |
| 531 | add_library(bcm_c_generated_asm STATIC ${BCM_SOURCES}) |
| 532 | # The C++ code in libcrypto shouldn't depend on libstdc++. |
| 533 | target_compile_options(bcm_c_generated_asm PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${NO_CXX_RUNTIME_FLAGS}> "-S") |
| 534 | add_dependencies(bcm_c_generated_asm boringssl_prefix_symbols) |
| 535 | target_include_directories(bcm_c_generated_asm PRIVATE ${PROJECT_SOURCE_DIR}/include) |
| 536 | set_target_properties(bcm_c_generated_asm PROPERTIES POSITION_INDEPENDENT_CODE ON) |
| 537 | if(CLANG) |
| 538 | # Clang warns when passing both -c (from CMake) and -S. |
| 539 | target_compile_options(bcm_c_generated_asm PRIVATE "-Wno-unused-command-line-argument") |
| 540 | endif() |
| 541 |
| 542 | set(TARGET_FLAG "") |
| 543 | if(CMAKE_ASM_COMPILER_TARGET) |
| 544 | set(TARGET_FLAG "--target=${CMAKE_ASM_COMPILER_TARGET}") |
| 545 | endif() |
| 546 |
| 547 | go_executable(delocate boringssl.googlesource.com/boringssl.git/util/fipstools/delocate) |
| 548 | add_custom_command( |
| 549 | OUTPUT bcm-delocated.S |
| 550 | COMMAND ${CMAKE_CURRENT_BINARY_DIR}/delocate |
| 551 | -a $<TARGET_FILE:bcm_c_generated_asm> |
| 552 | -o ${CMAKE_CURRENT_BINARY_DIR}/bcm-delocated.S |
| 553 | -cc ${CMAKE_ASM_COMPILER} |
| 554 | -cc-flags "${TARGET_FLAG} ${CMAKE_ASM_FLAGS}" |
| 555 | ${BCM_SOURCES_ASM_USED} |
| 556 | ${CRYPTO_HEADERS} |
| 557 | DEPENDS bcm_c_generated_asm |
| 558 | delocate |
| 559 | ${BCM_SOURCES_ASM_USED} |
| 560 | ${CRYPTO_HEADERS} |
| 561 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} |
| 562 | ) |
| 563 |
| 564 | add_library(bcm_hashunset STATIC bcm-delocated.S) |
| 565 | set_target_properties(bcm_hashunset PROPERTIES POSITION_INDEPENDENT_CODE ON) |
| 566 | set_target_properties(bcm_hashunset PROPERTIES LINKER_LANGUAGE C) |
| 567 |
| 568 | go_executable(inject_hash |
| 569 | boringssl.googlesource.com/boringssl.git/util/fipstools/inject_hash) |
| 570 | add_custom_command( |
| 571 | OUTPUT bcm.o |
| 572 | COMMAND ./inject_hash -o bcm.o -in-archive $<TARGET_FILE:bcm_hashunset> |
| 573 | DEPENDS bcm_hashunset inject_hash |
| 574 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} |
| 575 | ) |
| 576 | set(CRYPTO_FIPS_OBJECTS bcm.o) |
| 577 | elseif(FIPS_SHARED) |
| 578 | if(NOT BUILD_SHARED_LIBS) |
| 579 | message(FATAL_ERROR "FIPS_SHARED set but not BUILD_SHARED_LIBS") |
| 580 | endif() |
| 581 |
| 582 | add_library(bcm_library STATIC ${BCM_SOURCES} ${BCM_SOURCES_ASM_USED}) |
| 583 | # The C++ code in libcrypto shouldn't depend on libstdc++. |
| 584 | target_compile_options(bcm_library PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${NO_CXX_RUNTIME_FLAGS}>) |
| 585 | add_dependencies(bcm_library boringssl_prefix_symbols) |
| 586 | target_include_directories(bcm_library PRIVATE ${PROJECT_SOURCE_DIR}/include) |
| 587 |
| 588 | add_custom_command( |
| 589 | OUTPUT bcm.o |
| 590 | COMMAND ${CMAKE_LINKER} -r -T ${CMAKE_CURRENT_SOURCE_DIR}/crypto/fipsmodule/fips_shared.lds -o bcm.o --whole-archive $<TARGET_FILE:bcm_library> |
| 591 | DEPENDS bcm_library crypto/fipsmodule/fips_shared.lds |
| 592 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} |
| 593 | ) |
| 594 | set(CRYPTO_FIPS_OBJECTS bcm.o) |
| 595 | else() |
| 596 | add_library(fipsmodule OBJECT ${BCM_SOURCES} ${BCM_SOURCES_ASM_USED}) |
| 597 | # The C++ code in libcrypto shouldn't depend on libstdc++. |
| 598 | target_compile_options(fipsmodule PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${NO_CXX_RUNTIME_FLAGS}>) |
| 599 | add_dependencies(fipsmodule boringssl_prefix_symbols) |
| 600 | target_include_directories(fipsmodule PRIVATE ${PROJECT_SOURCE_DIR}/include) |
| 601 | set(CRYPTO_FIPS_OBJECTS $<TARGET_OBJECTS:fipsmodule>) |
| 602 | endif() |
| 603 |
| 604 | add_library(crypto ${CRYPTO_SOURCES} ${CRYPTO_FIPS_OBJECTS} ${CRYPTO_SOURCES_ASM_USED}) |
| 605 | # The C++ code in libcrypto shouldn't depend on libstdc++. |
| 606 | target_compile_options(crypto PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${NO_CXX_RUNTIME_FLAGS}>) |
| 607 | target_include_directories(crypto PUBLIC |
| 608 | $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> |
| 609 | $<INSTALL_INTERFACE:include> |
| 610 | ) |
| 611 | set_property(TARGET crypto PROPERTY EXPORT_NAME Crypto) |
| 612 |
| 613 | if(FIPS_SHARED) |
| 614 | # Rewrite libcrypto.so to inject the correct module hash value. This assumes |
| 615 | # UNIX-style library naming, but we only support FIPS mode on Linux anyway. |
| 616 | add_custom_command( |
| 617 | TARGET crypto POST_BUILD |
| 618 | COMMAND ${GO_EXECUTABLE} run |
| 619 | ${CMAKE_CURRENT_SOURCE_DIR}/util/fipstools/inject_hash/inject_hash.go |
| 620 | -o libcrypto.so -in-object libcrypto.so |
| 621 | # The DEPENDS argument to a POST_BUILD rule appears to be ignored. Thus |
| 622 | # go_executable isn't used (as it doesn't get built), but we list this |
| 623 | # dependency anyway in case it starts working in some CMake version. |
| 624 | DEPENDS util/fipstools/inject_hash/inject_hash.go |
| 625 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} |
| 626 | ) |
| 627 | endif() |
| 628 |
| 629 | add_dependencies(crypto boringssl_prefix_symbols) |
| 630 | if(WIN32) |
| 631 | target_link_libraries(crypto ws2_32) |
| 632 | endif() |
| 633 |
| 634 | # CMAKE_SYSTEM_NAME is "Generic" for embedded OSes: |
| 635 | # https://cmake.org/cmake/help/book/mastering-cmake/chapter/Cross%20Compiling%20With%20CMake.html#toolchain-files |
| 636 | # |
| 637 | # For now we assume embedded OSes do not have threads. Additionally, the Threads |
| 638 | # package does not work with Android, but Android does not require any extra |
| 639 | # parameters to link pthreads. |
| 640 | if(NOT CMAKE_SYSTEM_NAME MATCHES "^(Generic|Android)$") |
| 641 | find_package(Threads REQUIRED) |
| 642 | target_link_libraries(crypto Threads::Threads) |
| 643 | endif() |
| 644 |
| 645 | # Every target depends on crypto, so we add libcxx as a dependency here to |
| 646 | # simplify injecting it everywhere. |
| 647 | if(USE_CUSTOM_LIBCXX) |
| 648 | target_link_libraries(crypto libcxx) |
| 649 | endif() |
| 650 |
| 651 | add_library(ssl ${SSL_SOURCES}) |
| 652 | # Although libssl also provides headers that require an include directory, the |
| 653 | # flag is already specified by libcrypto, so we omit target_include_directories |
| 654 | # here. |
| 655 | set_property(TARGET ssl PROPERTY EXPORT_NAME SSL) |
| 656 | target_link_libraries(ssl crypto) |
| 657 |
| 658 | add_library(decrepit ${DECREPIT_SOURCES}) |
| 659 | target_link_libraries(decrepit ssl crypto) |
| 660 |
| 661 | add_library(test_support_lib STATIC |
| 662 | ${TEST_SUPPORT_SOURCES} ${TEST_SUPPORT_SOURCES_ASM_USED}) |
| 663 | if(LIBUNWIND_FOUND) |
| 664 | target_compile_options(test_support_lib PRIVATE ${LIBUNWIND_CFLAGS_OTHER}) |
| 665 | target_include_directories(test_support_lib PRIVATE ${LIBUNWIND_INCLUDE_DIRS}) |
| 666 | target_link_libraries(test_support_lib ${LIBUNWIND_LDFLAGS}) |
| 667 | endif() |
| 668 | if(WIN32) |
| 669 | target_link_libraries(test_support_lib dbghelp) |
| 670 | endif() |
| 671 | target_link_libraries(test_support_lib boringssl_gtest crypto) |
| 672 |
| 673 | # urandom_test is a separate binary because it needs to be able to observe the |
| 674 | # PRNG initialisation, which means that it can't have other tests running before |
| 675 | # it does. |
| 676 | add_executable(urandom_test ${URANDOM_TEST_SOURCES}) |
| 677 | target_link_libraries(urandom_test test_support_lib boringssl_gtest crypto) |
| 678 | add_dependencies(all_tests urandom_test) |
| 679 |
| 680 | add_executable(crypto_test ${CRYPTO_TEST_SOURCES}) |
| 681 | target_link_libraries(crypto_test test_support_lib boringssl_gtest crypto) |
| 682 | add_dependencies(all_tests crypto_test) |
| 683 |
| 684 | add_executable(ssl_test ${SSL_TEST_SOURCES}) |
| 685 | target_link_libraries(ssl_test test_support_lib boringssl_gtest ssl crypto) |
| 686 | add_dependencies(all_tests ssl_test) |
| 687 | add_executable(decrepit_test ${DECREPIT_TEST_SOURCES}) |
| 688 | target_link_libraries(decrepit_test test_support_lib boringssl_gtest |
| 689 | decrepit ssl crypto) |
| 690 | add_dependencies(all_tests decrepit_test) |
| 691 |
| 692 | if(APPLE) |
| 693 | set(PKI_CXX_FLAGS "-fno-aligned-new") |
| 694 | endif() |
| 695 |
| 696 | add_library(pki ${PKI_SOURCES}) |
| 697 | target_link_libraries(pki crypto) |
| 698 |
| 699 | add_executable(pki_test ${PKI_TEST_SOURCES}) |
| 700 | target_link_libraries(pki_test test_support_lib boringssl_gtest pki crypto) |
| 701 | add_dependencies(all_tests pki_test) |
| 702 |
| 703 | set_target_properties( |
| 704 | pki pki_test |
| 705 | PROPERTIES |
| 706 | COMPILE_FLAGS "${PKI_CXX_FLAGS}") |
| 707 |
| 708 | add_executable(bssl ${BSSL_SOURCES}) |
| 709 | target_link_libraries(bssl ssl crypto) |
| 710 |
| 711 | # Historically, targets were built in subdirectories. For compatibility with |
| 712 | # existing tools, we, for now, copy the targets into the subdirectories. This |
| 713 | # will be removed sometime in 2024. |
| 714 | copy_post_build(crypto crypto crypto_test urandom_test) |
| 715 | copy_post_build(ssl ssl ssl_test) |
| 716 | copy_post_build(decrepit decrepit decrepit_test) |
| 717 | copy_post_build(tool bssl) |
| 718 |
| 719 | if(FUZZ) |
| 720 | if(LIBFUZZER_FROM_DEPS) |
| 721 | file(GLOB LIBFUZZER_SOURCES "util/bot/libFuzzer/*.cpp") |
| 722 | add_library(Fuzzer STATIC ${LIBFUZZER_SOURCES}) |
| 723 | # libFuzzer does not pass our aggressive warnings. It also must be built |
| 724 | # without -fsanitize-coverage options or clang crashes. |
| 725 | set_target_properties( |
| 726 | Fuzzer PROPERTIES |
| 727 | COMPILE_FLAGS "-Wno-shadow -Wno-format-nonliteral -Wno-missing-prototypes -fsanitize-coverage=0" |
| 728 | ) |
| 729 | endif() |
| 730 |
| 731 | add_subdirectory(fuzz) |
| 732 | endif() |
| 733 |
| 734 | if(RUST_BINDINGS) |
| 735 | find_program(BINDGEN_EXECUTABLE bindgen) |
| 736 | if(NOT BINDGEN_EXECUTABLE) |
| 737 | message(FATAL_ERROR "Could not find bindgen but was asked to generate Rust bindings.") |
| 738 | else() |
| 739 | add_subdirectory(rust) |
| 740 | endif() |
| 741 | endif() |
| 742 |
| 743 | if(CMAKE_SYSTEM_NAME STREQUAL "Linux") |
| 744 | set(HANDSHAKER_ARGS "-handshaker-path" $<TARGET_FILE:handshaker>) |
| 745 | endif() |
| 746 |
| 747 | if(FIPS) |
| 748 | add_custom_target( |
| 749 | acvp_tests |
| 750 | COMMAND ${GO_EXECUTABLE} build -o ${CMAKE_CURRENT_BINARY_DIR}/acvptool |
| 751 | boringssl.googlesource.com/boringssl.git/util/fipstools/acvp/acvptool |
| 752 | COMMAND ${GO_EXECUTABLE} build -o ${CMAKE_CURRENT_BINARY_DIR}/testmodulewrapper |
| 753 | boringssl.googlesource.com/boringssl.git/util/fipstools/acvp/acvptool/testmodulewrapper |
| 754 | COMMAND cd util/fipstools/acvp/acvptool/test && |
| 755 | ${GO_EXECUTABLE} run check_expected.go |
| 756 | -tool ${CMAKE_CURRENT_BINARY_DIR}/acvptool |
| 757 | -module-wrappers modulewrapper:$<TARGET_FILE:modulewrapper>,testmodulewrapper:${CMAKE_CURRENT_BINARY_DIR}/testmodulewrapper |
| 758 | -tests tests.json |
| 759 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} |
| 760 | DEPENDS modulewrapper |
| 761 | USES_TERMINAL) |
| 762 |
| 763 | add_custom_target( |
| 764 | fips_specific_tests_if_any |
| 765 | DEPENDS acvp_tests |
| 766 | ) |
| 767 | else() |
| 768 | add_custom_target(fips_specific_tests_if_any) |
| 769 | endif() |
| 770 |
| 771 | file(STRINGS util/go_tests.txt GO_TESTS) |
| 772 | set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS |
| 773 | util/go_tests.txt) |
| 774 |
| 775 | if(GO_EXECUTABLE) |
| 776 | add_custom_target( |
| 777 | run_tests |
| 778 | COMMAND ${CMAKE_COMMAND} -E echo "Running Go tests" |
| 779 | COMMAND ${GO_EXECUTABLE} test ${GO_TESTS} |
| 780 | COMMAND ${CMAKE_COMMAND} -E echo |
| 781 | COMMAND ${CMAKE_COMMAND} -E echo "Running unit tests" |
| 782 | COMMAND ${GO_EXECUTABLE} run util/all_tests.go -build-dir |
| 783 | ${CMAKE_CURRENT_BINARY_DIR} |
| 784 | COMMAND ${CMAKE_COMMAND} -E echo |
| 785 | COMMAND ${CMAKE_COMMAND} -E echo "Running SSL tests" |
| 786 | COMMAND cd ssl/test/runner && |
| 787 | ${GO_EXECUTABLE} test -shim-path $<TARGET_FILE:bssl_shim> |
| 788 | ${HANDSHAKER_ARGS} ${RUNNER_ARGS} |
| 789 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} |
| 790 | DEPENDS all_tests bssl_shim handshaker fips_specific_tests_if_any |
| 791 | USES_TERMINAL) |
| 792 | else() |
| 793 | add_custom_target( |
| 794 | run_tests |
| 795 | COMMAND ${CMAKE_COMMAND} -E echo "Running tests requires Go" |
| 796 | COMMAND ${CMAKE_COMMAND} -E false) |
| 797 | endif() |
| 798 |
| 799 | if(INSTALL_ENABLED) |
| 800 | install(TARGETS crypto ssl EXPORT OpenSSLTargets) |
| 801 | install(TARGETS bssl) |
| 802 | install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) |
| 803 | install(EXPORT OpenSSLTargets |
| 804 | FILE OpenSSLTargets.cmake |
| 805 | NAMESPACE OpenSSL:: |
| 806 | DESTINATION lib/cmake/OpenSSL) |
| 807 | install(FILES cmake/OpenSSLConfig.cmake DESTINATION lib/cmake/OpenSSL) |
| 808 | endif() |
| 809 |