You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

477 lines
18 KiB

  1. cmake_minimum_required (VERSION 2.8.11)
  2. # Report AppleClang separately from Clang. Their version numbers are different.
  3. # https://cmake.org/cmake/help/v3.0/policy/CMP0025.html
  4. if(POLICY CMP0025)
  5. cmake_policy(SET CMP0025 NEW)
  6. endif()
  7. # Defer enabling C and CXX languages.
  8. project (BoringSSL NONE)
  9. if(WIN32)
  10. # On Windows, prefer cl over gcc if both are available. By default most of
  11. # the CMake generators prefer gcc, even on Windows.
  12. set(CMAKE_GENERATOR_CC cl)
  13. endif()
  14. include(sources.cmake)
  15. enable_language(C)
  16. enable_language(CXX)
  17. if(ANDROID)
  18. # Android-NDK CMake files reconfigure the path and so Go and Perl won't be
  19. # found. However, ninja will still find them in $PATH if we just name them.
  20. if(NOT PERL_EXECUTABLE)
  21. set(PERL_EXECUTABLE "perl")
  22. endif()
  23. if(NOT GO_EXECUTABLE)
  24. set(GO_EXECUTABLE "go")
  25. endif()
  26. else()
  27. find_package(Perl REQUIRED)
  28. find_program(GO_EXECUTABLE go)
  29. endif()
  30. if (NOT GO_EXECUTABLE)
  31. message(FATAL_ERROR "Could not find Go")
  32. endif()
  33. if (USE_CUSTOM_LIBCXX)
  34. set(BORINGSSL_ALLOW_CXX_RUNTIME 1)
  35. endif()
  36. if (BORINGSSL_ALLOW_CXX_RUNTIME)
  37. add_definitions(-DBORINGSSL_ALLOW_CXX_RUNTIME)
  38. endif()
  39. if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  40. set(CLANG 1)
  41. endif()
  42. if(CMAKE_COMPILER_IS_GNUCXX OR CLANG)
  43. # Note clang-cl is odd and sets both CLANG and MSVC. We base our configuration
  44. # primarily on our normal Clang one.
  45. set(C_CXX_FLAGS "-Werror -Wformat=2 -Wsign-compare -Wmissing-field-initializers -Wwrite-strings")
  46. if(MSVC)
  47. # clang-cl sets different default warnings than clang. It also treats -Wall
  48. # as -Weverything, to match MSVC. Instead -W3 is the alias for -Wall.
  49. # See http://llvm.org/viewvc/llvm-project?view=revision&revision=319116
  50. set(C_CXX_FLAGS "${C_CXX_FLAGS} -W3 -Wno-unused-parameter -fmsc-version=1900")
  51. # googletest suppresses warning C4996 via a pragma, but clang-cl does not
  52. # honor it. Suppress it here to compensate. See https://crbug.com/772117.
  53. set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wno-deprecated-declarations")
  54. else()
  55. set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wall -ggdb -fvisibility=hidden -fno-common")
  56. endif()
  57. if(CLANG)
  58. set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wnewline-eof -fcolor-diagnostics")
  59. else()
  60. # GCC (at least 4.8.4) has a bug where it'll find unreachable free() calls
  61. # and declare that the code is trying to free a stack pointer.
  62. set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wno-free-nonheap-object")
  63. endif()
  64. if(CLANG OR NOT "7.0.0" VERSION_GREATER CMAKE_C_COMPILER_VERSION)
  65. set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wimplicit-fallthrough")
  66. endif()
  67. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${C_CXX_FLAGS} -Wmissing-prototypes -Wold-style-definition -Wstrict-prototypes")
  68. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${C_CXX_FLAGS} -Wmissing-declarations")
  69. if(NOT MSVC)
  70. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
  71. if(APPLE)
  72. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
  73. endif()
  74. if(NOT BORINGSSL_ALLOW_CXX_RUNTIME)
  75. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -fno-rtti")
  76. endif()
  77. endif()
  78. # In GCC, -Wmissing-declarations is the C++ spelling of -Wmissing-prototypes
  79. # and using the wrong one is an error. In Clang, -Wmissing-prototypes is the
  80. # spelling for both and -Wmissing-declarations is some other warning.
  81. #
  82. # https://gcc.gnu.org/onlinedocs/gcc-7.1.0/gcc/Warning-Options.html#Warning-Options
  83. # https://clang.llvm.org/docs/DiagnosticsReference.html#wmissing-prototypes
  84. # https://clang.llvm.org/docs/DiagnosticsReference.html#wmissing-declarations
  85. if(CLANG)
  86. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wmissing-prototypes")
  87. endif()
  88. if(CMAKE_COMPILER_IS_GNUCXX AND "4.8" VERSION_GREATER CMAKE_C_COMPILER_VERSION)
  89. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-array-bounds")
  90. endif()
  91. elseif(MSVC)
  92. set(MSVC_DISABLED_WARNINGS_LIST
  93. "C4061" # enumerator 'identifier' in switch of enum 'enumeration' is not
  94. # explicitly handled by a case label
  95. # Disable this because it flags even when there is a default.
  96. "C4100" # 'exarg' : unreferenced formal parameter
  97. "C4127" # conditional expression is constant
  98. "C4200" # nonstandard extension used : zero-sized array in
  99. # struct/union.
  100. "C4204" # nonstandard extension used: non-constant aggregate initializer
  101. "C4221" # nonstandard extension used : 'identifier' : cannot be
  102. # initialized using address of automatic variable
  103. "C4242" # 'function' : conversion from 'int' to 'uint8_t',
  104. # possible loss of data
  105. "C4244" # 'function' : conversion from 'int' to 'uint8_t',
  106. # possible loss of data
  107. "C4267" # conversion from 'size_t' to 'int', possible loss of data
  108. "C4371" # layout of class may have changed from a previous version of the
  109. # compiler due to better packing of member '...'
  110. "C4388" # signed/unsigned mismatch
  111. "C4296" # '>=' : expression is always true
  112. "C4350" # behavior change: 'std::_Wrap_alloc...'
  113. "C4365" # '=' : conversion from 'size_t' to 'int',
  114. # signed/unsigned mismatch
  115. "C4389" # '!=' : signed/unsigned mismatch
  116. "C4464" # relative include path contains '..'
  117. "C4510" # 'argument' : default constructor could not be generated
  118. "C4512" # 'argument' : assignment operator could not be generated
  119. "C4514" # 'function': unreferenced inline function has been removed
  120. "C4548" # expression before comma has no effect; expected expression with
  121. # side-effect" caused by FD_* macros.
  122. "C4610" # struct 'argument' can never be instantiated - user defined
  123. # constructor required.
  124. "C4623" # default constructor was implicitly defined as deleted
  125. "C4625" # copy constructor could not be generated because a base class
  126. # copy constructor is inaccessible or deleted
  127. "C4626" # assignment operator could not be generated because a base class
  128. # assignment operator is inaccessible or deleted
  129. "C4668" # 'symbol' is not defined as a preprocessor macro, replacing with
  130. # '0' for 'directives'
  131. # Disable this because GTest uses it everywhere.
  132. "C4706" # assignment within conditional expression
  133. "C4710" # 'function': function not inlined
  134. "C4711" # function 'function' selected for inline expansion
  135. "C4800" # 'int' : forcing value to bool 'true' or 'false'
  136. # (performance warning)
  137. "C4820" # 'bytes' bytes padding added after construct 'member_name'
  138. "C5026" # move constructor was implicitly defined as deleted
  139. "C5027" # move assignment operator was implicitly defined as deleted
  140. "C5045" # Compiler will insert Spectre mitigation for memory load if
  141. # /Qspectre switch specified
  142. )
  143. set(MSVC_LEVEL4_WARNINGS_LIST
  144. # See https://connect.microsoft.com/VisualStudio/feedback/details/1217660/warning-c4265-when-using-functional-header
  145. "C4265" # class has virtual functions, but destructor is not virtual
  146. )
  147. string(REPLACE "C" " -wd" MSVC_DISABLED_WARNINGS_STR
  148. ${MSVC_DISABLED_WARNINGS_LIST})
  149. string(REPLACE "C" " -w4" MSVC_LEVEL4_WARNINGS_STR
  150. ${MSVC_LEVEL4_WARNINGS_LIST})
  151. set(CMAKE_C_FLAGS "-utf-8 -Wall -WX ${MSVC_DISABLED_WARNINGS_STR} ${MSVC_LEVEL4_WARNINGS_STR}")
  152. set(CMAKE_CXX_FLAGS "-utf-8 -Wall -WX ${MSVC_DISABLED_WARNINGS_STR} ${MSVC_LEVEL4_WARNINGS_STR}")
  153. endif()
  154. if(WIN32)
  155. add_definitions(-D_HAS_EXCEPTIONS=0)
  156. add_definitions(-DWIN32_LEAN_AND_MEAN)
  157. add_definitions(-DNOMINMAX)
  158. # Allow use of fopen.
  159. add_definitions(-D_CRT_SECURE_NO_WARNINGS)
  160. # VS 2017 and higher supports STL-only warning suppressions. Manually add to
  161. # C++ only to work around a CMake quoting bug when using NASM with the Visual
  162. # Studio generator. This will be fixed in CMake 3.13.0. See
  163. # https://gitlab.kitware.com/cmake/cmake/merge_requests/2179
  164. add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-D_STL_EXTRA_DISABLED_WARNINGS=4774\ 4987>)
  165. endif()
  166. if((CMAKE_COMPILER_IS_GNUCXX AND CMAKE_C_COMPILER_VERSION VERSION_GREATER "4.7.99") OR
  167. CLANG)
  168. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wshadow")
  169. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow")
  170. endif()
  171. if(CMAKE_COMPILER_IS_GNUCXX)
  172. if ((CMAKE_C_COMPILER_VERSION VERSION_GREATER "4.8.99") OR CLANG)
  173. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11")
  174. else()
  175. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
  176. endif()
  177. endif()
  178. # pthread_rwlock_t requires a feature flag.
  179. if(NOT WIN32)
  180. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_XOPEN_SOURCE=700")
  181. endif()
  182. if(FUZZ)
  183. if(NOT CLANG)
  184. message(FATAL_ERROR "You need to build with Clang for fuzzing to work")
  185. endif()
  186. add_definitions(-DBORINGSSL_UNSAFE_DETERMINISTIC_MODE)
  187. set(RUNNER_ARGS "-deterministic")
  188. if(NOT NO_FUZZER_MODE)
  189. add_definitions(-DBORINGSSL_UNSAFE_FUZZER_MODE)
  190. set(RUNNER_ARGS ${RUNNER_ARGS} "-fuzzer" "-shim-config" "fuzzer_mode.json")
  191. endif()
  192. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fsanitize-coverage=edge,indirect-calls,trace-pc-guard")
  193. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize-coverage=edge,indirect-calls,trace-pc-guard")
  194. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
  195. link_directories(.)
  196. endif()
  197. add_definitions(-DBORINGSSL_IMPLEMENTATION)
  198. if (BUILD_SHARED_LIBS)
  199. add_definitions(-DBORINGSSL_SHARED_LIBRARY)
  200. # Enable position-independent code globally. This is needed because
  201. # some library targets are OBJECT libraries.
  202. set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
  203. endif()
  204. if (MSAN)
  205. if(NOT CLANG)
  206. message(FATAL_ERROR "Cannot enable MSAN unless using Clang")
  207. endif()
  208. if (ASAN)
  209. message(FATAL_ERROR "ASAN and MSAN are mutually exclusive")
  210. endif()
  211. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer")
  212. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer")
  213. set(OPENSSL_NO_ASM "1")
  214. endif()
  215. if (ASAN)
  216. if(NOT CLANG)
  217. message(FATAL_ERROR "Cannot enable ASAN unless using Clang")
  218. endif()
  219. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fsanitize-address-use-after-scope -fno-omit-frame-pointer")
  220. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize-address-use-after-scope -fno-omit-frame-pointer")
  221. set(OPENSSL_NO_ASM "1")
  222. endif()
  223. if(CFI)
  224. if(NOT CLANG)
  225. message(FATAL_ERROR "Cannot enable CFI unless using Clang")
  226. endif()
  227. # TODO(crbug.com/785442): Remove -fsanitize-cfi-icall-generalize-pointers.
  228. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=cfi -fno-sanitize-trap=cfi -fsanitize-cfi-icall-generalize-pointers -flto")
  229. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=cfi -fno-sanitize-trap=cfi -fsanitize-cfi-icall-generalize-pointers -flto")
  230. # We use Chromium's copy of clang, which requires -fuse-ld=lld if building
  231. # with -flto. That, in turn, can't handle -ggdb.
  232. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=lld")
  233. string(REPLACE "-ggdb" "-g" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
  234. string(REPLACE "-ggdb" "-g" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
  235. # -flto causes object files to contain LLVM bitcode. Mixing those with
  236. # assembly output in the same static library breaks the linker.
  237. set(OPENSSL_NO_ASM "1")
  238. endif()
  239. if(TSAN)
  240. if(NOT CLANG)
  241. message(FATAL_ERROR "Cannot enable TSAN unless using Clang")
  242. endif()
  243. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread")
  244. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread")
  245. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=thread")
  246. endif()
  247. if (GCOV)
  248. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
  249. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
  250. endif()
  251. if(FIPS)
  252. add_definitions(-DBORINGSSL_FIPS)
  253. if(FIPS_BREAK_TEST)
  254. add_definitions("-DBORINGSSL_FIPS_BREAK_${FIPS_BREAK_TEST}=1")
  255. endif()
  256. # Delocate does not work for ASan and MSan builds.
  257. if(NOT ASAN AND NOT MSAN)
  258. set(FIPS_DELOCATE "1")
  259. endif()
  260. endif()
  261. if(OPENSSL_SMALL)
  262. add_definitions(-DOPENSSL_SMALL)
  263. endif()
  264. # CMake's iOS support uses Apple's multiple-architecture toolchain. It takes an
  265. # architecture list from CMAKE_OSX_ARCHITECTURES, leaves CMAKE_SYSTEM_PROCESSOR
  266. # alone, and expects all architecture-specific logic to be conditioned within
  267. # the source files rather than the build. This does not work for our assembly
  268. # files, so we fix CMAKE_SYSTEM_PROCESSOR and only support single-architecture
  269. # builds.
  270. if (NOT OPENSSL_NO_ASM AND CMAKE_OSX_ARCHITECTURES)
  271. list(LENGTH CMAKE_OSX_ARCHITECTURES NUM_ARCHES)
  272. if (NOT ${NUM_ARCHES} EQUAL 1)
  273. message(FATAL_ERROR "Universal binaries not supported.")
  274. endif()
  275. list(GET CMAKE_OSX_ARCHITECTURES 0 CMAKE_SYSTEM_PROCESSOR)
  276. endif()
  277. if (OPENSSL_NO_ASM)
  278. add_definitions(-DOPENSSL_NO_ASM)
  279. set(ARCH "generic")
  280. elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
  281. set(ARCH "x86_64")
  282. elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "amd64")
  283. set(ARCH "x86_64")
  284. elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64")
  285. # cmake reports AMD64 on Windows, but we might be building for 32-bit.
  286. if (CMAKE_CL_64)
  287. set(ARCH "x86_64")
  288. else()
  289. set(ARCH "x86")
  290. endif()
  291. elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86")
  292. set(ARCH "x86")
  293. elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i386")
  294. set(ARCH "x86")
  295. elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686")
  296. set(ARCH "x86")
  297. elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
  298. set(ARCH "aarch64")
  299. elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm64")
  300. set(ARCH "aarch64")
  301. elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^arm*")
  302. set(ARCH "arm")
  303. elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "mips")
  304. # Just to avoid the “unknown processor” error.
  305. set(ARCH "generic")
  306. elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "ppc64le")
  307. set(ARCH "ppc64le")
  308. else()
  309. message(FATAL_ERROR "Unknown processor:" ${CMAKE_SYSTEM_PROCESSOR})
  310. endif()
  311. if (ANDROID AND NOT ANDROID_NDK_REVISION AND ${ARCH} STREQUAL "arm")
  312. # The third-party Android-NDK CMake files somehow fail to set the -march flag
  313. # for assembly files. Without this flag, the compiler believes that it's
  314. # building for ARMv5.
  315. set(CMAKE_ASM_FLAGS "-march=${CMAKE_SYSTEM_PROCESSOR} ${CMAKE_ASM_FLAGS}")
  316. endif()
  317. if (${ARCH} STREQUAL "x86" AND APPLE AND ${CMAKE_VERSION} VERSION_LESS "3.0")
  318. # With CMake 2.8.x, ${CMAKE_SYSTEM_PROCESSOR} evalutes to i386 on OS X,
  319. # but clang defaults to 64-bit builds on OS X unless otherwise told.
  320. # Set ARCH to x86_64 so clang and CMake agree. This is fixed in CMake 3.
  321. set(ARCH "x86_64")
  322. endif()
  323. if (USE_CUSTOM_LIBCXX)
  324. if (NOT CLANG)
  325. message(FATAL_ERROR "USE_CUSTOM_LIBCXX only supported with Clang")
  326. endif()
  327. # CMAKE_CXX_FLAGS ends up in the linker flags as well, so use
  328. # add_compile_options. There does not appear to be a way to set
  329. # language-specific compile-only flags.
  330. add_compile_options("-nostdinc++")
  331. set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -nostdlib++")
  332. include_directories(
  333. SYSTEM
  334. util/bot/libcxx/include
  335. util/bot/libcxxabi/include
  336. )
  337. # This is patterned after buildtools/third_party/libc++/BUILD.gn and
  338. # buildtools/third_party/libc++abi/BUILD.gn in Chromium.
  339. file(GLOB LIBCXX_SOURCES "util/bot/libcxx/src/*.cpp")
  340. file(GLOB LIBCXXABI_SOURCES "util/bot/libcxxabi/src/*.cpp")
  341. # This file is meant for exception-less builds.
  342. list(REMOVE_ITEM LIBCXXABI_SOURCES "trunk/src/cxa_noexception.cpp")
  343. # libc++ also defines new and delete.
  344. list(REMOVE_ITEM LIBCXXABI_SOURCES "trunk/src/stdlib_new_delete.cpp")
  345. if (TSAN)
  346. # ThreadSanitizer tries to intercept these symbols. Skip them to avoid
  347. # symbol conflicts.
  348. list(REMOVE_ITEM LIBCXXABI_SOURCES "trunk/src/cxa_guard.cpp")
  349. endif()
  350. add_library(libcxxabi ${LIBCXXABI_SOURCES})
  351. target_compile_definitions(
  352. libcxxabi PRIVATE
  353. -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
  354. )
  355. set_target_properties(libcxxabi PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes -Wno-implicit-fallthrough")
  356. add_library(libcxx ${LIBCXX_SOURCES})
  357. if (ASAN OR MSAN OR TSAN)
  358. # Sanitizers try to intercept new and delete.
  359. target_compile_definitions(
  360. libcxx PRIVATE
  361. -D_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS
  362. )
  363. endif()
  364. target_compile_definitions(
  365. libcxx PRIVATE
  366. -D_LIBCPP_BUILDING_LIBRARY
  367. -DLIBCXX_BUILDING_LIBCXXABI
  368. )
  369. target_link_libraries(libcxx libcxxabi)
  370. endif()
  371. # Add minimal googletest targets. The provided one has many side-effects, and
  372. # googletest has a very straightforward build.
  373. add_library(boringssl_gtest third_party/googletest/src/gtest-all.cc)
  374. target_include_directories(boringssl_gtest PRIVATE third_party/googletest)
  375. include_directories(third_party/googletest/include)
  376. # Declare a dummy target to build all unit tests. Test targets should inject
  377. # themselves as dependencies next to the target definition.
  378. add_custom_target(all_tests)
  379. add_custom_command(
  380. OUTPUT crypto_test_data.cc
  381. COMMAND ${GO_EXECUTABLE} run util/embed_test_data.go ${CRYPTO_TEST_DATA} >
  382. ${CMAKE_CURRENT_BINARY_DIR}/crypto_test_data.cc
  383. DEPENDS util/embed_test_data.go ${CRYPTO_TEST_DATA}
  384. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
  385. add_library(crypto_test_data OBJECT crypto_test_data.cc)
  386. add_subdirectory(crypto)
  387. add_subdirectory(third_party/fiat)
  388. add_subdirectory(ssl)
  389. add_subdirectory(ssl/test)
  390. add_subdirectory(fipstools)
  391. add_subdirectory(tool)
  392. add_subdirectory(decrepit)
  393. if(FUZZ)
  394. if(LIBFUZZER_FROM_DEPS)
  395. file(GLOB LIBFUZZER_SOURCES "util/bot/libFuzzer/*.cpp")
  396. add_library(Fuzzer STATIC ${LIBFUZZER_SOURCES})
  397. # libFuzzer does not pass our aggressive warnings. It also must be built
  398. # without -fsanitize-coverage options or clang crashes.
  399. set_target_properties(Fuzzer PROPERTIES COMPILE_FLAGS "-Wno-shadow -Wno-format-nonliteral -Wno-missing-prototypes -fsanitize-coverage=0")
  400. endif()
  401. add_subdirectory(fuzz)
  402. endif()
  403. if (NOT ${CMAKE_VERSION} VERSION_LESS "3.2")
  404. # USES_TERMINAL is only available in CMake 3.2 or later.
  405. set(MAYBE_USES_TERMINAL USES_TERMINAL)
  406. endif()
  407. add_custom_target(
  408. run_tests
  409. COMMAND ${GO_EXECUTABLE} run util/all_tests.go -build-dir
  410. ${CMAKE_BINARY_DIR}
  411. COMMAND cd ssl/test/runner &&
  412. ${GO_EXECUTABLE} test -shim-path $<TARGET_FILE:bssl_shim>
  413. ${RUNNER_ARGS}
  414. WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
  415. DEPENDS all_tests bssl_shim handshaker
  416. ${MAYBE_USES_TERMINAL})