Merge pull request #20765 from KyleFromKitware/cmake-style-fix

CMake style fixes
reviewable/pr20596/r7
Jan Tattermusch 5 years ago committed by GitHub
commit 398be27287
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 17186
      CMakeLists.txt
  2. 16
      cmake/benchmark.cmake
  3. 4
      cmake/cares.cmake
  4. 16
      cmake/gRPCConfig.cmake.in
  5. 11
      cmake/gRPCConfigVersion.cmake.in
  6. 4
      cmake/gflags.cmake
  7. 8
      cmake/msvc_static_runtime.cmake
  8. 6
      cmake/protobuf.cmake
  9. 6
      cmake/ssl.cmake
  10. 6
      cmake/zlib.cmake
  11. 238
      templates/CMakeLists.txt.template

File diff suppressed because it is too large Load Diff

@ -12,21 +12,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.
if("${gRPC_BENCHMARK_PROVIDER}" STREQUAL "module")
if(gRPC_BENCHMARK_PROVIDER STREQUAL "module")
set(BENCHMARK_ENABLE_GTEST_TESTS OFF CACHE BOOL "Turn off gTest in gBenchmark")
if(NOT BENCHMARK_ROOT_DIR)
set(BENCHMARK_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/benchmark)
endif()
if(EXISTS "${BENCHMARK_ROOT_DIR}/CMakeLists.txt")
add_subdirectory(${BENCHMARK_ROOT_DIR} third_party/benchmark)
if(TARGET benchmark)
set(_gRPC_BENCHMARK_LIBRARIES benchmark)
set(_gRPC_BENCHMARK_INCLUDE_DIR "${BENCHMARK_ROOT_DIR}/include")
endif()
add_subdirectory(${BENCHMARK_ROOT_DIR} third_party/benchmark)
if(TARGET benchmark)
set(_gRPC_BENCHMARK_LIBRARIES benchmark)
set(_gRPC_BENCHMARK_INCLUDE_DIR "${BENCHMARK_ROOT_DIR}/include")
endif()
else()
message(WARNING "gRPC_BENCHMARK_PROVIDER is \"module\" but BENCHMARK_ROOT_DIR is wrong")
message(WARNING "gRPC_BENCHMARK_PROVIDER is \"module\" but BENCHMARK_ROOT_DIR is wrong")
endif()
elseif("${gRPC_BENCHMARK_PROVIDER}" STREQUAL "package")
elseif(gRPC_BENCHMARK_PROVIDER STREQUAL "package")
# Use "CONFIG" as there is no built-in cmake module for benchmark.
find_package(benchmark REQUIRED CONFIG)
if(TARGET benchmark::benchmark)

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
if("${gRPC_CARES_PROVIDER}" STREQUAL "module")
if(gRPC_CARES_PROVIDER STREQUAL "module")
if(NOT CARES_ROOT_DIR)
set(CARES_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/cares/cares)
endif()
@ -33,7 +33,7 @@ if("${gRPC_CARES_PROVIDER}" STREQUAL "module")
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")
elseif(gRPC_CARES_PROVIDER STREQUAL "package")
# Use "CONFIG" as there is no built-in cmake module for c-ares.
find_package(c-ares REQUIRED CONFIG)
if(TARGET c-ares::cares)

@ -1,8 +1,8 @@
# Depend packages
@_gRPC_FIND_ZLIB@
@_gRPC_FIND_PROTOBUF@
@_gRPC_FIND_SSL@
@_gRPC_FIND_CARES@
# Targets
include(${CMAKE_CURRENT_LIST_DIR}/gRPCTargets.cmake)
# Depend packages
@_gRPC_FIND_ZLIB@
@_gRPC_FIND_PROTOBUF@
@_gRPC_FIND_SSL@
@_gRPC_FIND_CARES@
# Targets
include(${CMAKE_CURRENT_LIST_DIR}/gRPCTargets.cmake)

@ -1,11 +0,0 @@
set(PACKAGE_VERSION "@PACKAGE_VERSION@")
# Check whether the requested PACKAGE_FIND_VERSION is compatible
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
set(PACKAGE_VERSION_EXACT TRUE)
endif()
endif()

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
if("${gRPC_GFLAGS_PROVIDER}" STREQUAL "module")
if(gRPC_GFLAGS_PROVIDER STREQUAL "module")
if(NOT GFLAGS_ROOT_DIR)
set(GFLAGS_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/gflags)
endif()
@ -23,7 +23,7 @@ if("${gRPC_GFLAGS_PROVIDER}" STREQUAL "module")
else()
message(WARNING "gRPC_GFLAGS_PROVIDER is \"module\" but GFLAGS_ROOT_DIR is wrong")
endif()
elseif("${gRPC_GFLAGS_PROVIDER}" STREQUAL "package")
elseif(gRPC_GFLAGS_PROVIDER STREQUAL "package")
# Use "CONFIG" as there is no built-in cmake module for gflags.
find_package(gflags REQUIRED CONFIG)
if(TARGET gflags::gflags)

