aboutsummaryrefslogtreecommitdiffhomepage
path: root/templates/CMakeLists.txt.template
diff options
context:
space:
mode:
Diffstat (limited to 'templates/CMakeLists.txt.template')
-rw-r--r--templates/CMakeLists.txt.template26
1 files changed, 26 insertions, 0 deletions
diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template
index c279bef51f..0f088436d1 100644
--- a/templates/CMakeLists.txt.template
+++ b/templates/CMakeLists.txt.template
@@ -84,6 +84,7 @@
# Options
option(gRPC_BUILD_TESTS "Build tests" OFF)
+ option(gRPC_BUILD_CODEGEN "Build codegen" ON)
set(gRPC_INSTALL_default ON)
if (NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
@@ -125,6 +126,8 @@
set(_gRPC_PLATFORM_LINUX ON)
elseif(<%text>${CMAKE_SYSTEM_NAME}</%text> MATCHES "Darwin")
set(_gRPC_PLATFORM_MAC ON)
+ elseif(<%text>${CMAKE_SYSTEM_NAME}</%text> MATCHES "Android")
+ set(_gRPC_PLATFORM_ANDROID ON)
else()
set(_gRPC_PLATFORM_POSIX ON)
endif()
@@ -168,6 +171,8 @@
if(_gRPC_PLATFORM_MAC)
set(_gRPC_ALLTARGETS_LIBRARIES <%text>${CMAKE_DL_LIBS}</%text> m pthread)
+ elseif(_gRPC_PLATFORM_ANDROID)
+ set(_gRPC_ALLTARGETS_LIBRARIES <%text>${CMAKE_DL_LIBS}</%text> m)
elseif(UNIX)
set(_gRPC_ALLTARGETS_LIBRARIES <%text>${CMAKE_DL_LIBS}</%text> rt m pthread)
endif()
@@ -304,6 +309,13 @@
${cc_binary(tgt)}
${get_platforms_condition_end(tgt.platforms)}\
endif (gRPC_BUILD_TESTS)
+ % elif tgt.build in ["protoc"]:
+ if (gRPC_BUILD_CODEGEN)
+ ${get_platforms_condition_begin(tgt.platforms)}\
+ ${cc_binary(tgt)}
+ ${cc_install(tgt)}
+ ${get_platforms_condition_end(tgt.platforms)}\
+ endif (gRPC_BUILD_CODEGEN)
% else:
${get_platforms_condition_begin(tgt.platforms)}\
${cc_binary(tgt)}
@@ -314,6 +326,9 @@
% endfor
<%def name="cc_library(lib)">
+ % if any(proto_re.match(src) for src in lib.src):
+ if (gRPC_BUILD_CODEGEN)
+ % endif
add_library(${lib.name}${' SHARED' if lib.get('dll', None) == 'only' else ''}
% for src in lib.src:
% if not proto_re.match(src):
@@ -376,6 +391,14 @@
% endfor
)
% endif
+ % if lib.name in ["gpr"]:
+ if (_gRPC_PLATFORM_ANDROID)
+ target_link_libraries(gpr
+ android
+ log
+ )
+ endif (_gRPC_PLATFORM_ANDROID)
+ % endif
% if len(lib.get('public_headers', [])) > 0:
foreach(_hdr
@@ -390,6 +413,9 @@
)
endforeach()
% endif
+ % if any(proto_re.match(src) for src in lib.src):
+ endif (gRPC_BUILD_CODEGEN)
+ % endif
</%def>
<%def name="cc_binary(tgt)">