Skip to content

Commit

Permalink
Allow gRPC_INSTALL with module providers
Browse files Browse the repository at this point in the history
  • Loading branch information
zackgalbreath committed Dec 11, 2019
1 parent bcb716a commit cad4c32
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 10 deletions.
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,15 @@ if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(gRPC_INSTALL_default OFF)
endif()
set(gRPC_INSTALL ${gRPC_INSTALL_default} CACHE BOOL
"Generate installation target: gRPC_ZLIB_PROVIDER, gRPC_CARES_PROVIDER, gRPC_SSL_PROVIDER and gRPC_PROTOBUF_PROVIDER must all be \"package\"")
"Generate installation target")

# We can install dependencies from submodules if we're running
# CMake v3.13 or newer.
if(CMAKE_VERSION VERSION_LESS 3.13)
set(_gRPC_INSTALL_SUPPORTED_FROM_MODULE OFF)
else()
set(_gRPC_INSTALL_SUPPORTED_FROM_MODULE ON)
endif()

# Providers for third-party dependencies (gRPC_*_PROVIDER properties):
# "module": build the dependency using sources from git submodule (under third_party)
Expand Down
10 changes: 8 additions & 2 deletions cmake/cares.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,16 @@ if(gRPC_CARES_PROVIDER STREQUAL "module")

if(TARGET c-ares)
set(_gRPC_CARES_LIBRARIES c-ares)
if(gRPC_INSTALL AND _gRPC_INSTALL_SUPPORTED_FROM_MODULE)
install(TARGETS c-ares EXPORT gRPCTargets
RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR}
LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR})
endif()
endif()

if(gRPC_INSTALL)
message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_CARES_PROVIDER is \"module\"")
if(gRPC_INSTALL AND NOT _gRPC_INSTALL_SUPPORTED_FROM_MODULE)
message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_CARES_PROVIDER is \"module\" and CMake version (${CMAKE_VERSION}) is less than 3.13.")
set(gRPC_INSTALL FALSE)
endif()
elseif(gRPC_CARES_PROVIDER STREQUAL "package")
Expand Down
4 changes: 2 additions & 2 deletions cmake/protobuf.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ if(gRPC_PROTOBUF_PROVIDER STREQUAL "module")
else()
message(WARNING "gRPC_PROTOBUF_PROVIDER is \"module\" but PROTOBUF_ROOT_DIR is wrong")
endif()
if(gRPC_INSTALL)
message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_PROTOBUF_PROVIDER is \"module\"")
if(gRPC_INSTALL AND NOT _gRPC_INSTALL_SUPPORTED_FROM_MODULE)
message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_PROTOBUF_PROVIDER is \"module\" and CMake version (${CMAKE_VERSION}) is less than 3.13.")
set(gRPC_INSTALL FALSE)
endif()
elseif(gRPC_PROTOBUF_PROVIDER STREQUAL "package")
Expand Down
10 changes: 8 additions & 2 deletions cmake/ssl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,18 @@ if(gRPC_SSL_PROVIDER STREQUAL "module")
if(TARGET ssl)
set(_gRPC_SSL_LIBRARIES ssl)
set(_gRPC_SSL_INCLUDE_DIR ${BORINGSSL_ROOT_DIR}/include)
if(gRPC_INSTALL AND _gRPC_INSTALL_SUPPORTED_FROM_MODULE)
install(TARGETS ssl crypto EXPORT gRPCTargets
RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR}
LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR})
endif()
endif()
else()
message(WARNING "gRPC_SSL_PROVIDER is \"module\" but BORINGSSL_ROOT_DIR is wrong")
endif()
if(gRPC_INSTALL)
message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_SSL_PROVIDER is \"module\"")
if(gRPC_INSTALL AND NOT _gRPC_INSTALL_SUPPORTED_FROM_MODULE)
message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_SSL_PROVIDER is \"module\" and CMake version (${CMAKE_VERSION}) is less than 3.13.")
set(gRPC_INSTALL FALSE)
endif()
elseif(gRPC_SSL_PROVIDER STREQUAL "package")
Expand Down
10 changes: 8 additions & 2 deletions cmake/zlib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,18 @@ if(gRPC_ZLIB_PROVIDER STREQUAL "module")
if(TARGET zlibstatic)
set(_gRPC_ZLIB_LIBRARIES zlibstatic)
set(_gRPC_ZLIB_INCLUDE_DIR "${ZLIB_ROOT_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib")
if(gRPC_INSTALL AND _gRPC_INSTALL_SUPPORTED_FROM_MODULE)
install(TARGETS zlibstatic EXPORT gRPCTargets
RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR}
LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR})
endif()
endif()
else()
message(WARNING "gRPC_ZLIB_PROVIDER is \"module\" but ZLIB_ROOT_DIR is wrong")
endif()
if(gRPC_INSTALL)
message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_ZLIB_PROVIDER is \"module\"")
if(gRPC_INSTALL AND NOT _gRPC_INSTALL_SUPPORTED_FROM_MODULE)
message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_ZLIB_PROVIDER is \"module\" and CMake version (${CMAKE_VERSION}) is less than 3.13.")
set(gRPC_INSTALL FALSE)
endif()
elseif(gRPC_ZLIB_PROVIDER STREQUAL "package")
Expand Down
10 changes: 9 additions & 1 deletion templates/CMakeLists.txt.template
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,15 @@
set(gRPC_INSTALL_default OFF)
endif()
set(gRPC_INSTALL <%text>${gRPC_INSTALL_default}</%text> CACHE BOOL
"Generate installation target: gRPC_ZLIB_PROVIDER, gRPC_CARES_PROVIDER, gRPC_SSL_PROVIDER and gRPC_PROTOBUF_PROVIDER must all be \"package\"")
"Generate installation target")

# We can install dependencies from submodules if we're running
# CMake v3.13 or newer.
if(CMAKE_VERSION VERSION_LESS 3.13)
set(_gRPC_INSTALL_SUPPORTED_FROM_MODULE OFF)
else()
set(_gRPC_INSTALL_SUPPORTED_FROM_MODULE ON)
endif()

# Providers for third-party dependencies (gRPC_*_PROVIDER properties):
# "module": build the dependency using sources from git submodule (under third_party)
Expand Down

0 comments on commit cad4c32

Please sign in to comment.