diff options
author | Jan Tattermusch <jtattermusch@users.noreply.github.com> | 2018-01-19 08:17:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-19 08:17:29 +0100 |
commit | 461cf30159c0ada954e8e2a4e6591694f617809c (patch) | |
tree | 6c0f2b9cfe328d0ed724700449f39e709915b3bd /cmake | |
parent | 471a5dc18b4465b051cddf4e02dbdf44336f80ce (diff) | |
parent | bb2f7e28edc3e3dd663ad308aed7ed632a0a17bf (diff) |
Merge branch 'master' into cmake-export-fix
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/benchmark.cmake | 5 | ||||
-rw-r--r-- | cmake/cares.cmake | 5 | ||||
-rw-r--r-- | cmake/gflags.cmake | 14 | ||||
-rw-r--r-- | cmake/protobuf.cmake | 18 | ||||
-rw-r--r-- | cmake/zlib.cmake | 18 |
5 files changed, 38 insertions, 22 deletions
diff --git a/cmake/benchmark.cmake b/cmake/benchmark.cmake index c6284225a3..753dc0696f 100644 --- a/cmake/benchmark.cmake +++ b/cmake/benchmark.cmake @@ -20,14 +20,17 @@ if("${gRPC_BENCHMARK_PROVIDER}" STREQUAL "module") add_subdirectory(${BENCHMARK_ROOT_DIR} third_party/benchmark) if(TARGET benchmark) set(_gRPC_BENCHMARK_LIBRARIES benchmark) + set(_gRPC_BENCHMARK_INCLUDE_DIR "${BENCHMARK_ROOT_DIR}/include") endif() else() message(WARNING "gRPC_BENCHMARK_PROVIDER is \"module\" but BENCHMARK_ROOT_DIR is wrong") endif() elseif("${gRPC_BENCHMARK_PROVIDER}" STREQUAL "package") - find_package(benchmark) + find_package(benchmark REQUIRED) if(TARGET benchmark::benchmark) set(_gRPC_BENCHMARK_LIBRARIES benchmark::benchmark) + # extract the include dir from target's properties + get_target_property(_gRPC_BENCHMARK_INCLUDE_DIR benchmark::benchmark INTERFACE_INCLUDE_DIRECTORIES) endif() set(_gRPC_FIND_BENCHMARK "if(NOT benchmark_FOUND)\n find_package(benchmark)\nendif()") endif() diff --git a/cmake/cares.cmake b/cmake/cares.cmake index 521cf52e77..53d7582f6f 100644 --- a/cmake/cares.cmake +++ b/cmake/cares.cmake @@ -18,11 +18,13 @@ if("${gRPC_CARES_PROVIDER}" STREQUAL "module") endif() set(CARES_SHARED OFF CACHE BOOL "disable shared library") set(CARES_STATIC ON CACHE BOOL "link cares statically") - set(CARES_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/cares/cares") add_subdirectory(third_party/cares/cares) + if(TARGET c-ares) set(_gRPC_CARES_LIBRARIES c-ares) + set(_gRPC_CARES_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/cares/cares" "${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares") endif() + if(gRPC_INSTALL) message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_CARES_PROVIDER is \"module\"") set(gRPC_INSTALL FALSE) @@ -31,6 +33,7 @@ elseif("${gRPC_CARES_PROVIDER}" STREQUAL "package") find_package(c-ares REQUIRED CONFIG) if(TARGET c-ares::cares) set(_gRPC_CARES_LIBRARIES c-ares::cares) + set(_gRPC_CARES_INCLUDE_DIR ${c-ares_INCLUDE_DIR}) endif() set(_gRPC_FIND_CARES "if(NOT c-ares_FOUND)\n find_package(c-ares CONFIG)\nendif()") endif() diff --git a/cmake/gflags.cmake b/cmake/gflags.cmake index 1864bda357..f86a141c1d 100644 --- a/cmake/gflags.cmake +++ b/cmake/gflags.cmake @@ -17,17 +17,19 @@ if("${gRPC_GFLAGS_PROVIDER}" STREQUAL "module") set(GFLAGS_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/gflags) endif() if(EXISTS "${GFLAGS_ROOT_DIR}/CMakeLists.txt") - add_subdirectory(${GFLAGS_ROOT_DIR} third_party/gflags) - if(TARGET gflags_static) - set(_gRPC_GFLAGS_LIBRARIES gflags_static) - endif() + add_subdirectory(${GFLAGS_ROOT_DIR} third_party/gflags) + if(TARGET gflags_static) + set(_gRPC_GFLAGS_LIBRARIES gflags_static) + set(_gRPC_GFLAGS_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include") + endif() else() - message(WARNING "gRPC_GFLAGS_PROVIDER is \"module\" but GFLAGS_ROOT_DIR is wrong") + message(WARNING "gRPC_GFLAGS_PROVIDER is \"module\" but GFLAGS_ROOT_DIR is wrong") endif() elseif("${gRPC_GFLAGS_PROVIDER}" STREQUAL "package") - find_package(gflags) + find_package(gflags REQUIRED) if(TARGET gflags::gflags) set(_gRPC_GFLAGS_LIBRARIES gflags::gflags) + set(_gRPC_GFLAGS_INCLUDE_DIR ${GFLAGS_INCLUDE_DIR}) endif() set(_gRPC_FIND_GFLAGS "if(NOT gflags_FOUND)\n find_package(gflags)\nendif()") endif() diff --git a/cmake/protobuf.cmake b/cmake/protobuf.cmake index e2206a2319..cb799b5295 100644 --- a/cmake/protobuf.cmake +++ b/cmake/protobuf.cmake @@ -27,7 +27,7 @@ if("${gRPC_PROTOBUF_PROVIDER}" STREQUAL "module") if(NOT PROTOBUF_ROOT_DIR) set(PROTOBUF_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/protobuf) endif() - set(PROTOBUF_WELLKNOWN_IMPORT_DIR ${PROTOBUF_ROOT_DIR}/src) + if(EXISTS "${PROTOBUF_ROOT_DIR}/cmake/CMakeLists.txt") set(protobuf_MSVC_STATIC_RUNTIME OFF CACHE BOOL "Link static runtime libraries") add_subdirectory(${PROTOBUF_ROOT_DIR}/cmake third_party/protobuf) @@ -41,6 +41,9 @@ if("${gRPC_PROTOBUF_PROVIDER}" STREQUAL "module") set(_gRPC_PROTOBUF_PROTOC protoc) set(_gRPC_PROTOBUF_PROTOC_EXECUTABLE $<TARGET_FILE:protoc>) endif() + set(_gRPC_PROTOBUF_INCLUDE_DIR "${PROTOBUF_ROOT_DIR}") + # For well-known .proto files distributed with protobuf + set(_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR "${PROTOBUF_ROOT_DIR}/src") else() message(WARNING "gRPC_PROTOBUF_PROVIDER is \"module\" but PROTOBUF_ROOT_DIR is wrong") endif() @@ -50,6 +53,11 @@ if("${gRPC_PROTOBUF_PROVIDER}" STREQUAL "module") endif() elseif("${gRPC_PROTOBUF_PROVIDER}" STREQUAL "package") find_package(Protobuf REQUIRED ${gRPC_PROTOBUF_PACKAGE_TYPE}) + + # {Protobuf,PROTOBUF}_FOUND is defined based on find_package type ("MODULE" vs "CONFIG"). + # For "MODULE", the case has also changed between cmake 3.5 and 3.6. + # We use the legacy uppercase version for *_LIBRARIES AND *_INCLUDE_DIRS variables + # as newer cmake versions provide them too for backward compatibility. if(Protobuf_FOUND OR PROTOBUF_FOUND) if(TARGET protobuf::${_gRPC_PROTOBUF_LIBRARY_NAME}) set(_gRPC_PROTOBUF_LIBRARIES protobuf::${_gRPC_PROTOBUF_LIBRARY_NAME}) @@ -58,8 +66,11 @@ elseif("${gRPC_PROTOBUF_PROVIDER}" STREQUAL "package") endif() if(TARGET protobuf::libprotoc) set(_gRPC_PROTOBUF_PROTOC_LIBRARIES protobuf::libprotoc) + # extract the include dir from target's properties + get_target_property(_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR protobuf::libprotoc INTERFACE_INCLUDE_DIRECTORIES) else() set(_gRPC_PROTOBUF_PROTOC_LIBRARIES ${PROTOBUF_PROTOC_LIBRARIES}) + set(_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR ${PROTOBUF_INCLUDE_DIRS}) endif() if(TARGET protobuf::protoc) set(_gRPC_PROTOBUF_PROTOC protobuf::protoc) @@ -68,10 +79,7 @@ elseif("${gRPC_PROTOBUF_PROVIDER}" STREQUAL "package") set(_gRPC_PROTOBUF_PROTOC ${PROTOBUF_PROTOC_EXECUTABLE}) set(_gRPC_PROTOBUF_PROTOC_EXECUTABLE ${PROTOBUF_PROTOC_EXECUTABLE}) endif() + set(_gRPC_PROTOBUF_INCLUDE_DIR ${PROTOBUF_INCLUDE_DIRS}) set(_gRPC_FIND_PROTOBUF "if(NOT Protobuf_FOUND AND NOT PROTOBUF_FOUND)\n find_package(Protobuf ${gRPC_PROTOBUF_PACKAGE_TYPE})\nendif()") endif() - if(PROTOBUF_FOUND) - include_directories(${PROTOBUF_INCLUDE_DIRS}) - endif() - set(PROTOBUF_WELLKNOWN_IMPORT_DIR /usr/local/include) endif() diff --git a/cmake/zlib.cmake b/cmake/zlib.cmake index e324802f65..e4c94f5213 100644 --- a/cmake/zlib.cmake +++ b/cmake/zlib.cmake @@ -16,15 +16,15 @@ if("${gRPC_ZLIB_PROVIDER}" STREQUAL "module") if(NOT ZLIB_ROOT_DIR) set(ZLIB_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/zlib) endif() - set(ZLIB_INCLUDE_DIR "${ZLIB_ROOT_DIR}") if(EXISTS "${ZLIB_ROOT_DIR}/CMakeLists.txt") - # TODO(jtattermusch): workaround for https://github.com/madler/zlib/issues/218 - include_directories(${ZLIB_INCLUDE_DIR}) + # TODO(jtattermusch): workaround for https://github.com/madler/zlib/issues/218 + include_directories("${ZLIB_ROOT_DIR}") + add_subdirectory(${ZLIB_ROOT_DIR} third_party/zlib) - add_subdirectory(${ZLIB_ROOT_DIR} third_party/zlib) - if(TARGET zlibstatic) - set(_gRPC_ZLIB_LIBRARIES zlibstatic) - endif() + if(TARGET zlibstatic) + set(_gRPC_ZLIB_LIBRARIES zlibstatic) + set(_gRPC_ZLIB_INCLUDE_DIR "${ZLIB_ROOT_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib") + endif() else() message(WARNING "gRPC_ZLIB_PROVIDER is \"module\" but ZLIB_ROOT_DIR is wrong") endif() @@ -34,12 +34,12 @@ if("${gRPC_ZLIB_PROVIDER}" STREQUAL "module") endif() elseif("${gRPC_ZLIB_PROVIDER}" STREQUAL "package") find_package(ZLIB REQUIRED) - + if(TARGET ZLIB::ZLIB) set(_gRPC_ZLIB_LIBRARIES ZLIB::ZLIB) else() set(_gRPC_ZLIB_LIBRARIES ${ZLIB_LIBRARIES}) endif() - + set(_gRPC_ZLIB_INCLUDE_DIR ${ZLIB_INCLUDE_DIRS}) set(_gRPC_FIND_ZLIB "if(NOT ZLIB_FOUND)\n find_package(ZLIB)\nendif()") endif() |