blob: a67789d83baaa2877f2125713ec5f51ef08afe5d [file] [log] [blame]
David Benjamin96628432017-01-19 19:05:47 -05001cmake_minimum_required (VERSION 2.8.11)
Adam Langley95c29f32014-06-20 12:00:00 -07002
David Benjamin6b34d542016-02-05 21:58:39 -05003# Defer enabling C and CXX languages.
4project (BoringSSL NONE)
5
6if(WIN32)
7 # On Windows, prefer cl over gcc if both are available. By default most of
8 # the CMake generators prefer gcc, even on Windows.
9 set(CMAKE_GENERATOR_CC cl)
10endif()
11
David Benjamin3ecd0a52017-05-19 15:26:18 -040012include(sources.cmake)
13
David Benjamin6b34d542016-02-05 21:58:39 -050014enable_language(C)
15enable_language(CXX)
Adam Langley95c29f32014-06-20 12:00:00 -070016
Adam Langley843ab662015-04-28 17:46:58 -070017if(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.
Tamas Berghammer5693e422016-05-19 14:28:14 +010020 if(NOT PERL_EXECUTABLE)
21 set(PERL_EXECUTABLE "perl")
22 endif()
23 if(NOT GO_EXECUTABLE)
24 set(GO_EXECUTABLE "go")
25 endif()
Adam Langley843ab662015-04-28 17:46:58 -070026else()
27 find_package(Perl REQUIRED)
28 find_program(GO_EXECUTABLE go)
29endif()
David Benjamin3ce3c362015-02-23 13:06:19 -050030
David Benjamind27eda02015-03-05 01:19:27 -050031if (NOT GO_EXECUTABLE)
32 message(FATAL_ERROR "Could not find Go")
33endif()
34
David Benjamin2507d9e2017-07-26 11:39:38 -040035if (BORINGSSL_ALLOW_CXX_RUNTIME)
36 add_definitions(-DBORINGSSL_ALLOW_CXX_RUNTIME)
37endif()
38
David Benjamin02afbd32017-10-05 15:04:08 -040039if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
40 set(CLANG 1)
41endif()
Vincent Batts60931e22017-09-20 11:51:54 -040042
David Benjamin02afbd32017-10-05 15:04:08 -040043if(CMAKE_COMPILER_IS_GNUCXX OR CLANG)
44 # Note clang-cl is odd and sets both CLANG and MSVC. We base our configuration
45 # primarily on our normal Clang one because the MSVC one is mostly
46 # suppressions for an overaggressive -Wall.
47 set(C_CXX_FLAGS "-Wall -Werror -Wformat=2 -Wsign-compare -Wmissing-field-initializers -Wwrite-strings")
48 if(MSVC)
49 # clang-cl sets different default warnings than clang.
David Benjamin4519a5a2017-10-06 11:27:11 -040050 set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wno-unused-parameter -fmsc-version=1900")
David Benjamin02afbd32017-10-05 15:04:08 -040051 # 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} -ggdb -fvisibility=hidden -fno-common")
56 endif()
57
58 if(CLANG)
David Benjamin9fb6fea2017-07-31 14:03:38 -040059 set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wnewline-eof -fcolor-diagnostics")
Adam Langley5c38c052017-04-28 14:47:06 -070060 else()
61 # GCC (at least 4.8.4) has a bug where it'll find unreachable free() calls
62 # and declare that the code is trying to free a stack pointer.
63 set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wno-free-nonheap-object")
David Benjamin9b7d8362016-08-29 14:59:31 -040064 endif()
Vincent Batts60931e22017-09-20 11:51:54 -040065
David Benjamin02afbd32017-10-05 15:04:08 -040066 if(CLANG OR NOT "7.0.0" VERSION_GREATER CMAKE_C_COMPILER_VERSION)
Vincent Batts60931e22017-09-20 11:51:54 -040067 set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wimplicit-fallthrough")
68 endif()
69
Adam Langley01867872016-06-30 14:16:59 -070070 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${C_CXX_FLAGS} -Wmissing-prototypes -Wold-style-definition -Wstrict-prototypes")
David Benjamin02afbd32017-10-05 15:04:08 -040071 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${C_CXX_FLAGS} -Wmissing-declarations")
David Benjamin2507d9e2017-07-26 11:39:38 -040072
David Benjamin02afbd32017-10-05 15:04:08 -040073 if(NOT MSVC)
74 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
75 if(NOT BORINGSSL_ALLOW_CXX_RUNTIME)
76 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -fno-rtti")
77 endif()
David Benjamin2507d9e2017-07-26 11:39:38 -040078 endif()
79
David Benjamin4a8d1f32017-07-13 17:53:07 -040080 # In GCC, -Wmissing-declarations is the C++ spelling of -Wmissing-prototypes
81 # and using the wrong one is an error. In Clang, -Wmissing-prototypes is the
82 # spelling for both and -Wmissing-declarations is some other warning.
83 #
84 # https://gcc.gnu.org/onlinedocs/gcc-7.1.0/gcc/Warning-Options.html#Warning-Options
85 # https://clang.llvm.org/docs/DiagnosticsReference.html#wmissing-prototypes
86 # https://clang.llvm.org/docs/DiagnosticsReference.html#wmissing-declarations
David Benjamin02afbd32017-10-05 15:04:08 -040087 if(CLANG)
Vincent Batts60931e22017-09-20 11:51:54 -040088 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wmissing-prototypes")
David Benjamin4a8d1f32017-07-13 17:53:07 -040089 endif()
Adam Langley95c29f32014-06-20 12:00:00 -070090elseif(MSVC)
Brian Smithefed2212015-01-28 16:20:02 -080091 set(MSVC_DISABLED_WARNINGS_LIST
David Benjamin96628432017-01-19 19:05:47 -050092 "C4061" # enumerator 'identifier' in switch of enum 'enumeration' is not
93 # explicitly handled by a case label
94 # Disable this because it flags even when there is a default.
Brian Smithefed2212015-01-28 16:20:02 -080095 "C4100" # 'exarg' : unreferenced formal parameter
96 "C4127" # conditional expression is constant
97 "C4200" # nonstandard extension used : zero-sized array in
98 # struct/union.
David Benjaminffb11072016-11-13 10:32:10 +090099 "C4204" # nonstandard extension used: non-constant aggregate initializer
100 "C4221" # nonstandard extension used : 'identifier' : cannot be
101 # initialized using address of automatic variable
Brian Smithefed2212015-01-28 16:20:02 -0800102 "C4242" # 'function' : conversion from 'int' to 'uint8_t',
103 # possible loss of data
104 "C4244" # 'function' : conversion from 'int' to 'uint8_t',
105 # possible loss of data
David Benjamin3673be72015-02-11 15:12:05 -0500106 "C4267" # conversion from 'size_t' to 'int', possible loss of data
David Benjamin3673be72015-02-11 15:12:05 -0500107 "C4371" # layout of class may have changed from a previous version of the
108 # compiler due to better packing of member '...'
109 "C4388" # signed/unsigned mismatch
Brian Smithefed2212015-01-28 16:20:02 -0800110 "C4296" # '>=' : expression is always true
111 "C4350" # behavior change: 'std::_Wrap_alloc...'
112 "C4365" # '=' : conversion from 'size_t' to 'int',
113 # signed/unsigned mismatch
114 "C4389" # '!=' : signed/unsigned mismatch
David Benjamin7acd6bc2016-05-02 12:57:01 -0400115 "C4464" # relative include path contains '..'
Brian Smithefed2212015-01-28 16:20:02 -0800116 "C4510" # 'argument' : default constructor could not be generated
117 "C4512" # 'argument' : assignment operator could not be generated
118 "C4514" # 'function': unreferenced inline function has been removed
119 "C4548" # expression before comma has no effect; expected expression with
120 # side-effect" caused by FD_* macros.
121 "C4610" # struct 'argument' can never be instantiated - user defined
122 # constructor required.
David Benjamin7acd6bc2016-05-02 12:57:01 -0400123 "C4623" # default constructor was implicitly defined as deleted
David Benjamin3673be72015-02-11 15:12:05 -0500124 "C4625" # copy constructor could not be generated because a base class
125 # copy constructor is inaccessible or deleted
126 "C4626" # assignment operator could not be generated because a base class
127 # assignment operator is inaccessible or deleted
David Benjamin96628432017-01-19 19:05:47 -0500128 "C4668" # 'symbol' is not defined as a preprocessor macro, replacing with
129 # '0' for 'directives'
130 # Disable this because GTest uses it everywhere.
Brian Smithefed2212015-01-28 16:20:02 -0800131 "C4706" # assignment within conditional expression
132 "C4710" # 'function': function not inlined
133 "C4711" # function 'function' selected for inline expansion
134 "C4800" # 'int' : forcing value to bool 'true' or 'false'
135 # (performance warning)
136 "C4820" # 'bytes' bytes padding added after construct 'member_name'
David Benjamin96628432017-01-19 19:05:47 -0500137 "C5026" # move constructor was implicitly defined as deleted
David Benjamin7acd6bc2016-05-02 12:57:01 -0400138 "C5027" # move assignment operator was implicitly defined as deleted
139 )
140 set(MSVC_LEVEL4_WARNINGS_LIST
141 # See https://connect.microsoft.com/VisualStudio/feedback/details/1217660/warning-c4265-when-using-functional-header
142 "C4265" # class has virtual functions, but destructor is not virtual
143 )
Brian Smithefed2212015-01-28 16:20:02 -0800144 string(REPLACE "C" " -wd" MSVC_DISABLED_WARNINGS_STR
145 ${MSVC_DISABLED_WARNINGS_LIST})
David Benjamin7acd6bc2016-05-02 12:57:01 -0400146 string(REPLACE "C" " -w4" MSVC_LEVEL4_WARNINGS_STR
147 ${MSVC_LEVEL4_WARNINGS_LIST})
Brian Smithdc6c1b82016-01-17 22:21:42 -1000148 set(CMAKE_C_FLAGS "-Wall -WX ${MSVC_DISABLED_WARNINGS_STR} ${MSVC_LEVEL4_WARNINGS_STR}")
149 set(CMAKE_CXX_FLAGS "-Wall -WX ${MSVC_DISABLED_WARNINGS_STR} ${MSVC_LEVEL4_WARNINGS_STR}")
David Benjamine2568c42017-08-16 15:25:27 -0400150endif()
151
152if(WIN32)
Adam Langley4a0f0c42015-01-28 16:37:10 -0800153 add_definitions(-D_HAS_EXCEPTIONS=0)
Brian Smitha87de9b2015-01-28 20:34:47 -0800154 add_definitions(-DWIN32_LEAN_AND_MEAN)
David Benjamin0e434b92015-04-02 13:20:01 -0400155 add_definitions(-DNOMINMAX)
David Benjamin9b6ff442017-06-15 20:44:30 -0400156 # Allow use of fopen.
157 add_definitions(-D_CRT_SECURE_NO_WARNINGS)
158 # VS 2017 and higher supports STL-only warning suppressions.
159 add_definitions("-D_STL_EXTRA_DISABLED_WARNINGS=4774 4987")
Adam Langley95c29f32014-06-20 12:00:00 -0700160endif()
161
David Benjaminb826c0d2015-02-28 00:00:44 -0500162if((CMAKE_COMPILER_IS_GNUCXX AND CMAKE_C_COMPILER_VERSION VERSION_GREATER "4.7.99") OR
David Benjamin02afbd32017-10-05 15:04:08 -0400163 CLANG)
Adam Langley4a0f0c42015-01-28 16:37:10 -0800164 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wshadow")
165 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow")
Adam Langley07100c62015-01-16 15:20:54 -0800166endif()
167
David Benjamin2e8ba2d2016-06-09 16:22:26 -0400168if(CMAKE_COMPILER_IS_GNUCXX)
David Benjamin02afbd32017-10-05 15:04:08 -0400169 if ((CMAKE_C_COMPILER_VERSION VERSION_GREATER "4.8.99") OR CLANG)
David Benjamin2e8ba2d2016-06-09 16:22:26 -0400170 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11")
171 else()
172 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
173 endif()
174endif()
175
176# pthread_rwlock_t requires a feature flag.
177if(NOT WIN32)
178 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_XOPEN_SOURCE=700")
Adam Langley6f2e7332015-05-15 12:01:29 -0700179endif()
180
Adam Langley9a4beb82015-11-09 13:57:26 -0800181if(FUZZ)
David Benjamin02afbd32017-10-05 15:04:08 -0400182 if(NOT CLANG)
Alessandro Ghedinib6f69272016-09-28 22:14:01 +0100183 message(FATAL_ERROR "You need to build with Clang for fuzzing to work")
Adam Langley9a4beb82015-11-09 13:57:26 -0800184 endif()
185
David Benjaminec978dd2016-11-04 18:59:33 -0400186 add_definitions(-DBORINGSSL_UNSAFE_DETERMINISTIC_MODE)
187 set(RUNNER_ARGS "-deterministic")
188
189 if(NOT NO_FUZZER_MODE)
190 add_definitions(-DBORINGSSL_UNSAFE_FUZZER_MODE)
191 set(RUNNER_ARGS ${RUNNER_ARGS} "-fuzzer" "-shim-config" "fuzzer_mode.json")
192 endif()
David Benjaminbc5b2a22016-03-01 22:57:32 -0500193
David Benjamin08ab59b2017-05-10 12:02:58 -0400194 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fsanitize-coverage=edge,indirect-calls,trace-pc-guard")
195 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize-coverage=edge,indirect-calls,trace-pc-guard")
Adam Langley9a4beb82015-11-09 13:57:26 -0800196 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
Adam Langley7104cc92015-11-10 15:00:51 -0800197 link_directories(.)
Adam Langley9a4beb82015-11-09 13:57:26 -0800198endif()
199
Adam Langleyeb7d2ed2014-07-30 16:02:14 -0700200add_definitions(-DBORINGSSL_IMPLEMENTATION)
201
David Benjamin507c1ee2015-01-28 00:50:21 -0500202if (BUILD_SHARED_LIBS)
Adam Langley4a0f0c42015-01-28 16:37:10 -0800203 add_definitions(-DBORINGSSL_SHARED_LIBRARY)
204 # Enable position-independent code globally. This is needed because
205 # some library targets are OBJECT libraries.
206 set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
David Benjamin507c1ee2015-01-28 00:50:21 -0500207endif()
208
Adam Langley1bcd10c2016-12-16 10:48:23 -0800209if (MSAN)
David Benjamin02afbd32017-10-05 15:04:08 -0400210 if(NOT CLANG)
Adam Langley1bcd10c2016-12-16 10:48:23 -0800211 message(FATAL_ERROR "Cannot enable MSAN unless using Clang")
212 endif()
213
214 if (ASAN)
215 message(FATAL_ERROR "ASAN and MSAN are mutually exclusive")
216 endif()
217
218 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer")
219 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer")
220 set(OPENSSL_NO_ASM "1")
221endif()
222
223if (ASAN)
David Benjamin02afbd32017-10-05 15:04:08 -0400224 if(NOT CLANG)
Adam Langley1bcd10c2016-12-16 10:48:23 -0800225 message(FATAL_ERROR "Cannot enable ASAN unless using Clang")
226 endif()
227
David Benjamin0d3c9632017-02-28 14:58:00 -0500228 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fsanitize-address-use-after-scope -fno-omit-frame-pointer")
229 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize-address-use-after-scope -fno-omit-frame-pointer")
Adam Langley1bcd10c2016-12-16 10:48:23 -0800230 set(OPENSSL_NO_ASM "1")
231endif()
232
David Benjamind035ab32016-12-27 12:15:56 -0500233if (GCOV)
234 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
235 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
236endif()
237
David Benjaminaff72a32017-04-06 23:26:04 -0400238if(FIPS)
239 add_definitions(-DBORINGSSL_FIPS)
Adam Langleyf64a6ee2017-05-17 13:05:50 -0700240 if(FIPS_BREAK_TEST)
241 add_definitions("-DBORINGSSL_FIPS_BREAK_${FIPS_BREAK_TEST}=1")
242 endif()
243 # Delocate does not work for ASan and MSan builds.
244 if(NOT ASAN AND NOT MSAN)
245 set(FIPS_DELOCATE "1")
246 endif()
David Benjaminaff72a32017-04-06 23:26:04 -0400247endif()
248
249# CMake's iOS support uses Apple's multiple-architecture toolchain. It takes an
250# architecture list from CMAKE_OSX_ARCHITECTURES, leaves CMAKE_SYSTEM_PROCESSOR
251# alone, and expects all architecture-specific logic to be conditioned within
252# the source files rather than the build. This does not work for our assembly
253# files, so we fix CMAKE_SYSTEM_PROCESSOR and only support single-architecture
254# builds.
255if (NOT OPENSSL_NO_ASM AND CMAKE_OSX_ARCHITECTURES)
256 list(LENGTH CMAKE_OSX_ARCHITECTURES NUM_ARCHES)
257 if (NOT ${NUM_ARCHES} EQUAL 1)
258 message(FATAL_ERROR "Universal binaries not supported.")
259 endif()
260 list(GET CMAKE_OSX_ARCHITECTURES 0 CMAKE_SYSTEM_PROCESSOR)
261endif()
262
David Benjamin27b08e92015-05-04 15:16:57 -0400263if (OPENSSL_NO_ASM)
264 add_definitions(-DOPENSSL_NO_ASM)
265 set(ARCH "generic")
David Benjaminaff72a32017-04-06 23:26:04 -0400266elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
267 set(ARCH "x86_64")
268elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "amd64")
269 set(ARCH "x86_64")
270elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64")
271 # cmake reports AMD64 on Windows, but we might be building for 32-bit.
272 if (CMAKE_CL_64)
273 set(ARCH "x86_64")
274 else()
275 set(ARCH "x86")
276 endif()
277elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86")
278 set(ARCH "x86")
279elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i386")
280 set(ARCH "x86")
281elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686")
282 set(ARCH "x86")
283elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
284 set(ARCH "aarch64")
285elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm64")
286 set(ARCH "aarch64")
287elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^arm*")
288 set(ARCH "arm")
289elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "mips")
290 # Just to avoid the “unknown processor” error.
291 set(ARCH "generic")
292elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "ppc64le")
293 set(ARCH "ppc64le")
294else()
295 message(FATAL_ERROR "Unknown processor:" ${CMAKE_SYSTEM_PROCESSOR})
David Benjamin27b08e92015-05-04 15:16:57 -0400296endif()
297
David Benjaminaff72a32017-04-06 23:26:04 -0400298if (ANDROID AND ${ARCH} STREQUAL "arm")
299 # The Android-NDK CMake files somehow fail to set the -march flag for
300 # assembly files. Without this flag, the compiler believes that it's
301 # building for ARMv5.
302 set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -march=${CMAKE_SYSTEM_PROCESSOR}")
303endif()
304
305if (${ARCH} STREQUAL "x86" AND APPLE)
306 # With CMake 2.8.x, ${CMAKE_SYSTEM_PROCESSOR} evalutes to i386 on OS X,
307 # but clang defaults to 64-bit builds on OS X unless otherwise told.
308 # Set ARCH to x86_64 so clang and CMake agree. This is fixed in CMake 3.
309 set(ARCH "x86_64")
Adam Langleyfd499932017-04-04 14:21:43 -0700310endif()
311
David Benjamin96628432017-01-19 19:05:47 -0500312# Add minimal googletest targets. The provided one has many side-effects, and
313# googletest has a very straightforward build.
314add_library(gtest third_party/googletest/src/gtest-all.cc)
315target_include_directories(gtest PRIVATE third_party/googletest)
David Benjamin96628432017-01-19 19:05:47 -0500316
317include_directories(third_party/googletest/include)
318
David Benjamin301afaf2015-10-14 21:34:40 -0400319# Declare a dummy target to build all unit tests. Test targets should inject
320# themselves as dependencies next to the target definition.
321add_custom_target(all_tests)
322
David Benjamin3ecd0a52017-05-19 15:26:18 -0400323add_custom_command(
324 OUTPUT crypto_test_data.cc
325 COMMAND ${GO_EXECUTABLE} run util/embed_test_data.go ${CRYPTO_TEST_DATA} >
326 ${CMAKE_CURRENT_BINARY_DIR}/crypto_test_data.cc
327 DEPENDS util/embed_test_data.go ${CRYPTO_TEST_DATA}
328 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
329
330add_library(crypto_test_data OBJECT crypto_test_data.cc)
331
Adam Langley95c29f32014-06-20 12:00:00 -0700332add_subdirectory(crypto)
333add_subdirectory(ssl)
334add_subdirectory(ssl/test)
Martin Kreichgauer118355c2017-05-12 15:34:45 -0700335add_subdirectory(fipstools)
Adam Langley95c29f32014-06-20 12:00:00 -0700336add_subdirectory(tool)
Adam Langleyc004dfc2015-02-03 10:45:12 -0800337add_subdirectory(decrepit)
David Benjamin301afaf2015-10-14 21:34:40 -0400338
Adam Langley9a4beb82015-11-09 13:57:26 -0800339if(FUZZ)
David Benjamin1e5cb822017-05-10 16:07:56 -0400340 if(LIBFUZZER_FROM_DEPS)
341 file(GLOB LIBFUZZER_SOURCES "util/bot/libFuzzer/*.cpp")
342 add_library(Fuzzer STATIC ${LIBFUZZER_SOURCES})
343 # libFuzzer does not pass our aggressive warnings. It also must be built
344 # without -fsanitize-coverage options or clang crashes.
David Benjamin6fb16cc2017-07-14 11:02:39 -0400345 set_target_properties(Fuzzer PROPERTIES COMPILE_FLAGS "-Wno-shadow -Wno-format-nonliteral -Wno-missing-prototypes -fsanitize-coverage=0")
David Benjamin1e5cb822017-05-10 16:07:56 -0400346 endif()
347
Adam Langley9a4beb82015-11-09 13:57:26 -0800348 add_subdirectory(fuzz)
349endif()
350
David Benjamin301afaf2015-10-14 21:34:40 -0400351if (NOT ${CMAKE_VERSION} VERSION_LESS "3.2")
352 # USES_TERMINAL is only available in CMake 3.2 or later.
353 set(MAYBE_USES_TERMINAL USES_TERMINAL)
354endif()
355
356add_custom_target(
357 run_tests
358 COMMAND ${GO_EXECUTABLE} run util/all_tests.go -build-dir
359 ${CMAKE_BINARY_DIR}
Adam Langleyd5c72c82016-09-23 16:43:17 -0700360 COMMAND cd ssl/test/runner &&
361 ${GO_EXECUTABLE} test -shim-path $<TARGET_FILE:bssl_shim>
362 ${RUNNER_ARGS}
David Benjamin301afaf2015-10-14 21:34:40 -0400363 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
364 DEPENDS all_tests bssl_shim
365 ${MAYBE_USES_TERMINAL})