@ -22,9 +22,9 @@ if(gRPC_MSVC_STATIC_RUNTIME)
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if(${flag_var} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
endif(${flag_var} MATCHES "/MD")
endforeach(flag_var)
if(flag_var MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
endif()
endforeach()
endif()

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
if("${gRPC_PROTOBUF_PROVIDER}" STREQUAL "module")
if(gRPC_PROTOBUF_PROVIDER STREQUAL "module")
# Building the protobuf tests require gmock what is not part of a standard protobuf checkout.
# Disable them unless they are explicitly requested from the cmake command line (when we assume
# gmock is downloaded to the right location inside protobuf).
@ -45,13 +45,13 @@ if("${gRPC_PROTOBUF_PROVIDER}" STREQUAL "module")
# For well-known .proto files distributed with protobuf
set(_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR "${PROTOBUF_ROOT_DIR}/src")
else()
message(WARNING "gRPC_PROTOBUF_PROVIDER is \"module\" but PROTOBUF_ROOT_DIR is wrong")
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")
elseif(gRPC_PROTOBUF_PROVIDER STREQUAL "package")
find_package(Protobuf REQUIRED ${gRPC_PROTOBUF_PACKAGE_TYPE})
# {Protobuf,PROTOBUF}_FOUND is defined based on find_package type ("MODULE" vs "CONFIG").

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
if("${gRPC_SSL_PROVIDER}" STREQUAL "module")
if(gRPC_SSL_PROVIDER STREQUAL "module")
if(NOT BORINGSSL_ROOT_DIR)
set(BORINGSSL_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/boringssl)
endif()
@ -31,13 +31,13 @@ if("${gRPC_SSL_PROVIDER}" STREQUAL "module")
set(_gRPC_SSL_INCLUDE_DIR ${BORINGSSL_ROOT_DIR}/include)
endif()
else()
message(WARNING "gRPC_SSL_PROVIDER is \"module\" but BORINGSSL_ROOT_DIR is wrong")
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")
elseif(gRPC_SSL_PROVIDER STREQUAL "package")
# OpenSSL installation directory can be configured by setting OPENSSL_ROOT_DIR
# We expect to locate OpenSSL using the built-in cmake module as the openssl
# project itself does not provide installation support in its CMakeLists.txt

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
if("${gRPC_ZLIB_PROVIDER}" STREQUAL "module")
if(gRPC_ZLIB_PROVIDER STREQUAL "module")
if(NOT ZLIB_ROOT_DIR)
set(ZLIB_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/zlib)
endif()
@ -26,13 +26,13 @@ if("${gRPC_ZLIB_PROVIDER}" STREQUAL "module")
set(_gRPC_ZLIB_INCLUDE_DIR "${ZLIB_ROOT_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib")
endif()
else()
message(WARNING "gRPC_ZLIB_PROVIDER is \"module\" but ZLIB_ROOT_DIR is wrong")
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")
elseif(gRPC_ZLIB_PROVIDER STREQUAL "package")
# zlib installation directory can be configured by setting ZLIB_ROOT
# We allow locating zlib using both "CONFIG" and "MODULE" as the expectation
# is that many Linux systems will have zlib installed via a distribution

@ -61,12 +61,43 @@
if all(platform in platforms for platform in ['linux', 'mac', 'posix', 'windows']):
return ''
cond = ' OR '.join(['_gRPC_PLATFORM_%s' % platform.upper() for platform in platforms])
return 'if(%s)\n' % cond
return 'if(%s)' % cond
def get_platforms_condition_end(platforms):
if not get_platforms_condition_begin(platforms):
return ''
return 'endif()\n'
return 'endif()'
def platforms_condition_block(platforms):
def _func(text):
lines = text.split('\n')
cond = get_platforms_condition_begin(platforms)
if cond:
# Remove empty line following <%block>
del lines[0]
# Indent each line after
for i, line in enumerate(lines[:-1]):
if line:
lines[i] = ' ' + line
# Add the condition block
lines.insert(0, cond)
# Add endif() to the last line
lines[-1] += 'endif()'
else:
# Remove empty line following <%block>
del lines[0]
# Strip leading whitespace from first line
lines[0] = lines[0].lstrip(' ')
# Remove empty line before </%block>
del lines[-1]
return '\n'.join(lines)
return _func
%>
<%
# These files are added to a set so that they are not duplicated if multiple
@ -112,7 +143,7 @@
option(gRPC_BACKWARDS_COMPATIBILITY_MODE "Build libraries that are binary compatible across a larger number of OS and libc versions" OFF)
set(gRPC_INSTALL_default ON)
if (NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
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()
@ -122,7 +153,7 @@
# Providers for third-party dependencies (gRPC_*_PROVIDER properties):
# "module": build the dependency using sources from git submodule (under third_party)
# "package": use cmake's find_package functionality to locate a pre-installed dependency
set(gRPC_ZLIB_PROVIDER "module" CACHE STRING "Provider of zlib library")
set_property(CACHE gRPC_ZLIB_PROVIDER PROPERTY STRINGS "module" "package")
@ -165,8 +196,8 @@
## Some libraries are shared even with BUILD_SHARED_LIBRARIES=OFF
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
if (MSVC)
if(MSVC)
include(cmake/msvc_static_runtime.cmake)
add_definitions(-D_WIN32_WINNT=0x600 -D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS -D_WINSOCK_DEPRECATED_NO_WARNINGS)
# needed to compile protobuf
@ -181,7 +212,7 @@
set(CMAKE_C_FLAGS "<%text>${CMAKE_C_FLAGS} ${_gRPC_C_CXX_FLAGS}</%text>")
set(CMAKE_CXX_FLAGS "<%text>${CMAKE_CXX_FLAGS} ${_gRPC_C_CXX_FLAGS}</%text>")
if (gRPC_USE_PROTO_LITE)
if(gRPC_USE_PROTO_LITE)
set(_gRPC_PROTOBUF_LIBRARY_NAME "libprotobuf-lite")
add_definitions("-DGRPC_USE_PROTO_LITE")
else()
@ -190,13 +221,13 @@
if(gRPC_BACKWARDS_COMPATIBILITY_MODE)
add_definitions(-DGPR_BACKWARDS_COMPATIBILITY_MODE)
if (_gRPC_PLATFORM_MAC)
if(_gRPC_PLATFORM_MAC)
# some C++11 constructs not supported before OS X 10.9
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.9)
endif()
endif()
if (_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_IOS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_IOS)
set(_gRPC_CORE_NOSTDCXX_FLAGS -fno-exceptions -fno-rtti)
else()
set(_gRPC_CORE_NOSTDCXX_FLAGS "")
@ -259,9 +290,9 @@
#if cross-compiling, find host plugin
if(CMAKE_CROSSCOMPILING)
find_program(_gRPC_CPP_PLUGIN grpc_cpp_plugin)
find_program(_gRPC_CPP_PLUGIN grpc_cpp_plugin)
else()
set(_gRPC_CPP_PLUGIN $<TARGET_FILE:grpc_cpp_plugin>)
set(_gRPC_CPP_PLUGIN $<TARGET_FILE:grpc_cpp_plugin>)
endif()
add_custom_command(
@ -280,8 +311,6 @@
WORKING_DIRECTORY <%text>${CMAKE_CURRENT_SOURCE_DIR}</%text>
COMMENT "Running gRPC C++ protocol buffer compiler on <%text>${FIL}</%text>"
VERBATIM)
<%text>set_source_files_properties("${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.grpc.pb.cc" "${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.grpc.pb.h" "${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}_mock.grpc.pb.h" "${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.pb.cc" "${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.pb.h" PROPERTIES GENERATED TRUE)</%text>
endforeach()
endfunction()
@ -321,57 +350,57 @@
)
% endfor
if (gRPC_BUILD_TESTS)
add_custom_target(buildtests_c)
% for tgt in targets:
% if tgt.build == 'test' and not tgt.language == 'c++' and not tgt.get('external_deps', None) and not tgt.boringssl:
${get_platforms_condition_begin(tgt.platforms)}\
add_dependencies(buildtests_c ${tgt.name})
${get_platforms_condition_end(tgt.platforms)}\
% endif
% endfor
add_custom_target(buildtests_cxx)
% for tgt in targets:
% if tgt.build == 'test' and tgt.language == 'c++' and not tgt.get('external_deps', None) and not tgt.boringssl:
${get_platforms_condition_begin(tgt.platforms)}\
add_dependencies(buildtests_cxx ${tgt.name})
${get_platforms_condition_end(tgt.platforms)}\
% endif
% endfor
if(gRPC_BUILD_TESTS)
add_custom_target(buildtests_c)
% for tgt in targets:
% if tgt.build == 'test' and not tgt.language == 'c++' and not tgt.get('external_deps', None) and not tgt.boringssl:
<%block filter='platforms_condition_block(tgt.platforms)'>
add_dependencies(buildtests_c ${tgt.name})
</%block>
% endif
% endfor
add_custom_target(buildtests_cxx)
% for tgt in targets:
% if tgt.build == 'test' and tgt.language == 'c++' and not tgt.get('external_deps', None) and not tgt.boringssl:
<%block filter='platforms_condition_block(tgt.platforms)'>
add_dependencies(buildtests_cxx ${tgt.name})
</%block>
% endif
% endfor
add_custom_target(buildtests
DEPENDS buildtests_c buildtests_cxx)
endif (gRPC_BUILD_TESTS)
add_custom_target(buildtests
DEPENDS buildtests_c buildtests_cxx)
endif()
% for lib in libs:
% if lib.build in ["all", "protoc", "tool", "test", "private"] and not lib.boringssl:
% if not lib.get('build_system', []) or 'cmake' in lib.get('build_system', []):
% if not lib.name in ['ares', 'benchmark', 'upb', 'z']: # we build these using CMake instead
% if lib.build in ["test", "private"]:
if (gRPC_BUILD_TESTS)
if(gRPC_BUILD_TESTS)
${cc_library(lib)}
endif (gRPC_BUILD_TESTS)
endif()
% elif lib.name in ['grpc_csharp_ext']:
if (gRPC_BUILD_CSHARP_EXT)
if(gRPC_BUILD_CSHARP_EXT)
${cc_library(lib)}
% if any(proto_re.match(src) for src in lib.src):
if (gRPC_BUILD_CODEGEN)
if(gRPC_BUILD_CODEGEN)
% endif
${cc_install(lib)}
% if any(proto_re.match(src) for src in lib.src):
endif (gRPC_BUILD_CODEGEN)
endif()
% endif
endif (gRPC_BUILD_CSHARP_EXT)
endif()
% else:
${cc_library(lib)}
% if not lib.build in ["tool"]:
% if any(proto_re.match(src) for src in lib.src):
if (gRPC_BUILD_CODEGEN)
if(gRPC_BUILD_CODEGEN)
% endif
${cc_install(lib)}
% if any(proto_re.match(src) for src in lib.src):
endif (gRPC_BUILD_CODEGEN)
endif()
% endif
% endif
% endif
@ -383,32 +412,32 @@
% for tgt in targets:
% if tgt.build in ["all", "protoc", "tool", "test", "private"] and not tgt.boringssl:
% if tgt.build in ["test", "private"]:
if (gRPC_BUILD_TESTS)
${get_platforms_condition_begin(tgt.platforms)}\
if(gRPC_BUILD_TESTS)
<%block filter='platforms_condition_block(tgt.platforms)'>
${cc_binary(tgt)}
${get_platforms_condition_end(tgt.platforms)}\
endif (gRPC_BUILD_TESTS)
</%block>
endif()
% elif tgt.build in ["protoc"]:
if (gRPC_BUILD_CODEGEN)
${get_platforms_condition_begin(tgt.platforms)}\
if(gRPC_BUILD_CODEGEN)
<%block filter='platforms_condition_block(tgt.platforms)'>
${cc_binary(tgt)}
${cc_install(tgt)}
${get_platforms_condition_end(tgt.platforms)}\
endif (gRPC_BUILD_CODEGEN)
</%block>
endif()
% else:
${get_platforms_condition_begin(tgt.platforms)}\
<%block filter='platforms_condition_block(tgt.platforms)'>
${cc_binary(tgt)}
% if not tgt.build in ["tool"]:
${cc_install(tgt)}
% endif
${get_platforms_condition_end(tgt.platforms)}\
</%block>
% endif
% endif
% endfor
<%def name="cc_library(lib)">
% if any(proto_re.match(src) for src in lib.src):
if (gRPC_BUILD_CODEGEN)
if(gRPC_BUILD_CODEGEN)
% endif
add_library(${lib.name}${' SHARED' if lib.get('dll', None) == 'only' else ''}
% for src in lib.src:
@ -443,7 +472,7 @@
set_target_properties(${lib.name} PROPERTIES COMPILE_PDB_NAME "${lib.name}"
COMPILE_PDB_OUTPUT_DIRECTORY <%text>"${CMAKE_BINARY_DIR}</%text>"
)
if (gRPC_INSTALL)
if(gRPC_INSTALL)
install(FILES <%text>${CMAKE_CURRENT_BINARY_DIR}/</%text>${lib.name}.pdb
DESTINATION <%text>${gRPC_INSTALL_LIBDIR}</%text> OPTIONAL
)
@ -452,25 +481,26 @@
target_include_directories(${lib.name}
PUBLIC <%text>$<INSTALL_INTERFACE:${gRPC_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include></%text>
PRIVATE <%text>${CMAKE_CURRENT_SOURCE_DIR}</%text>
PRIVATE <%text>${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}</%text>
PRIVATE <%text>${_gRPC_BENCHMARK_INCLUDE_DIR}</%text>
PRIVATE <%text>${_gRPC_CARES_INCLUDE_DIR}</%text>
PRIVATE <%text>${_gRPC_GFLAGS_INCLUDE_DIR}</%text>
PRIVATE <%text>${_gRPC_PROTOBUF_INCLUDE_DIR}</%text>
PRIVATE <%text>${_gRPC_SSL_INCLUDE_DIR}</%text>
PRIVATE <%text>${_gRPC_UPB_GENERATED_DIR}</%text>
PRIVATE <%text>${_gRPC_UPB_GRPC_GENERATED_DIR}</%text>
PRIVATE <%text>${_gRPC_UPB_INCLUDE_DIR}</%text>
PRIVATE <%text>${_gRPC_ZLIB_INCLUDE_DIR}</%text>
PRIVATE
<%text>${CMAKE_CURRENT_SOURCE_DIR}</%text>
<%text>${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}</%text>
<%text>${_gRPC_BENCHMARK_INCLUDE_DIR}</%text>
<%text>${_gRPC_CARES_INCLUDE_DIR}</%text>
<%text>${_gRPC_GFLAGS_INCLUDE_DIR}</%text>
<%text>${_gRPC_PROTOBUF_INCLUDE_DIR}</%text>
<%text>${_gRPC_SSL_INCLUDE_DIR}</%text>
<%text>${_gRPC_UPB_GENERATED_DIR}</%text>
<%text>${_gRPC_UPB_GRPC_GENERATED_DIR}</%text>
<%text>${_gRPC_UPB_INCLUDE_DIR}</%text>
<%text>${_gRPC_ZLIB_INCLUDE_DIR}</%text>
% if lib.build in ['test', 'private'] and lib.language == 'c++':
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
PRIVATE third_party/googletest/googlemock
third_party/googletest/googletest/include
third_party/googletest/googletest
third_party/googletest/googlemock/include
third_party/googletest/googlemock
% endif
% if lib.language == 'c++':
PRIVATE <%text>${_gRPC_PROTO_GENS_DIR}</%text>
<%text>${_gRPC_PROTO_GENS_DIR}</%text>
% endif
)
% if len(get_deps(lib)) > 0:
@ -481,17 +511,17 @@
)
% endif
% if lib.name in ["gpr"]:
if (_gRPC_PLATFORM_ANDROID)
if(_gRPC_PLATFORM_ANDROID)
target_link_libraries(gpr
android
log
)
endif (_gRPC_PLATFORM_ANDROID)
endif()
% endif
% if lib.name in ["grpc", "grpc_cronet", "grpc_test_util", \
"grpc_test_util_unsecure", "grpc_unsecure", \
"grpc++_cronet"]:
if (_gRPC_PLATFORM_IOS OR _gRPC_PLATFORM_MAC)
if(_gRPC_PLATFORM_IOS OR _gRPC_PLATFORM_MAC)
target_link_libraries(${lib.name} "-framework CoreFoundation")
endif()
%endif
@ -510,7 +540,7 @@
endforeach()
% endif
% if any(proto_re.match(src) for src in lib.src):
endif (gRPC_BUILD_CODEGEN)
endif()
% endif
</%def>
@ -533,26 +563,27 @@
)
target_include_directories(${tgt.name}
PRIVATE <%text>${CMAKE_CURRENT_SOURCE_DIR}</%text>
PRIVATE <%text>${CMAKE_CURRENT_SOURCE_DIR}</%text>/include
PRIVATE <%text>${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}</%text>
PRIVATE <%text>${_gRPC_BENCHMARK_INCLUDE_DIR}</%text>
PRIVATE <%text>${_gRPC_CARES_INCLUDE_DIR}</%text>
PRIVATE <%text>${_gRPC_GFLAGS_INCLUDE_DIR}</%text>
PRIVATE <%text>${_gRPC_PROTOBUF_INCLUDE_DIR}</%text>
PRIVATE <%text>${_gRPC_SSL_INCLUDE_DIR}</%text>
PRIVATE <%text>${_gRPC_UPB_GENERATED_DIR}</%text>
PRIVATE <%text>${_gRPC_UPB_GRPC_GENERATED_DIR}</%text>
PRIVATE <%text>${_gRPC_UPB_INCLUDE_DIR}</%text>
PRIVATE <%text>${_gRPC_ZLIB_INCLUDE_DIR}</%text>
PRIVATE
<%text>${CMAKE_CURRENT_SOURCE_DIR}</%text>
<%text>${CMAKE_CURRENT_SOURCE_DIR}</%text>/include
<%text>${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}</%text>
<%text>${_gRPC_BENCHMARK_INCLUDE_DIR}</%text>
<%text>${_gRPC_CARES_INCLUDE_DIR}</%text>
<%text>${_gRPC_GFLAGS_INCLUDE_DIR}</%text>
<%text>${_gRPC_PROTOBUF_INCLUDE_DIR}</%text>
<%text>${_gRPC_SSL_INCLUDE_DIR}</%text>
<%text>${_gRPC_UPB_GENERATED_DIR}</%text>
<%text>${_gRPC_UPB_GRPC_GENERATED_DIR}</%text>
<%text>${_gRPC_UPB_INCLUDE_DIR}</%text>
<%text>${_gRPC_ZLIB_INCLUDE_DIR}</%text>
% if tgt.build in ['test', 'private'] and tgt.language == 'c++':
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
PRIVATE third_party/googletest/googlemock
third_party/googletest/googletest/include
third_party/googletest/googletest
third_party/googletest/googlemock/include
third_party/googletest/googlemock
% endif
% if tgt.language == 'c++':
PRIVATE <%text>${_gRPC_PROTO_GENS_DIR}</%text>
<%text>${_gRPC_PROTO_GENS_DIR}</%text>
% endif
)
@ -567,7 +598,7 @@
</%def>
<%def name="cc_install(tgt)">
if (gRPC_INSTALL)
if(gRPC_INSTALL)
install(TARGETS ${tgt.name} EXPORT gRPCTargets
RUNTIME DESTINATION <%text>${gRPC_INSTALL_BINDIR}</%text>
LIBRARY DESTINATION <%text>${gRPC_INSTALL_LIBDIR}</%text>
@ -576,21 +607,26 @@
endif()
</%def>
if (gRPC_INSTALL)
if(gRPC_INSTALL)
install(EXPORT gRPCTargets
DESTINATION <%text>${gRPC_INSTALL_CMAKEDIR}</%text>
NAMESPACE gRPC::
)
endif()
foreach(_config gRPCConfig gRPCConfigVersion)
configure_file(cmake/<%text>${_config}</%text>.cmake.in
<%text>${_config}</%text>.cmake @ONLY)
install(FILES <%text>${CMAKE_CURRENT_BINARY_DIR}/${_config}</%text>.cmake
DESTINATION <%text>${gRPC_INSTALL_CMAKEDIR}</%text>
)
endforeach()
include(CMakePackageConfigHelpers)
configure_file(cmake/gRPCConfig.cmake.in
gRPCConfig.cmake @ONLY)
write_basic_package_version_file(<%text>${CMAKE_CURRENT_BINARY_DIR}/</%text>gRPCConfigVersion.cmake
VERSION <%text>${PACKAGE_VERSION}</%text>
COMPATIBILITY AnyNewerVersion)
install(FILES
<%text>${CMAKE_CURRENT_BINARY_DIR}/</%text>gRPCConfig.cmake
<%text>${CMAKE_CURRENT_BINARY_DIR}/</%text>gRPCConfigVersion.cmake
DESTINATION <%text>${gRPC_INSTALL_CMAKEDIR}</%text>
)
install(FILES <%text>${CMAKE_CURRENT_SOURCE_DIR}/etc/roots.pem</%text>
DESTINATION <%text>${gRPC_INSTALL_SHAREDIR}</%text>)

Loading…
Cancel
Save