From 8ced27a3641d3818b6324254e197141c57a37cee Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Mon, 15 May 2017 21:56:44 +0100 Subject: Fix finding c-ares in package mode with CMake The next release of c-ares will install a CMake package (when built using CMake), but it will be called "c-ares", not "CARES". --- templates/CMakeLists.txt.template | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'templates') diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template index 2252a7ea80..3e03afdf57 100644 --- a/templates/CMakeLists.txt.template +++ b/templates/CMakeLists.txt.template @@ -195,11 +195,11 @@ message(WARNING "gRPC_CARES_PROVIDER is \"module\" but CARES_ROOT_DIR is wrong") endif() elseif("<%text>${gRPC_CARES_PROVIDER}" 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}" STREQUAL "module") -- cgit v1.2.3 From b5984fa8d765c251a8ad2a0717c50be2710fa4b4 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Mon, 15 May 2017 21:04:16 +0100 Subject: Revert "cmake: fix #8729" This reverts commit c019e057c20db0b9c9a2f76fb0b9cd6f44addf92. --- CMakeLists.txt | 7 +++++++ templates/CMakeLists.txt.template | 7 +++++++ 2 files changed, 14 insertions(+) (limited to 'templates') diff --git a/CMakeLists.txt b/CMakeLists.txt index a65ce567a6..c4e0e0162d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14326,6 +14326,13 @@ endif (gRPC_BUILD_TESTS) +if (gRPC_INSTALL) + install(EXPORT gRPCTargets + DESTINATION ${CMAKE_INSTALL_CMAKEDIR} + NAMESPACE gRPC:: + ) +endif() + foreach(_config gRPCConfig gRPCConfigVersion) configure_file(tools/cmake/${_config}.cmake.in ${_config}.cmake @ONLY) diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template index 3e03afdf57..acf39305fa 100644 --- a/templates/CMakeLists.txt.template +++ b/templates/CMakeLists.txt.template @@ -618,6 +618,13 @@ endif() + if (gRPC_INSTALL) + install(EXPORT gRPCTargets + DESTINATION <%text>${CMAKE_INSTALL_CMAKEDIR} + NAMESPACE gRPC:: + ) + endif() + foreach(_config gRPCConfig gRPCConfigVersion) configure_file(tools/cmake/<%text>${_config}.cmake.in <%text>${_config}.cmake @ONLY) -- cgit v1.2.3 From c17eb5c37e1c2ab44bb1e001769379e5c6f58f64 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Mon, 15 May 2017 21:17:29 +0100 Subject: 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. --- CMakeLists.txt | 25 +++++++++++++++++++++---- templates/CMakeLists.txt.template | 25 +++++++++++++++++++++---- 2 files changed, 42 insertions(+), 8 deletions(-) (limited to 'templates') diff --git a/CMakeLists.txt b/CMakeLists.txt index c4e0e0162d..a97b7a59ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template index acf39305fa..c792877b04 100644 --- a/templates/CMakeLists.txt.template +++ b/templates/CMakeLists.txt.template @@ -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} 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}" 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}" 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}" 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}" STREQUAL "package") find_package(OpenSSL) if(TARGET OpenSSL::SSL) -- cgit v1.2.3 From a65f006d2111b2d94d5108ac4fca7f29f75c81b1 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Mon, 15 May 2017 22:59:37 +0100 Subject: Set gRPC_INSTALL to ON by default for MSVC and OFF if a subproject Now that gRPC_INSTALL is forced off if using bundled third-party libraries, it no longer makes sense to set it OFF by default for MSVC. However, we do want to set it OFF by default if gRPC is being built as a subproject of another project. --- CMakeLists.txt | 5 +++-- templates/CMakeLists.txt.template | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'templates') diff --git a/CMakeLists.txt b/CMakeLists.txt index a97b7a59ee..23f3748b72 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,8 +49,9 @@ project(${PACKAGE_NAME} C CXX) option(gRPC_BUILD_TESTS "Build tests" OFF) set(gRPC_INSTALL_default ON) -if (MSVC) - set(gRPC_INSTALL_default OFF) +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 ${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\"") diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template index c792877b04..0719b3688f 100644 --- a/templates/CMakeLists.txt.template +++ b/templates/CMakeLists.txt.template @@ -93,8 +93,9 @@ option(gRPC_BUILD_TESTS "Build tests" OFF) set(gRPC_INSTALL_default ON) - if (MSVC) - set(gRPC_INSTALL_default OFF) + 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} CACHE BOOL "Generate installation target: gRPC_ZLIB_PROVIDER, gRPC_CARES_PROVIDER, gRPC_SSL_PROVIDER and gRPC_PROTOBUF_PROVIDER must all be \"package\"") -- cgit v1.2.3