blob: 1ebba93fd4b8d34cde07cc85be6567e0b66d908f [file] [log] [blame]
David Benjamin39707fe2022-11-21 15:23:17 -05001cmake_minimum_required(VERSION 3.10)
David Benjamin6979c7e2017-12-04 17:19:49 -05002
David Benjamin6b34d542016-02-05 21:58:39 -05003# Defer enabling C and CXX languages.
David Benjamine6fd1252018-08-10 10:30:55 -05004project(BoringSSL NONE)
David Benjamin6b34d542016-02-05 21:58:39 -05005
Daniel Thornburgh2fc6d382022-04-04 11:23:56 -07006# Don't install BoringSSL to system directories by default; it has no stable
7# ABI. Instead, default to an "install" directory under the source.
8if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
9 set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/install CACHE PATH "" FORCE)
10endif()
11
David Benjamin6b34d542016-02-05 21:58:39 -050012if(WIN32)
13 # On Windows, prefer cl over gcc if both are available. By default most of
14 # the CMake generators prefer gcc, even on Windows.
15 set(CMAKE_GENERATOR_CC cl)
16endif()
17
David Benjamin3ecd0a52017-05-19 15:26:18 -040018include(sources.cmake)
19
David Benjamin6b34d542016-02-05 21:58:39 -050020enable_language(C)
21enable_language(CXX)
Adam Langley95c29f32014-06-20 12:00:00 -070022
Daniel Thornburgh48f79472022-04-25 20:52:43 +000023include(GNUInstallDirs)
24
Joshua Liebow-Feeser8c7c6352018-08-26 18:53:36 -070025# This is a dummy target which all other targets depend on (manually - see other
26# CMakeLists.txt files). This gives us a hook to add any targets which need to
27# run before all other targets.
28add_custom_target(global_target)
29
Adam Langley843ab662015-04-28 17:46:58 -070030if(ANDROID)
31 # Android-NDK CMake files reconfigure the path and so Go and Perl won't be
32 # found. However, ninja will still find them in $PATH if we just name them.
Tamas Berghammer5693e422016-05-19 14:28:14 +010033 if(NOT PERL_EXECUTABLE)
34 set(PERL_EXECUTABLE "perl")
35 endif()
36 if(NOT GO_EXECUTABLE)
37 set(GO_EXECUTABLE "go")
38 endif()
Adam Langley843ab662015-04-28 17:46:58 -070039else()
40 find_package(Perl REQUIRED)
41 find_program(GO_EXECUTABLE go)
42endif()
David Benjamin3ce3c362015-02-23 13:06:19 -050043
David Benjaminf36c3ad2019-01-15 12:45:57 -060044if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT CMAKE_CROSSCOMPILING)
Adam Langley9dfaf252019-01-04 07:53:25 -080045 find_package(PkgConfig QUIET)
46 if (PkgConfig_FOUND)
47 pkg_check_modules(LIBUNWIND libunwind-generic)
48 if(LIBUNWIND_FOUND)
49 add_definitions(-DBORINGSSL_HAVE_LIBUNWIND)
50 else()
51 message("libunwind not found. Disabling unwind tests.")
52 endif()
David Benjamin17d553d2018-12-21 17:58:36 -060053 else()
Adam Langley9dfaf252019-01-04 07:53:25 -080054 message("pkgconfig not found. Disabling unwind tests.")
David Benjamin17d553d2018-12-21 17:58:36 -060055 endif()
56endif()
57
David Benjamine6fd1252018-08-10 10:30:55 -050058if(NOT GO_EXECUTABLE)
David Benjamind27eda02015-03-05 01:19:27 -050059 message(FATAL_ERROR "Could not find Go")
60endif()
61
David Benjamine6fd1252018-08-10 10:30:55 -050062if(USE_CUSTOM_LIBCXX)
David Benjamine9ae99b2018-08-09 15:33:07 -050063 set(BORINGSSL_ALLOW_CXX_RUNTIME 1)
64endif()
Joshua Liebow-Feeser8c7c6352018-08-26 18:53:36 -070065
David Benjamine6fd1252018-08-10 10:30:55 -050066if(BORINGSSL_ALLOW_CXX_RUNTIME)
David Benjamin2507d9e2017-07-26 11:39:38 -040067 add_definitions(-DBORINGSSL_ALLOW_CXX_RUNTIME)
68endif()
69
David Benjamin0de64a72019-09-26 15:59:40 -040070string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER)
71if(NOT FIPS)
72 if(CMAKE_BUILD_TYPE_LOWER STREQUAL "relwithassert" OR
73 NOT CMAKE_BUILD_TYPE_LOWER MATCHES "rel")
74 add_definitions(-DBORINGSSL_DISPATCH_TEST)
75 # CMake automatically connects include_directories to the NASM
76 # command-line, but not add_definitions.
77 set(CMAKE_ASM_NASM_FLAGS "${CMAKE_ASM_NASM_FLAGS} -DBORINGSSL_DISPATCH_TEST")
78 endif()
Adam Langleyc1615712018-11-27 14:07:12 -080079endif()
80
David Benjaminc47f7932019-01-22 19:49:35 -060081# Add a RelWithAsserts build configuration. It is the same as Release, except it
82# does not define NDEBUG, so asserts run.
83foreach(VAR CMAKE_C_FLAGS CMAKE_CXX_FLAGS CMAKE_ASM_FLAGS)
84 string(REGEX REPLACE "(^| )[/-]DNDEBUG( |$)" " " "${VAR}_RELWITHASSERTS"
85 "${${VAR}_RELEASE}")
86endforeach()
87
Joshua Liebow-Feeser8c7c6352018-08-26 18:53:36 -070088if(BORINGSSL_PREFIX AND BORINGSSL_PREFIX_SYMBOLS)
89 add_definitions(-DBORINGSSL_PREFIX=${BORINGSSL_PREFIX})
David Benjamin8c23d3a2018-11-25 15:58:02 -060090 # CMake automatically connects include_directories to the NASM command-line,
91 # but not add_definitions.
92 set(CMAKE_ASM_NASM_FLAGS "${CMAKE_ASM_NASM_FLAGS} -DBORINGSSL_PREFIX=${BORINGSSL_PREFIX}")
Joshua Liebow-Feeser8c7c6352018-08-26 18:53:36 -070093
94 # Use "symbol_prefix_include" to store generated header files
95 include_directories(${CMAKE_CURRENT_BINARY_DIR}/symbol_prefix_include)
96 add_custom_command(
97 OUTPUT 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 COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/symbol_prefix_include
101 COMMAND ${GO_EXECUTABLE} run ${CMAKE_CURRENT_SOURCE_DIR}/util/make_prefix_headers.go -out ${CMAKE_CURRENT_BINARY_DIR}/symbol_prefix_include ${BORINGSSL_PREFIX_SYMBOLS}
102 DEPENDS util/make_prefix_headers.go
103 ${CMAKE_BINARY_DIR}/${BORINGSSL_PREFIX_SYMBOLS})
104
105 # add_dependencies needs a target, not a file, so we add an intermediate
106 # target.
107 add_custom_target(
108 boringssl_prefix_symbols
109 DEPENDS symbol_prefix_include/boringssl_prefix_symbols.h
110 symbol_prefix_include/boringssl_prefix_symbols_asm.h
111 symbol_prefix_include/boringssl_prefix_symbols_nasm.inc)
112 add_dependencies(global_target boringssl_prefix_symbols)
113elseif(BORINGSSL_PREFIX OR BORINGSSL_PREFIX_SYMBOLS)
114 message(FATAL_ERROR "Must specify both or neither of BORINGSSL_PREFIX and BORINGSSL_PREFIX_SYMBOLS")
115endif()
116
David Benjamin02afbd32017-10-05 15:04:08 -0400117if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
118 set(CLANG 1)
119endif()
Vincent Batts60931e22017-09-20 11:51:54 -0400120
Alexei Lozovsky356a9a02019-04-10 14:50:55 +0300121if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
122 set(EMSCRIPTEN 1)
123endif()
124
David Benjamina9281712022-05-20 12:41:15 -0400125set(CMAKE_CXX_STANDARD 14)
126set(CMAKE_CXX_STANDARD_REQUIRED ON)
127if(MSVC AND NOT CLANG)
128 set(CMAKE_C_STANDARD 11)
129 set(CMAKE_C_STANDARD_REQUIRED ON)
130endif()
131
David Benjamin02afbd32017-10-05 15:04:08 -0400132if(CMAKE_COMPILER_IS_GNUCXX OR CLANG)
133 # Note clang-cl is odd and sets both CLANG and MSVC. We base our configuration
David Benjamin8d67f6f2018-01-05 15:43:09 -0500134 # primarily on our normal Clang one.
David Benjaminfd4315d2022-10-27 19:15:48 -0400135 set(C_CXX_FLAGS "-Werror -Wformat=2 -Wsign-compare -Wmissing-field-initializers -Wwrite-strings -Wvla -Wshadow -Wtype-limits")
David Benjamin02afbd32017-10-05 15:04:08 -0400136 if(MSVC)
David Benjamin8d67f6f2018-01-05 15:43:09 -0500137 # clang-cl sets different default warnings than clang. It also treats -Wall
138 # as -Weverything, to match MSVC. Instead -W3 is the alias for -Wall.
139 # See http://llvm.org/viewvc/llvm-project?view=revision&revision=319116
140 set(C_CXX_FLAGS "${C_CXX_FLAGS} -W3 -Wno-unused-parameter -fmsc-version=1900")
David Benjamin02afbd32017-10-05 15:04:08 -0400141 # googletest suppresses warning C4996 via a pragma, but clang-cl does not
142 # honor it. Suppress it here to compensate. See https://crbug.com/772117.
143 set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wno-deprecated-declarations")
144 else()
Alexei Lozovsky356a9a02019-04-10 14:50:55 +0300145 if(EMSCRIPTEN)
146 # emscripten's emcc/clang does not accept the "-ggdb" flag.
147 set(C_CXX_FLAGS "${C_CXX_FLAGS} -g")
148 else()
149 set(C_CXX_FLAGS "${C_CXX_FLAGS} -ggdb")
150 endif()
151
152 set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wall -fvisibility=hidden -fno-common")
David Benjamin02afbd32017-10-05 15:04:08 -0400153 endif()
154
155 if(CLANG)
David Benjamin9fb6fea2017-07-31 14:03:38 -0400156 set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wnewline-eof -fcolor-diagnostics")
Adam Langley5c38c052017-04-28 14:47:06 -0700157 else()
158 # GCC (at least 4.8.4) has a bug where it'll find unreachable free() calls
159 # and declare that the code is trying to free a stack pointer.
160 set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wno-free-nonheap-object")
David Benjamin9b7d8362016-08-29 14:59:31 -0400161 endif()
Vincent Batts60931e22017-09-20 11:51:54 -0400162
David Benjamin7d1fc2b2022-10-14 08:44:15 -0400163 # -Wstring-concatenation was added in Clang 12.0.0, which corresponds to
164 # AppleClang 13.0.0 per the table in
165 # https://en.wikipedia.org/wiki/Xcode#Toolchain_versions
166 if((CMAKE_C_COMPILER_ID STREQUAL "Clang" AND
167 CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "12.0.0") OR
168 (CMAKE_C_COMPILER_ID STREQUAL "AppleClang" AND
169 CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "13.0.0"))
170 set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wstring-concatenation")
171 endif()
172
David Benjaminc8d31372022-07-12 11:46:03 -0400173 if(CLANG OR CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "7.0.0")
Vincent Batts60931e22017-09-20 11:51:54 -0400174 set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wimplicit-fallthrough")
175 endif()
176
David Benjamind7936c22021-12-15 17:25:10 -0500177 if(CMAKE_COMPILER_IS_GNUCXX)
178 set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wformat-signedness")
179 endif()
180
Adam Langley01867872016-06-30 14:16:59 -0700181 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${C_CXX_FLAGS} -Wmissing-prototypes -Wold-style-definition -Wstrict-prototypes")
David Benjamin02afbd32017-10-05 15:04:08 -0400182 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${C_CXX_FLAGS} -Wmissing-declarations")
David Benjamin2507d9e2017-07-26 11:39:38 -0400183
David Benjamina9281712022-05-20 12:41:15 -0400184 if(NOT MSVC AND NOT BORINGSSL_ALLOW_CXX_RUNTIME)
185 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -fno-rtti")
David Benjamin2507d9e2017-07-26 11:39:38 -0400186 endif()
187
David Benjamin4a8d1f32017-07-13 17:53:07 -0400188 # 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
David Benjamin02afbd32017-10-05 15:04:08 -0400195 if(CLANG)
Vincent Batts60931e22017-09-20 11:51:54 -0400196 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wmissing-prototypes")
David Benjamin4a8d1f32017-07-13 17:53:07 -0400197 endif()
Adam Langley95c29f32014-06-20 12:00:00 -0700198elseif(MSVC)
Brian Smithefed2212015-01-28 16:20:02 -0800199 set(MSVC_DISABLED_WARNINGS_LIST
David Benjamin96628432017-01-19 19:05:47 -0500200 "C4061" # enumerator 'identifier' in switch of enum 'enumeration' is not
201 # explicitly handled by a case label
202 # Disable this because it flags even when there is a default.
Brian Smithefed2212015-01-28 16:20:02 -0800203 "C4100" # 'exarg' : unreferenced formal parameter
204 "C4127" # conditional expression is constant
205 "C4200" # nonstandard extension used : zero-sized array in
206 # struct/union.
David Benjaminffb11072016-11-13 10:32:10 +0900207 "C4204" # nonstandard extension used: non-constant aggregate initializer
208 "C4221" # nonstandard extension used : 'identifier' : cannot be
209 # initialized using address of automatic variable
Brian Smithefed2212015-01-28 16:20:02 -0800210 "C4242" # 'function' : conversion from 'int' to 'uint8_t',
211 # possible loss of data
212 "C4244" # 'function' : conversion from 'int' to 'uint8_t',
213 # possible loss of data
David Benjamin3673be72015-02-11 15:12:05 -0500214 "C4267" # conversion from 'size_t' to 'int', possible loss of data
David Benjamin3673be72015-02-11 15:12:05 -0500215 "C4371" # layout of class may have changed from a previous version of the
216 # compiler due to better packing of member '...'
217 "C4388" # signed/unsigned mismatch
Brian Smithefed2212015-01-28 16:20:02 -0800218 "C4296" # '>=' : expression is always true
219 "C4350" # behavior change: 'std::_Wrap_alloc...'
220 "C4365" # '=' : conversion from 'size_t' to 'int',
221 # signed/unsigned mismatch
222 "C4389" # '!=' : signed/unsigned mismatch
David Benjamin7acd6bc2016-05-02 12:57:01 -0400223 "C4464" # relative include path contains '..'
Brian Smithefed2212015-01-28 16:20:02 -0800224 "C4510" # 'argument' : default constructor could not be generated
225 "C4512" # 'argument' : assignment operator could not be generated
226 "C4514" # 'function': unreferenced inline function has been removed
227 "C4548" # expression before comma has no effect; expected expression with
228 # side-effect" caused by FD_* macros.
229 "C4610" # struct 'argument' can never be instantiated - user defined
230 # constructor required.
David Benjamin7acd6bc2016-05-02 12:57:01 -0400231 "C4623" # default constructor was implicitly defined as deleted
David Benjamin3673be72015-02-11 15:12:05 -0500232 "C4625" # copy constructor could not be generated because a base class
233 # copy constructor is inaccessible or deleted
234 "C4626" # assignment operator could not be generated because a base class
235 # assignment operator is inaccessible or deleted
David Benjaminbe7006a2019-04-09 18:05:02 -0500236 "C4628" # digraphs not supported with -Ze
David Benjamin96628432017-01-19 19:05:47 -0500237 "C4668" # 'symbol' is not defined as a preprocessor macro, replacing with
238 # '0' for 'directives'
239 # Disable this because GTest uses it everywhere.
Brian Smithefed2212015-01-28 16:20:02 -0800240 "C4706" # assignment within conditional expression
241 "C4710" # 'function': function not inlined
242 "C4711" # function 'function' selected for inline expansion
243 "C4800" # 'int' : forcing value to bool 'true' or 'false'
244 # (performance warning)
245 "C4820" # 'bytes' bytes padding added after construct 'member_name'
David Benjamin96628432017-01-19 19:05:47 -0500246 "C5026" # move constructor was implicitly defined as deleted
David Benjamin7acd6bc2016-05-02 12:57:01 -0400247 "C5027" # move assignment operator was implicitly defined as deleted
Adam Vartanian189270c2018-05-22 13:50:44 +0100248 "C5045" # Compiler will insert Spectre mitigation for memory load if
249 # /Qspectre switch specified
David Benjamin7acd6bc2016-05-02 12:57:01 -0400250 )
251 set(MSVC_LEVEL4_WARNINGS_LIST
252 # See https://connect.microsoft.com/VisualStudio/feedback/details/1217660/warning-c4265-when-using-functional-header
253 "C4265" # class has virtual functions, but destructor is not virtual
254 )
Brian Smithefed2212015-01-28 16:20:02 -0800255 string(REPLACE "C" " -wd" MSVC_DISABLED_WARNINGS_STR
256 ${MSVC_DISABLED_WARNINGS_LIST})
David Benjamin7acd6bc2016-05-02 12:57:01 -0400257 string(REPLACE "C" " -w4" MSVC_LEVEL4_WARNINGS_STR
258 ${MSVC_LEVEL4_WARNINGS_LIST})
sphawk3ab1a692018-03-11 19:20:51 +0900259 set(CMAKE_C_FLAGS "-utf-8 -Wall -WX ${MSVC_DISABLED_WARNINGS_STR} ${MSVC_LEVEL4_WARNINGS_STR}")
260 set(CMAKE_CXX_FLAGS "-utf-8 -Wall -WX ${MSVC_DISABLED_WARNINGS_STR} ${MSVC_LEVEL4_WARNINGS_STR}")
David Benjamine2568c42017-08-16 15:25:27 -0400261endif()
262
263if(WIN32)
Adam Langley4a0f0c42015-01-28 16:37:10 -0800264 add_definitions(-D_HAS_EXCEPTIONS=0)
Brian Smitha87de9b2015-01-28 20:34:47 -0800265 add_definitions(-DWIN32_LEAN_AND_MEAN)
David Benjamin0e434b92015-04-02 13:20:01 -0400266 add_definitions(-DNOMINMAX)
David Benjamin9b6ff442017-06-15 20:44:30 -0400267 # Allow use of fopen.
268 add_definitions(-D_CRT_SECURE_NO_WARNINGS)
Adam Langleyf7b830d2019-09-06 08:49:28 -0700269 # VS 2017 and higher supports STL-only warning suppressions.
270 # A bug in CMake < 3.13.0 may cause the space in this value to
271 # cause issues when building with NASM. In that case, update CMake.
272 add_definitions("-D_STL_EXTRA_DISABLED_WARNINGS=4774 4987")
Adam Langley95c29f32014-06-20 12:00:00 -0700273endif()
274
David Benjamin387f8202022-01-25 12:16:48 -0500275# pthread_rwlock_t on Linux requires a feature flag. We limit this to Linux
276# because, on Apple platforms, it instead disables APIs we use. See compat(5)
277# and sys/cdefs.h. Reportedly, FreeBSD also breaks when this is set. See
278# https://crbug.com/boringssl/471.
279if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
David Benjamin2e8ba2d2016-06-09 16:22:26 -0400280 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_XOPEN_SOURCE=700")
Adam Langley6f2e7332015-05-15 12:01:29 -0700281endif()
282
Adam Langley9a4beb82015-11-09 13:57:26 -0800283if(FUZZ)
David Benjamin02afbd32017-10-05 15:04:08 -0400284 if(NOT CLANG)
Alessandro Ghedinib6f69272016-09-28 22:14:01 +0100285 message(FATAL_ERROR "You need to build with Clang for fuzzing to work")
Adam Langley9a4beb82015-11-09 13:57:26 -0800286 endif()
287
Adam Langley9c969bf2018-08-24 10:46:01 -0700288 if(CMAKE_C_COMPILER_VERSION VERSION_LESS "6.0.0")
289 message(FATAL_ERROR "You need Clang ≥ 6.0.0")
290 endif()
291
David Benjaminec978dd2016-11-04 18:59:33 -0400292 add_definitions(-DBORINGSSL_UNSAFE_DETERMINISTIC_MODE)
293 set(RUNNER_ARGS "-deterministic")
294
295 if(NOT NO_FUZZER_MODE)
296 add_definitions(-DBORINGSSL_UNSAFE_FUZZER_MODE)
297 set(RUNNER_ARGS ${RUNNER_ARGS} "-fuzzer" "-shim-config" "fuzzer_mode.json")
298 endif()
David Benjaminbc5b2a22016-03-01 22:57:32 -0500299
Adam Langley9c969bf2018-08-24 10:46:01 -0700300 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address,fuzzer-no-link -fsanitize-coverage=edge,indirect-calls")
301 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address,fuzzer-no-link -fsanitize-coverage=edge,indirect-calls")
Adam Langley9a4beb82015-11-09 13:57:26 -0800302endif()
303
Adam Langleyeb7d2ed2014-07-30 16:02:14 -0700304add_definitions(-DBORINGSSL_IMPLEMENTATION)
305
David Benjamine6fd1252018-08-10 10:30:55 -0500306if(BUILD_SHARED_LIBS)
Adam Langley4a0f0c42015-01-28 16:37:10 -0800307 add_definitions(-DBORINGSSL_SHARED_LIBRARY)
308 # Enable position-independent code globally. This is needed because
309 # some library targets are OBJECT libraries.
310 set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
David Benjamin507c1ee2015-01-28 00:50:21 -0500311endif()
312
David Benjamine6fd1252018-08-10 10:30:55 -0500313if(MSAN)
David Benjamin02afbd32017-10-05 15:04:08 -0400314 if(NOT CLANG)
Adam Langley1bcd10c2016-12-16 10:48:23 -0800315 message(FATAL_ERROR "Cannot enable MSAN unless using Clang")
316 endif()
317
David Benjamine6fd1252018-08-10 10:30:55 -0500318 if(ASAN)
Adam Langley1bcd10c2016-12-16 10:48:23 -0800319 message(FATAL_ERROR "ASAN and MSAN are mutually exclusive")
320 endif()
321
322 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer")
323 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer")
Adam Langleye77c27d2018-09-07 11:20:23 -0700324 set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer")
Adam Langley1bcd10c2016-12-16 10:48:23 -0800325endif()
326
David Benjamine6fd1252018-08-10 10:30:55 -0500327if(ASAN)
David Benjamin02afbd32017-10-05 15:04:08 -0400328 if(NOT CLANG)
Adam Langley1bcd10c2016-12-16 10:48:23 -0800329 message(FATAL_ERROR "Cannot enable ASAN unless using Clang")
330 endif()
331
David Benjamin0d3c9632017-02-28 14:58:00 -0500332 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fsanitize-address-use-after-scope -fno-omit-frame-pointer")
333 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 -0800334endif()
335
David Benjaminc367ee52017-11-21 08:16:42 -0500336if(CFI)
337 if(NOT CLANG)
338 message(FATAL_ERROR "Cannot enable CFI unless using Clang")
339 endif()
340
David Benjamin66508982018-09-22 16:19:15 -0500341 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=cfi -fno-sanitize-trap=cfi -flto=thin")
342 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=cfi -fno-sanitize-trap=cfi -flto=thin")
David Benjaminc367ee52017-11-21 08:16:42 -0500343 # We use Chromium's copy of clang, which requires -fuse-ld=lld if building
344 # with -flto. That, in turn, can't handle -ggdb.
345 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=lld")
346 string(REPLACE "-ggdb" "-g" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
347 string(REPLACE "-ggdb" "-g" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
348 # -flto causes object files to contain LLVM bitcode. Mixing those with
349 # assembly output in the same static library breaks the linker.
350 set(OPENSSL_NO_ASM "1")
351endif()
352
David Benjamin5852cfc2018-07-19 17:50:45 -0400353if(TSAN)
354 if(NOT CLANG)
355 message(FATAL_ERROR "Cannot enable TSAN unless using Clang")
356 endif()
357
358 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread")
359 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread")
360 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=thread")
361endif()
362
David Benjaminfc27a192019-01-21 07:25:12 +0000363if(UBSAN)
364 if(NOT CLANG)
365 message(FATAL_ERROR "Cannot enable UBSAN unless using Clang")
366 endif()
367
368 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined")
369 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
370 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined")
371
372 if(NOT UBSAN_RECOVER)
373 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-sanitize-recover=undefined")
374 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-sanitize-recover=undefined")
375 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-sanitize-recover=undefined")
376 endif()
377endif()
378
David Benjamine6fd1252018-08-10 10:30:55 -0500379if(GCOV)
David Benjamind035ab32016-12-27 12:15:56 -0500380 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
381 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
382endif()
383
David Benjaminaff72a32017-04-06 23:26:04 -0400384if(FIPS)
385 add_definitions(-DBORINGSSL_FIPS)
Adam Langleyf64a6ee2017-05-17 13:05:50 -0700386 if(FIPS_BREAK_TEST)
387 add_definitions("-DBORINGSSL_FIPS_BREAK_${FIPS_BREAK_TEST}=1")
388 endif()
Adam Langleyd72e47f2019-05-09 16:39:49 -0700389 # The FIPS integrity check does not work for ASan and MSan builds.
Adam Langleyf64a6ee2017-05-17 13:05:50 -0700390 if(NOT ASAN AND NOT MSAN)
Adam Langleyd72e47f2019-05-09 16:39:49 -0700391 if(BUILD_SHARED_LIBS)
392 set(FIPS_SHARED "1")
393 else()
394 set(FIPS_DELOCATE "1")
395 endif()
Adam Langleyf64a6ee2017-05-17 13:05:50 -0700396 endif()
David Benjamine481d942019-10-18 16:43:12 -0400397 if(FIPS_SHARED)
398 # The Android CMake files set -ffunction-sections and -fdata-sections,
399 # which is incompatible with FIPS_SHARED.
400 set(CMAKE_C_FLAGS
401 "${CMAKE_C_FLAGS} -fno-function-sections -fno-data-sections")
402 set(CMAKE_CXX_FLAGS
403 "${CMAKE_CXX_FLAGS} -fno-function-sections -fno-data-sections")
404 endif()
David Benjaminaff72a32017-04-06 23:26:04 -0400405endif()
406
David Benjamin6291af42018-03-23 13:49:27 -0400407if(OPENSSL_SMALL)
408 add_definitions(-DOPENSSL_SMALL)
409endif()
410
Adam Langleya6a049a2018-12-06 17:15:58 -0800411if(CONSTANT_TIME_VALIDATION)
412 add_definitions(-DBORINGSSL_CONSTANT_TIME_VALIDATION)
413 # Asserts will often test secret data.
414 add_definitions(-DNDEBUG)
415endif()
416
David Benjamin5baee452018-09-13 16:37:28 -0500417function(go_executable dest package)
418 set(godeps "${CMAKE_SOURCE_DIR}/util/godeps.go")
David Benjaminc8d31372022-07-12 11:46:03 -0400419 if(NOT CMAKE_GENERATOR STREQUAL "Ninja")
420 # The DEPFILE parameter to add_custom_command only works with Ninja. Query
421 # the sources at configure time. Additionally, everything depends on go.mod.
422 # That affects what external packages to use.
423 #
424 # TODO(davidben): Starting CMake 3.20, it also works with Make. Starting
425 # 3.21, it works with Visual Studio and Xcode too.
David Benjamin5baee452018-09-13 16:37:28 -0500426 execute_process(COMMAND ${GO_EXECUTABLE} run ${godeps} -format cmake
427 -pkg ${package}
428 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
429 OUTPUT_VARIABLE sources
430 RESULT_VARIABLE godeps_result)
431 add_custom_command(OUTPUT ${dest}
432 COMMAND ${GO_EXECUTABLE} build
433 -o ${CMAKE_CURRENT_BINARY_DIR}/${dest} ${package}
434 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
435 DEPENDS ${sources} ${CMAKE_SOURCE_DIR}/go.mod)
436 else()
437 # Ninja expects the target in the depfile to match the output. This is a
438 # relative path from the build directory.
439 string(LENGTH "${CMAKE_BINARY_DIR}" root_dir_length)
440 math(EXPR root_dir_length "${root_dir_length} + 1")
441 string(SUBSTRING "${CMAKE_CURRENT_BINARY_DIR}" ${root_dir_length} -1 target)
442 set(target "${target}/${dest}")
443
444 set(depfile "${CMAKE_CURRENT_BINARY_DIR}/${dest}.d")
445 add_custom_command(OUTPUT ${dest}
446 COMMAND ${GO_EXECUTABLE} build
447 -o ${CMAKE_CURRENT_BINARY_DIR}/${dest} ${package}
448 COMMAND ${GO_EXECUTABLE} run ${godeps} -format depfile
449 -target ${target} -pkg ${package} -out ${depfile}
450 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
451 DEPENDS ${godeps} ${CMAKE_SOURCE_DIR}/go.mod
452 DEPFILE ${depfile})
453 endif()
454endfunction()
455
David Benjaminaff72a32017-04-06 23:26:04 -0400456# CMake's iOS support uses Apple's multiple-architecture toolchain. It takes an
457# architecture list from CMAKE_OSX_ARCHITECTURES, leaves CMAKE_SYSTEM_PROCESSOR
458# alone, and expects all architecture-specific logic to be conditioned within
459# the source files rather than the build. This does not work for our assembly
460# files, so we fix CMAKE_SYSTEM_PROCESSOR and only support single-architecture
461# builds.
David Benjamine6fd1252018-08-10 10:30:55 -0500462if(NOT OPENSSL_NO_ASM AND CMAKE_OSX_ARCHITECTURES)
David Benjaminaff72a32017-04-06 23:26:04 -0400463 list(LENGTH CMAKE_OSX_ARCHITECTURES NUM_ARCHES)
David Benjamin7e265972021-08-04 14:28:55 -0400464 if(NOT NUM_ARCHES EQUAL 1)
David Benjaminaff72a32017-04-06 23:26:04 -0400465 message(FATAL_ERROR "Universal binaries not supported.")
466 endif()
467 list(GET CMAKE_OSX_ARCHITECTURES 0 CMAKE_SYSTEM_PROCESSOR)
468endif()
469
David Benjamin6887d5e2019-12-17 13:56:30 -0500470if(OPENSSL_NO_SSE2_FOR_TESTING)
471 add_definitions(-DOPENSSL_NO_SSE2_FOR_TESTING)
472endif()
473
David Benjamine6fd1252018-08-10 10:30:55 -0500474if(OPENSSL_NO_ASM)
David Benjamin27b08e92015-05-04 15:16:57 -0400475 add_definitions(-DOPENSSL_NO_ASM)
476 set(ARCH "generic")
David Benjamin7e265972021-08-04 14:28:55 -0400477elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
David Benjaminaff72a32017-04-06 23:26:04 -0400478 set(ARCH "x86_64")
David Benjamin7e265972021-08-04 14:28:55 -0400479elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64")
David Benjaminaff72a32017-04-06 23:26:04 -0400480 set(ARCH "x86_64")
David Benjamin7e265972021-08-04 14:28:55 -0400481elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64")
David Benjaminaff72a32017-04-06 23:26:04 -0400482 # cmake reports AMD64 on Windows, but we might be building for 32-bit.
David Benjamin884614c2020-06-16 10:59:58 -0400483 if(CMAKE_SIZEOF_VOID_P EQUAL 8)
David Benjaminaff72a32017-04-06 23:26:04 -0400484 set(ARCH "x86_64")
485 else()
486 set(ARCH "x86")
487 endif()
David Benjamin7e265972021-08-04 14:28:55 -0400488elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86")
David Benjaminaff72a32017-04-06 23:26:04 -0400489 set(ARCH "x86")
David Benjamin7e265972021-08-04 14:28:55 -0400490elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "i386")
David Benjaminaff72a32017-04-06 23:26:04 -0400491 set(ARCH "x86")
David Benjamin7e265972021-08-04 14:28:55 -0400492elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "i686")
David Benjaminaff72a32017-04-06 23:26:04 -0400493 set(ARCH "x86")
David Benjamin7e265972021-08-04 14:28:55 -0400494elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
David Benjaminaff72a32017-04-06 23:26:04 -0400495 set(ARCH "aarch64")
David Benjamin7e265972021-08-04 14:28:55 -0400496elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "ARM64")
Anthony Robertsafd5dba2020-10-19 12:27:51 +0100497 set(ARCH "aarch64")
David Benjamin7e265972021-08-04 14:28:55 -0400498elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
David Benjaminaff72a32017-04-06 23:26:04 -0400499 set(ARCH "aarch64")
Junghoon Jange8ba1e32018-11-15 10:20:42 +0900500# Apple A12 Bionic chipset which is added in iPhone XS/XS Max/XR uses arm64e architecture.
David Benjamin7e265972021-08-04 14:28:55 -0400501elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64e")
Junghoon Jange8ba1e32018-11-15 10:20:42 +0900502 set(ARCH "aarch64")
David Benjamin7e265972021-08-04 14:28:55 -0400503elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm*")
David Benjaminaff72a32017-04-06 23:26:04 -0400504 set(ARCH "arm")
David Benjamin7e265972021-08-04 14:28:55 -0400505elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "mips")
David Benjaminaff72a32017-04-06 23:26:04 -0400506 # Just to avoid the “unknown processor” error.
507 set(ARCH "generic")
David Benjamin7e265972021-08-04 14:28:55 -0400508elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64le")
David Benjaminaff72a32017-04-06 23:26:04 -0400509 set(ARCH "ppc64le")
Rebecca Chang Swee Fun4566bb52022-06-02 07:18:58 +0000510elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "riscv64")
511 set(ARCH "riscv64")
David Benjaminaff72a32017-04-06 23:26:04 -0400512else()
513 message(FATAL_ERROR "Unknown processor:" ${CMAKE_SYSTEM_PROCESSOR})
David Benjamin27b08e92015-05-04 15:16:57 -0400514endif()
515
David Benjamine6fd1252018-08-10 10:30:55 -0500516if(USE_CUSTOM_LIBCXX)
517 if(NOT CLANG)
David Benjamine9ae99b2018-08-09 15:33:07 -0500518 message(FATAL_ERROR "USE_CUSTOM_LIBCXX only supported with Clang")
519 endif()
520
521 # CMAKE_CXX_FLAGS ends up in the linker flags as well, so use
522 # add_compile_options. There does not appear to be a way to set
523 # language-specific compile-only flags.
524 add_compile_options("-nostdinc++")
525 set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -nostdlib++")
526 include_directories(
527 SYSTEM
David Benjamin16b3af72021-10-26 17:07:39 -0400528 util/bot/libcxx-config
David Benjamine9ae99b2018-08-09 15:33:07 -0500529 util/bot/libcxx/include
530 util/bot/libcxxabi/include
531 )
532
533 # This is patterned after buildtools/third_party/libc++/BUILD.gn and
534 # buildtools/third_party/libc++abi/BUILD.gn in Chromium.
535
536 file(GLOB LIBCXX_SOURCES "util/bot/libcxx/src/*.cpp")
537 file(GLOB LIBCXXABI_SOURCES "util/bot/libcxxabi/src/*.cpp")
538
539 # This file is meant for exception-less builds.
540 list(REMOVE_ITEM LIBCXXABI_SOURCES "trunk/src/cxa_noexception.cpp")
541 # libc++ also defines new and delete.
542 list(REMOVE_ITEM LIBCXXABI_SOURCES "trunk/src/stdlib_new_delete.cpp")
David Benjamine6fd1252018-08-10 10:30:55 -0500543 if(TSAN)
David Benjamine9ae99b2018-08-09 15:33:07 -0500544 # ThreadSanitizer tries to intercept these symbols. Skip them to avoid
545 # symbol conflicts.
546 list(REMOVE_ITEM LIBCXXABI_SOURCES "trunk/src/cxa_guard.cpp")
547 endif()
548
549 add_library(libcxxabi ${LIBCXXABI_SOURCES})
550 target_compile_definitions(
551 libcxxabi PRIVATE
552 -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
553 )
Daniel Thornburgh2fc6d382022-04-04 11:23:56 -0700554 install(TARGETS libcxxabi EXPORT OpenSSLTargets)
David Benjamine9ae99b2018-08-09 15:33:07 -0500555
556 add_library(libcxx ${LIBCXX_SOURCES})
David Benjamine6fd1252018-08-10 10:30:55 -0500557 if(ASAN OR MSAN OR TSAN)
David Benjamine9ae99b2018-08-09 15:33:07 -0500558 # Sanitizers try to intercept new and delete.
559 target_compile_definitions(
560 libcxx PRIVATE
561 -D_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS
562 )
563 endif()
564 target_compile_definitions(
565 libcxx PRIVATE
566 -D_LIBCPP_BUILDING_LIBRARY
567 -DLIBCXX_BUILDING_LIBCXXABI
568 )
David Benjaminaa72a6c2022-11-21 15:27:15 -0500569 set_target_properties(
570 libcxx libcxxabi PROPERTIES
571 COMPILE_FLAGS "-Wno-missing-prototypes -Wno-implicit-fallthrough"
572 # libc++ and libc++abi must be built in C++20 mode.
573 CXX_STANDARD 20
574 CXX_STANDARD_REQUIRED TRUE
575 )
576 # libc++abi depends on libc++ internal headers.
577 set_property(TARGET libcxx libcxxabi APPEND PROPERTY INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}/util/bot/libcxx/src")
David Benjamine9ae99b2018-08-09 15:33:07 -0500578 target_link_libraries(libcxx libcxxabi)
Daniel Thornburgh48f79472022-04-25 20:52:43 +0000579 install(TARGETS libcxx EXPORT OpenSSLTargets DESTINATION ${CMAKE_INSTALL_LIBDIR})
David Benjamine9ae99b2018-08-09 15:33:07 -0500580endif()
581
David Benjamin96628432017-01-19 19:05:47 -0500582# Add minimal googletest targets. The provided one has many side-effects, and
583# googletest has a very straightforward build.
Marek Gilbert11850d52018-01-03 23:07:58 -0800584add_library(boringssl_gtest third_party/googletest/src/gtest-all.cc)
585target_include_directories(boringssl_gtest PRIVATE third_party/googletest)
David Benjamin96628432017-01-19 19:05:47 -0500586
587include_directories(third_party/googletest/include)
588
David Benjamin301afaf2015-10-14 21:34:40 -0400589# Declare a dummy target to build all unit tests. Test targets should inject
590# themselves as dependencies next to the target definition.
591add_custom_target(all_tests)
592
David Benjamincbac9c32020-06-18 16:14:24 -0400593# On Windows, CRYPTO_TEST_DATA is too long to fit in command-line limits.
594# TODO(davidben): CMake 3.12 has a list(JOIN) command. Use that when we've
595# updated the minimum version.
596set(EMBED_TEST_DATA_ARGS "")
597foreach(arg ${CRYPTO_TEST_DATA})
598 set(EMBED_TEST_DATA_ARGS "${EMBED_TEST_DATA_ARGS}${arg}\n")
599endforeach()
600file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/embed_test_data_args.txt"
601 "${EMBED_TEST_DATA_ARGS}")
602
David Benjamin3ecd0a52017-05-19 15:26:18 -0400603add_custom_command(
604 OUTPUT crypto_test_data.cc
David Benjamincbac9c32020-06-18 16:14:24 -0400605 COMMAND ${GO_EXECUTABLE} run util/embed_test_data.go -file-list
606 "${CMAKE_CURRENT_BINARY_DIR}/embed_test_data_args.txt" >
607 "${CMAKE_CURRENT_BINARY_DIR}/crypto_test_data.cc"
David Benjamin3ecd0a52017-05-19 15:26:18 -0400608 DEPENDS util/embed_test_data.go ${CRYPTO_TEST_DATA}
609 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
610
611add_library(crypto_test_data OBJECT crypto_test_data.cc)
612
Adam Langley95c29f32014-06-20 12:00:00 -0700613add_subdirectory(crypto)
614add_subdirectory(ssl)
615add_subdirectory(ssl/test)
616add_subdirectory(tool)
Adam Langleyea9fb942022-02-07 12:32:09 -0800617add_subdirectory(util/fipstools)
Adam Langleyb7f0c1b2019-07-09 18:02:14 -0700618add_subdirectory(util/fipstools/acvp/modulewrapper)
Adam Langleyc004dfc2015-02-03 10:45:12 -0800619add_subdirectory(decrepit)
David Benjamin301afaf2015-10-14 21:34:40 -0400620
Adam Langley9a4beb82015-11-09 13:57:26 -0800621if(FUZZ)
David Benjamin6c597be2019-01-07 15:13:04 -0600622 if(LIBFUZZER_FROM_DEPS)
623 file(GLOB LIBFUZZER_SOURCES "util/bot/libFuzzer/*.cpp")
624 add_library(Fuzzer STATIC ${LIBFUZZER_SOURCES})
625 # libFuzzer does not pass our aggressive warnings. It also must be built
626 # without -fsanitize-coverage options or clang crashes.
627 set_target_properties(Fuzzer PROPERTIES COMPILE_FLAGS "-Wno-shadow -Wno-format-nonliteral -Wno-missing-prototypes -fsanitize-coverage=0")
628 endif()
629
Adam Langley9a4beb82015-11-09 13:57:26 -0800630 add_subdirectory(fuzz)
631endif()
632
Benjamin Brittainea46caf2022-01-20 15:50:12 -0500633if(RUST_BINDINGS)
634 find_program(BINDGEN_EXECUTABLE bindgen)
635 if(NOT BINDGEN_EXECUTABLE)
636 message(FATAL_ERROR "Could not find bindgen but was asked to generate Rust bindings.")
637 else()
638 add_subdirectory(rust)
639 endif()
640endif()
641
David Benjamin0f4454c2022-01-26 14:17:08 -0500642if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
David Benjamin17dc94e2018-08-10 09:05:20 -0500643 set(HANDSHAKER_ARGS "-handshaker-path" $<TARGET_FILE:handshaker>)
644endif()
645
Adam Langley4f75b762020-12-17 14:06:25 -0800646if(FIPS)
647 add_custom_target(
648 acvp_tests
649 COMMAND ${GO_EXECUTABLE} build -o ${CMAKE_BINARY_DIR}/acvptool
650 boringssl.googlesource.com/boringssl/util/fipstools/acvp/acvptool
651 COMMAND ${GO_EXECUTABLE} build -o ${CMAKE_BINARY_DIR}/testmodulewrapper
652 boringssl.googlesource.com/boringssl/util/fipstools/acvp/acvptool/testmodulewrapper
653 COMMAND cd util/fipstools/acvp/acvptool/test &&
654 ${GO_EXECUTABLE} run check_expected.go
655 -tool ${CMAKE_BINARY_DIR}/acvptool
656 -module-wrappers modulewrapper:$<TARGET_FILE:modulewrapper>,testmodulewrapper:${CMAKE_BINARY_DIR}/testmodulewrapper
657 -tests tests.json
658 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
659 DEPENDS modulewrapper
660 USES_TERMINAL)
661
662 add_custom_target(
663 fips_specific_tests_if_any
664 DEPENDS acvp_tests
665 )
666else()
667 add_custom_target(fips_specific_tests_if_any)
668endif()
669
David Benjamin301afaf2015-10-14 21:34:40 -0400670add_custom_target(
671 run_tests
672 COMMAND ${GO_EXECUTABLE} run util/all_tests.go -build-dir
673 ${CMAKE_BINARY_DIR}
Adam Langleyd5c72c82016-09-23 16:43:17 -0700674 COMMAND cd ssl/test/runner &&
675 ${GO_EXECUTABLE} test -shim-path $<TARGET_FILE:bssl_shim>
David Benjamin17dc94e2018-08-10 09:05:20 -0500676 ${HANDSHAKER_ARGS} ${RUNNER_ARGS}
David Benjamin301afaf2015-10-14 21:34:40 -0400677 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
Adam Langley4f75b762020-12-17 14:06:25 -0800678 DEPENDS all_tests bssl_shim handshaker fips_specific_tests_if_any
David Benjamin81a998a2020-05-26 11:35:58 -0400679 USES_TERMINAL)
Daniel Thornburgh2fc6d382022-04-04 11:23:56 -0700680
Daniel Thornburgh48f79472022-04-25 20:52:43 +0000681install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
Daniel Thornburgh2fc6d382022-04-04 11:23:56 -0700682
683install(EXPORT OpenSSLTargets
684 FILE OpenSSLTargets.cmake
685 NAMESPACE OpenSSL::
686 DESTINATION lib/cmake/OpenSSL
687)
688install(FILES OpenSSLConfig.cmake DESTINATION lib/cmake/OpenSSL)