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") |
Jan Tattermusch | 7132cd7 | 2018-08-21 18:01:53 +0200 | [diff] [blame] | 20 | if (MSVC AND NOT CMAKE_GENERATOR STREQUAL "Ninja") |
| 21 | # Visual Studio build with assembly optimizations is broken, |
| 22 | # but it works with Ninja generator. |
| 23 | # This will get eventually fixed in cmake, but until then |
| 24 | # we need to disable assembly optimizations. |
| 25 | # See https://github.com/grpc/grpc/issues/16376 |
| 26 | set(OPENSSL_NO_ASM ON) |
| 27 | endif() |
Jan Tattermusch | f38b152 | 2017-12-19 14:05:41 -0800 | [diff] [blame] | 28 | add_subdirectory(${BORINGSSL_ROOT_DIR} third_party/boringssl) |
| 29 | if(TARGET ssl) |
| 30 | set(_gRPC_SSL_LIBRARIES ssl) |
| 31 | set(_gRPC_SSL_INCLUDE_DIR ${BORINGSSL_ROOT_DIR}/include) |
| 32 | endif() |
| 33 | else() |
| 34 | message(WARNING "gRPC_SSL_PROVIDER is \"module\" but BORINGSSL_ROOT_DIR is wrong") |
| 35 | endif() |
| 36 | if(gRPC_INSTALL) |
| 37 | message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_SSL_PROVIDER is \"module\"") |
| 38 | set(gRPC_INSTALL FALSE) |
| 39 | endif() |
| 40 | elseif("${gRPC_SSL_PROVIDER}" STREQUAL "package") |
Jan Tattermusch | 6750d42 | 2018-02-07 15:57:23 +0100 | [diff] [blame] | 41 | # OpenSSL installation directory can be configured by setting OPENSSL_ROOT_DIR |
| 42 | # We expect to locate OpenSSL using the built-in cmake module as the openssl |
| 43 | # project itself does not provide installation support in its CMakeLists.txt |
| 44 | # See https://cmake.org/cmake/help/v3.6/module/FindOpenSSL.html |
Jan Tattermusch | f38b152 | 2017-12-19 14:05:41 -0800 | [diff] [blame] | 45 | find_package(OpenSSL REQUIRED) |
Stefan Hacker | 471a5dc | 2018-01-14 13:38:20 +0100 | [diff] [blame] | 46 | |
| 47 | if(TARGET OpenSSL::SSL) |
| 48 | set(_gRPC_SSL_LIBRARIES OpenSSL::SSL OpenSSL::Crypto) |
| 49 | else() |
| 50 | set(_gRPC_SSL_LIBRARIES ${OPENSSL_LIBRARIES}) |
| 51 | endif() |
Jan Tattermusch | f38b152 | 2017-12-19 14:05:41 -0800 | [diff] [blame] | 52 | set(_gRPC_SSL_INCLUDE_DIR ${OPENSSL_INCLUDE_DIR}) |
Stefan Hacker | 471a5dc | 2018-01-14 13:38:20 +0100 | [diff] [blame] | 53 | |
Jan Tattermusch | f38b152 | 2017-12-19 14:05:41 -0800 | [diff] [blame] | 54 | set(_gRPC_FIND_SSL "if(NOT OPENSSL_FOUND)\n find_package(OpenSSL)\nendif()") |
| 55 | endif() |