From a65f006d2111b2d94d5108ac4fca7f29f75c81b1 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Mon, 15 May 2017 22:59:37 +0100 Subject: [PATCH] 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(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a97b7a59ee6..23f3748b726 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 c792877b049..0719b3688f3 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\"")