blob: 83f642a6754c320e9e2b591828a36e70cbdaf1c3 [file] [log] [blame]
Jan Tattermuschf38b1522017-12-19 14:05:41 -08001# Copyright 2017 gRPC authors.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://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
15if("${gRPC_SSL_PROVIDER}" STREQUAL "module")
16 if(NOT BORINGSSL_ROOT_DIR)
17 set(BORINGSSL_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/boringssl)
18 endif()
19 if(EXISTS "${BORINGSSL_ROOT_DIR}/CMakeLists.txt")
20 set(OPENSSL_NO_ASM ON) # make boringssl buildable with Visual Studio
21 add_subdirectory(${BORINGSSL_ROOT_DIR} third_party/boringssl)
22 if(TARGET ssl)
23 set(_gRPC_SSL_LIBRARIES ssl)
24 set(_gRPC_SSL_INCLUDE_DIR ${BORINGSSL_ROOT_DIR}/include)
25 endif()
26 else()
27 message(WARNING "gRPC_SSL_PROVIDER is \"module\" but BORINGSSL_ROOT_DIR is wrong")
28 endif()
29 if(gRPC_INSTALL)
30 message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_SSL_PROVIDER is \"module\"")
31 set(gRPC_INSTALL FALSE)
32 endif()
33elseif("${gRPC_SSL_PROVIDER}" STREQUAL "package")
Jan Tattermusch6750d422018-02-07 15:57:23 +010034 # OpenSSL installation directory can be configured by setting OPENSSL_ROOT_DIR
35 # We expect to locate OpenSSL using the built-in cmake module as the openssl
36 # project itself does not provide installation support in its CMakeLists.txt
37 # See https://cmake.org/cmake/help/v3.6/module/FindOpenSSL.html
Jan Tattermuschf38b1522017-12-19 14:05:41 -080038 find_package(OpenSSL REQUIRED)
Stefan Hacker471a5dc2018-01-14 13:38:20 +010039
40 if(TARGET OpenSSL::SSL)
41 set(_gRPC_SSL_LIBRARIES OpenSSL::SSL OpenSSL::Crypto)
42 else()
43 set(_gRPC_SSL_LIBRARIES ${OPENSSL_LIBRARIES})
44 endif()
Jan Tattermuschf38b1522017-12-19 14:05:41 -080045 set(_gRPC_SSL_INCLUDE_DIR ${OPENSSL_INCLUDE_DIR})
Stefan Hacker471a5dc2018-01-14 13:38:20 +010046
Jan Tattermuschf38b1522017-12-19 14:05:41 -080047 set(_gRPC_FIND_SSL "if(NOT OPENSSL_FOUND)\n find_package(OpenSSL)\nendif()")
48endif()