@ -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
@ -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()
@ -325,24 +354,24 @@
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)}\
<%block filter='platforms_condition_block(tgt.platforms)'>
add_dependencies(buildtests_c ${tgt.name})
${get_platforms_condition_end(tgt.platforms)}\
</%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:
${get_platforms_condition_begin(tgt.platforms)}\
<%block filter='platforms_condition_block(tgt.platforms)'>
add_dependencies(buildtests_cxx ${tgt.name})
${get_platforms_condition_end(tgt.platforms)}\
</%block>
% endif
% endfor
add_custom_target(buildtests
DEPENDS buildtests_c buildtests_cxx)
endif (gRPC_BUILD_TESTS )
endif()
% for lib in libs:
% if lib.build in ["all", "protoc", "tool", "test", "private"] and not lib.boringssl:
@ -351,7 +380,7 @@
% if lib.build in ["test", "private"]:
if(gRPC_BUILD_TESTS)
${cc_library(lib)}
endif (gRPC_BUILD_TESTS )
endif()
% elif lib.name in ['grpc_csharp_ext']:
if(gRPC_BUILD_CSHARP_EXT)
${cc_library(lib)}
@ -360,9 +389,9 @@
% 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"]:
@ -371,7 +400,7 @@
% endif
${cc_install(lib)}
% if any(proto_re.match(src) for src in lib.src):
endif (gRPC_BUILD_CODEGEN )
endif()
% endif
% endif
% endif
@ -384,24 +413,24 @@
% 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)}\
<%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)}\
<%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
@ -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:
@ -486,7 +516,7 @@
android
log
)
endif (_gRPC_PLATFORM_ANDROID )
endif()
% endif
% if lib.name in ["grpc", "grpc_cronet", "grpc_test_util", \
"grpc_test_util_unsecure", "grpc_unsecure", \
@ -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
)
@ -583,13 +614,18 @@
)
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
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>
)
endforeach()
install(FILES <%text>${CMAKE_CURRENT_SOURCE_DIR}/etc/roots.pem</%text>
DESTINATION <%text>${gRPC_INSTALL_SHAREDIR}</%text>)