Jan Tattermusch | f38b152 | 2017-12-19 14:05:41 -0800 | [diff] [blame] | 1 | # 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 | |
| 15 | if("${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() |
| 33 | elseif("${gRPC_SSL_PROVIDER}" STREQUAL "package") |
Jan Tattermusch | 6750d42 | 2018-02-07 15:57:23 +0100 | [diff] [blame] | 34 | # 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 Tattermusch | f38b152 | 2017-12-19 14:05:41 -0800 | [diff] [blame] | 38 | find_package(OpenSSL REQUIRED) |
Stefan Hacker | 471a5dc | 2018-01-14 13:38:20 +0100 | [diff] [blame] | 39 | |
| 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 Tattermusch | f38b152 | 2017-12-19 14:05:41 -0800 | [diff] [blame] | 45 | set(_gRPC_SSL_INCLUDE_DIR ${OPENSSL_INCLUDE_DIR}) |
Stefan Hacker | 471a5dc | 2018-01-14 13:38:20 +0100 | [diff] [blame] | 46 | |
Jan Tattermusch | f38b152 | 2017-12-19 14:05:41 -0800 | [diff] [blame] | 47 | set(_gRPC_FIND_SSL "if(NOT OPENSSL_FOUND)\n find_package(OpenSSL)\nendif()") |
| 48 | endif() |