CMake: Disable installation when using bundled third party libraries

If gRPC is not getting its (link-time) dependencies from the system, it
should not be attempting installation.
pull/11140/head
Alex Merry 8 years ago
parent b5984fa8d7
commit c17eb5c37e
  1. 25
      CMakeLists.txt
  2. 25
      templates/CMakeLists.txt.template

@ -48,11 +48,12 @@ project(${PACKAGE_NAME} C CXX)
# 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 (MSVC)
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\"")
set(gRPC_ZLIB_PROVIDER "module" CACHE STRING "Provider of zlib library")
set_property(CACHE gRPC_ZLIB_PROVIDER PROPERTY STRINGS "module" "package")
@ -118,6 +119,10 @@ if("${gRPC_ZLIB_PROVIDER}" STREQUAL "module")
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("${gRPC_ZLIB_PROVIDER}" STREQUAL "package")
find_package(ZLIB)
if(TARGET ZLIB::ZLIB)
@ -149,6 +154,10 @@ if("${gRPC_CARES_PROVIDER}" STREQUAL "module")
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("${gRPC_CARES_PROVIDER}" STREQUAL "package")
find_package(c-ares CONFIG)
if(TARGET c-ares::cares)
@ -183,6 +192,10 @@ 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\"")
set(gRPC_INSTALL FALSE)
endif()
elseif("${gRPC_PROTOBUF_PROVIDER}" STREQUAL "package")
find_package(protobuf CONFIG)
if(protobuf_FOUND)
@ -216,6 +229,10 @@ if("${gRPC_SSL_PROVIDER}" STREQUAL "module")
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("${gRPC_SSL_PROVIDER}" STREQUAL "package")
find_package(OpenSSL)
if(TARGET OpenSSL::SSL)

@ -92,11 +92,12 @@
# 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 (MSVC)
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")
@ -163,6 +164,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)
@ -194,6 +199,10 @@
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(c-ares CONFIG)
if(TARGET c-ares::cares)
@ -228,6 +237,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)
@ -261,6 +274,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)

Loading…
Cancel
Save