blob: c301b1cdb6dcca9a252a69af02c506342c6ce982 [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_GFLAGS_PROVIDER}" STREQUAL "module")
16 if(NOT GFLAGS_ROOT_DIR)
17 set(GFLAGS_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/gflags)
18 endif()
19 if(EXISTS "${GFLAGS_ROOT_DIR}/CMakeLists.txt")
Jan Tattermusch586f7192018-01-16 17:57:17 +010020 add_subdirectory(${GFLAGS_ROOT_DIR} third_party/gflags)
21 if(TARGET gflags_static)
22 set(_gRPC_GFLAGS_LIBRARIES gflags_static)
23 set(_gRPC_GFLAGS_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include")
24 endif()
Jan Tattermuschf38b1522017-12-19 14:05:41 -080025 else()
Jan Tattermusch586f7192018-01-16 17:57:17 +010026 message(WARNING "gRPC_GFLAGS_PROVIDER is \"module\" but GFLAGS_ROOT_DIR is wrong")
Jan Tattermuschf38b1522017-12-19 14:05:41 -080027 endif()
28elseif("${gRPC_GFLAGS_PROVIDER}" STREQUAL "package")
Jan Tattermusch6750d422018-02-07 15:57:23 +010029 # Use "CONFIG" as there is no built-in cmake module for gflags.
30 find_package(gflags REQUIRED CONFIG)
Jan Tattermusch82af3602018-08-13 19:52:16 +020031 if(TARGET gflags)
32 set(_gRPC_GFLAGS_LIBRARIES gflags)
Jan Tattermusch586f7192018-01-16 17:57:17 +010033 set(_gRPC_GFLAGS_INCLUDE_DIR ${GFLAGS_INCLUDE_DIR})
Jan Tattermuschf38b1522017-12-19 14:05:41 -080034 endif()
Jan Tattermusch6750d422018-02-07 15:57:23 +010035 set(_gRPC_FIND_GFLAGS "if(NOT gflags_FOUND)\n find_package(gflags CONFIG)\nendif()")
Jan Tattermuschf38b1522017-12-19 14:05:41 -080036endif()