aboutsummaryrefslogtreecommitdiffhomepage
path: root/templates/CMakeLists.txt.template
diff options
context:
space:
mode:
authorGravatar Jan Tattermusch <jtattermusch@users.noreply.github.com>2017-06-19 17:36:55 +0200
committerGravatar GitHub <noreply@github.com>2017-06-19 17:36:55 +0200
commit04d299534df25840ef2d17123fbdfb5af7242d17 (patch)
treea1b9de3c1a36c1b81201f9fae48f8792b15f2c53 /templates/CMakeLists.txt.template
parentb82bfa4e95f0bc90c45c3eff8f86c701b4769f74 (diff)
parenta65f006d2111b2d94d5108ac4fca7f29f75c81b1 (diff)
Merge pull request #11140 from randomguy3/cmake-install
Fix CMake installation issues
Diffstat (limited to 'templates/CMakeLists.txt.template')
-rw-r--r--templates/CMakeLists.txt.template41
1 files changed, 33 insertions, 8 deletions
diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template
index 0cc2ae8020..ef0faccb2e 100644
--- a/templates/CMakeLists.txt.template
+++ b/templates/CMakeLists.txt.template
@@ -77,11 +77,13 @@
# Options
option(gRPC_BUILD_TESTS "Build tests" OFF)
- if (NOT MSVC)
- set(gRPC_INSTALL ON CACHE BOOL "Generate installation target")
- else()
- set(gRPC_INSTALL OFF CACHE BOOL "Generate installation target")
+ set(gRPC_INSTALL_default ON)
+ if (NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
+ # Disable gRPC_INSTALL by default if building as a submodule
+ 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\"")
set(gRPC_ZLIB_PROVIDER "module" CACHE STRING "Provider of zlib library")
set_property(CACHE gRPC_ZLIB_PROVIDER PROPERTY STRINGS "module" "package")
@@ -148,6 +150,10 @@
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\"")
+ set(gRPC_INSTALL FALSE)
+ endif()
elseif("<%text>${gRPC_ZLIB_PROVIDER}</%text>" STREQUAL "package")
find_package(ZLIB)
if(TARGET ZLIB::ZLIB)
@@ -179,12 +185,16 @@
else()
message(WARNING "gRPC_CARES_PROVIDER is \"module\" but CARES_ROOT_DIR is wrong")
endif()
+ if(gRPC_INSTALL)
+ message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_CARES_PROVIDER is \"module\"")
+ set(gRPC_INSTALL FALSE)
+ endif()
elseif("<%text>${gRPC_CARES_PROVIDER}</%text>" STREQUAL "package")
- find_package(CARES)
- if(TARGET CARES::CARES)
- set(_gRPC_CARES_LIBRARIES CARES::CARES)
+ find_package(c-ares CONFIG)
+ if(TARGET c-ares::cares)
+ set(_gRPC_CARES_LIBRARIES c-ares::cares)
endif()
- set(_gRPC_FIND_CARES "if(NOT CARES_FOUND)\n find_package(CARES)\nendif()")
+ set(_gRPC_FIND_CARES "if(NOT c-ares_FOUND)\n find_package(c-ares CONFIG)\nendif()")
endif()
if("<%text>${gRPC_PROTOBUF_PROVIDER}</%text>" STREQUAL "module")
@@ -213,6 +223,10 @@
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\"")
+ set(gRPC_INSTALL FALSE)
+ endif()
elseif("<%text>${gRPC_PROTOBUF_PROVIDER}</%text>" STREQUAL "package")
find_package(protobuf CONFIG)
if(protobuf_FOUND)
@@ -246,6 +260,10 @@
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\"")
+ set(gRPC_INSTALL FALSE)
+ endif()
elseif("<%text>${gRPC_SSL_PROVIDER}</%text>" STREQUAL "package")
find_package(OpenSSL)
if(TARGET OpenSSL::SSL)
@@ -603,6 +621,13 @@
endif()
</%def>
+ if (gRPC_INSTALL)
+ install(EXPORT gRPCTargets
+ DESTINATION <%text>${CMAKE_INSTALL_CMAKEDIR}</%text>
+ NAMESPACE gRPC::
+ )
+ endif()
+
foreach(_config gRPCConfig gRPCConfigVersion)
configure_file(tools/cmake/<%text>${_config}</%text>.cmake.in
<%text>${_config}</%text>.cmake @ONLY)