Tamas Berghammer | d798a7d | 2016-06-21 13:58:18 +0100 | [diff] [blame] | 1 | %YAML 1.2 |
| 2 | --- | |
| 3 | # GRPC global cmake file |
| 4 | # This currently builds C and C++ code. |
| 5 | # This file has been automatically generated from a template file. |
| 6 | # Please look at the templates directory instead. |
| 7 | # This file can be regenerated from the template by running |
| 8 | # tools/buildgen/generate_projects.sh |
Nicolas "Pixel" Noble | b360c8a | 2016-07-02 00:54:28 +0200 | [diff] [blame] | 9 | # |
Jan Tattermusch | 4d5c310 | 2017-06-07 10:23:56 +0200 | [diff] [blame] | 10 | # Copyright 2015 gRPC authors. |
Tamas Berghammer | d798a7d | 2016-06-21 13:58:18 +0100 | [diff] [blame] | 11 | # |
Jan Tattermusch | 4d5c310 | 2017-06-07 10:23:56 +0200 | [diff] [blame] | 12 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 13 | # you may not use this file except in compliance with the License. |
| 14 | # You may obtain a copy of the License at |
Tamas Berghammer | d798a7d | 2016-06-21 13:58:18 +0100 | [diff] [blame] | 15 | # |
Jan Tattermusch | 4d5c310 | 2017-06-07 10:23:56 +0200 | [diff] [blame] | 16 | # http://www.apache.org/licenses/LICENSE-2.0 |
Tamas Berghammer | d798a7d | 2016-06-21 13:58:18 +0100 | [diff] [blame] | 17 | # |
Jan Tattermusch | 4d5c310 | 2017-06-07 10:23:56 +0200 | [diff] [blame] | 18 | # Unless required by applicable law or agreed to in writing, software |
| 19 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 20 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 21 | # See the License for the specific language governing permissions and |
| 22 | # limitations under the License. |
Tamas Berghammer | d798a7d | 2016-06-21 13:58:18 +0100 | [diff] [blame] | 23 | |
| 24 | <%! |
Yuchen Zeng | e02cbeb | 2017-01-19 16:33:30 -0800 | [diff] [blame] | 25 | |
Jan Tattermusch | cc64168 | 2017-01-17 11:59:31 +0100 | [diff] [blame] | 26 | import re |
Yuchen Zeng | e02cbeb | 2017-01-19 16:33:30 -0800 | [diff] [blame] | 27 | |
Jan Tattermusch | cc64168 | 2017-01-17 11:59:31 +0100 | [diff] [blame] | 28 | proto_re = re.compile('(.*)\\.proto') |
Yuchen Zeng | e02cbeb | 2017-01-19 16:33:30 -0800 | [diff] [blame] | 29 | |
Jan Tattermusch | cc64168 | 2017-01-17 11:59:31 +0100 | [diff] [blame] | 30 | def proto_replace_ext(filename, ext): |
| 31 | m = proto_re.match(filename) |
| 32 | if not m: |
| 33 | return filename |
| 34 | return '${_gRPC_PROTO_GENS_DIR}/' + m.group(1) + ext |
Yuchen Zeng | e02cbeb | 2017-01-19 16:33:30 -0800 | [diff] [blame] | 35 | |
Tamas Berghammer | d798a7d | 2016-06-21 13:58:18 +0100 | [diff] [blame] | 36 | def get_deps(target_dict): |
| 37 | deps = [] |
Alexander Polcyn | 18caf6d | 2018-06-06 12:06:52 -0700 | [diff] [blame] | 38 | if target_dict.get('baselib', False) or target_dict['name'] == 'address_sorting': |
Konstantin Podsvirov | 5baf725 | 2016-07-27 16:25:37 +0300 | [diff] [blame] | 39 | deps.append("${_gRPC_BASELIB_LIBRARIES}") |
Tamas Berghammer | d798a7d | 2016-06-21 13:58:18 +0100 | [diff] [blame] | 40 | if target_dict.get('build', None) in ['protoc']: |
Konstantin Podsvirov | 5baf725 | 2016-07-27 16:25:37 +0300 | [diff] [blame] | 41 | deps.append("${_gRPC_PROTOBUF_PROTOC_LIBRARIES}") |
Tamas Berghammer | d798a7d | 2016-06-21 13:58:18 +0100 | [diff] [blame] | 42 | if target_dict.get('secure', False): |
Konstantin Podsvirov | 5baf725 | 2016-07-27 16:25:37 +0300 | [diff] [blame] | 43 | deps.append("${_gRPC_SSL_LIBRARIES}") |
Jan Tattermusch | 438c0b5 | 2017-01-23 11:24:53 +0100 | [diff] [blame] | 44 | if target_dict.language == 'c++': |
Konstantin Podsvirov | 5baf725 | 2016-07-27 16:25:37 +0300 | [diff] [blame] | 45 | deps.append("${_gRPC_PROTOBUF_LIBRARIES}") |
Jan Tattermusch | 807693b | 2017-06-12 10:15:27 +0200 | [diff] [blame] | 46 | if target_dict['name'] in ['grpc', 'grpc_cronet', 'grpc_unsecure']: |
Konstantin Podsvirov | 5baf725 | 2016-07-27 16:25:37 +0300 | [diff] [blame] | 47 | deps.append("${_gRPC_ZLIB_LIBRARIES}") |
Yuchen Zeng | 8076d2b | 2016-08-25 13:23:13 -0700 | [diff] [blame] | 48 | deps.append("${_gRPC_CARES_LIBRARIES}") |
Alexander Polcyn | 690dde6 | 2017-10-18 00:20:33 -0700 | [diff] [blame] | 49 | deps.append("${_gRPC_ADDRESS_SORTING_LIBRARIES}") |
Jan Tattermusch | 438c0b5 | 2017-01-23 11:24:53 +0100 | [diff] [blame] | 50 | deps.append("${_gRPC_ALLTARGETS_LIBRARIES}") |
Tamas Berghammer | d798a7d | 2016-06-21 13:58:18 +0100 | [diff] [blame] | 51 | for d in target_dict.get('deps', []): |
Jan Tattermusch | 586f719 | 2018-01-16 17:57:17 +0100 | [diff] [blame] | 52 | if d == 'benchmark': |
| 53 | deps.append("${_gRPC_BENCHMARK_LIBRARIES}") |
| 54 | else: |
| 55 | deps.append(d) |
Jan Tattermusch | 0a1701f | 2017-01-17 19:44:08 +0100 | [diff] [blame] | 56 | if target_dict.build == 'test' and target_dict.language == 'c++': |
| 57 | deps.append("${_gRPC_GFLAGS_LIBRARIES}") |
Tamas Berghammer | d798a7d | 2016-06-21 13:58:18 +0100 | [diff] [blame] | 58 | return deps |
Yuchen Zeng | 1492f6c | 2017-02-02 12:42:54 -0800 | [diff] [blame] | 59 | |
Jan Tattermusch | 438c0b5 | 2017-01-23 11:24:53 +0100 | [diff] [blame] | 60 | def get_platforms_condition_begin(platforms): |
| 61 | if all(platform in platforms for platform in ['linux', 'mac', 'posix', 'windows']): |
| 62 | return '' |
| 63 | cond = ' OR '.join(['_gRPC_PLATFORM_%s' % platform.upper() for platform in platforms]) |
| 64 | return 'if(%s)\n' % cond |
Yuchen Zeng | 1492f6c | 2017-02-02 12:42:54 -0800 | [diff] [blame] | 65 | |
Jan Tattermusch | 438c0b5 | 2017-01-23 11:24:53 +0100 | [diff] [blame] | 66 | def get_platforms_condition_end(platforms): |
| 67 | if not get_platforms_condition_begin(platforms): |
| 68 | return '' |
| 69 | return 'endif()\n' |
Tamas Berghammer | d798a7d | 2016-06-21 13:58:18 +0100 | [diff] [blame] | 70 | %> |
| 71 | |
| 72 | cmake_minimum_required(VERSION 2.8) |
| 73 | |
Tamas Berghammer | df6a44c | 2016-06-22 13:38:55 +0100 | [diff] [blame] | 74 | set(PACKAGE_NAME "grpc") |
Craig Tiller | 83c4789 | 2016-09-13 11:14:43 -0700 | [diff] [blame] | 75 | set(PACKAGE_VERSION "${settings.cpp_version}") |
Tamas Berghammer | df6a44c | 2016-06-22 13:38:55 +0100 | [diff] [blame] | 76 | set(PACKAGE_STRING "<%text>${PACKAGE_NAME} ${PACKAGE_VERSION}</%text>") |
| 77 | set(PACKAGE_TARNAME "<%text>${PACKAGE_NAME}-${PACKAGE_VERSION}</%text>") |
| 78 | set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") |
| 79 | project(<%text>${PACKAGE_NAME}</%text> C CXX) |
Craig Tiller | 4e86af7 | 2017-10-10 23:24:14 -0700 | [diff] [blame] | 80 | |
Stefan Hacker | 471a5dc | 2018-01-14 13:38:20 +0100 | [diff] [blame] | 81 | set(gRPC_INSTALL_BINDIR "bin" CACHE STRING "Installation directory for executables") |
| 82 | set(gRPC_INSTALL_LIBDIR "lib" CACHE STRING "Installation directory for libraries") |
| 83 | set(gRPC_INSTALL_INCLUDEDIR "include" CACHE STRING "Installation directory for headers") |
| 84 | set(gRPC_INSTALL_CMAKEDIR "lib/cmake/<%text>${PACKAGE_NAME}</%text>" CACHE STRING "Installation directory for cmake config files") |
Jan Tattermusch | a3992d2 | 2018-05-09 17:37:27 +0200 | [diff] [blame] | 85 | set(gRPC_INSTALL_SHAREDIR "share/grpc" CACHE STRING "Installation directory for root certificates") |
Tamas Berghammer | df6a44c | 2016-06-22 13:38:55 +0100 | [diff] [blame] | 86 | |
Jan Tattermusch | 0a1701f | 2017-01-17 19:44:08 +0100 | [diff] [blame] | 87 | # Options |
| 88 | option(gRPC_BUILD_TESTS "Build tests" OFF) |
Eric Gribkoff | a32a4c5 | 2018-01-25 13:16:41 -0800 | [diff] [blame] | 89 | option(gRPC_BUILD_CODEGEN "Build codegen" ON) |
Jozef Izso | bbdee16 | 2018-04-26 17:39:17 +0200 | [diff] [blame] | 90 | option(gRPC_BUILD_CSHARP_EXT "Build C# extensions" ON) |
Tamas Berghammer | df6a44c | 2016-06-22 13:38:55 +0100 | [diff] [blame] | 91 | |
Alex Merry | c17eb5c | 2017-05-15 21:17:29 +0100 | [diff] [blame] | 92 | set(gRPC_INSTALL_default ON) |
Alex Merry | a65f006 | 2017-05-15 22:59:37 +0100 | [diff] [blame] | 93 | if (NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) |
| 94 | # Disable gRPC_INSTALL by default if building as a submodule |
| 95 | set(gRPC_INSTALL_default OFF) |
Arkadiy Shapkin | 40beb37 | 2016-08-17 14:42:36 +0300 | [diff] [blame] | 96 | endif() |
Alex Merry | c17eb5c | 2017-05-15 21:17:29 +0100 | [diff] [blame] | 97 | set(gRPC_INSTALL <%text>${gRPC_INSTALL_default}</%text> CACHE BOOL |
| 98 | "Generate installation target: gRPC_ZLIB_PROVIDER, gRPC_CARES_PROVIDER, gRPC_SSL_PROVIDER and gRPC_PROTOBUF_PROVIDER must all be \"package\"") |
Arkadiy Shapkin | 40beb37 | 2016-08-17 14:42:36 +0300 | [diff] [blame] | 99 | |
Jan Tattermusch | 586f719 | 2018-01-16 17:57:17 +0100 | [diff] [blame] | 100 | # Providers for third-party dependencies (gRPC_*_PROVIDER properties): |
| 101 | # "module": build the dependency using sources from git submodule (under third_party) |
| 102 | # "package": use cmake's find_package functionality to locate a pre-installed dependency |
| 103 | |
Konstantin Podsvirov | 5baf725 | 2016-07-27 16:25:37 +0300 | [diff] [blame] | 104 | set(gRPC_ZLIB_PROVIDER "module" CACHE STRING "Provider of zlib library") |
| 105 | set_property(CACHE gRPC_ZLIB_PROVIDER PROPERTY STRINGS "module" "package") |
Tamas Berghammer | d798a7d | 2016-06-21 13:58:18 +0100 | [diff] [blame] | 106 | |
Yuchen Zeng | 8076d2b | 2016-08-25 13:23:13 -0700 | [diff] [blame] | 107 | set(gRPC_CARES_PROVIDER "module" CACHE STRING "Provider of c-ares library") |
| 108 | set_property(CACHE gRPC_CARES_PROVIDER PROPERTY STRINGS "module" "package") |
| 109 | |
Konstantin Podsvirov | 5baf725 | 2016-07-27 16:25:37 +0300 | [diff] [blame] | 110 | set(gRPC_SSL_PROVIDER "module" CACHE STRING "Provider of ssl library") |
| 111 | set_property(CACHE gRPC_SSL_PROVIDER PROPERTY STRINGS "module" "package") |
Tamas Berghammer | a72712e | 2016-07-06 10:30:25 +0100 | [diff] [blame] | 112 | |
Konstantin Podsvirov | 5baf725 | 2016-07-27 16:25:37 +0300 | [diff] [blame] | 113 | set(gRPC_PROTOBUF_PROVIDER "module" CACHE STRING "Provider of protobuf library") |
| 114 | set_property(CACHE gRPC_PROTOBUF_PROVIDER PROPERTY STRINGS "module" "package") |
Tamas Berghammer | d798a7d | 2016-06-21 13:58:18 +0100 | [diff] [blame] | 115 | |
Kamil Skalski | 6ba7d53 | 2017-06-28 19:42:26 +0100 | [diff] [blame] | 116 | set(gRPC_PROTOBUF_PACKAGE_TYPE "" CACHE STRING "Algorithm for searching protobuf package") |
| 117 | set_property(CACHE gRPC_PROTOBUF_PACKAGE_TYPE PROPERTY STRINGS "CONFIG" "MODULE") |
| 118 | |
Jan Tattermusch | 0a1701f | 2017-01-17 19:44:08 +0100 | [diff] [blame] | 119 | set(gRPC_GFLAGS_PROVIDER "module" CACHE STRING "Provider of gflags library") |
| 120 | set_property(CACHE gRPC_GFLAGS_PROVIDER PROPERTY STRINGS "module" "package") |
Yuchen Zeng | e02cbeb | 2017-01-19 16:33:30 -0800 | [diff] [blame] | 121 | |
Jan Tattermusch | 438c0b5 | 2017-01-23 11:24:53 +0100 | [diff] [blame] | 122 | set(gRPC_BENCHMARK_PROVIDER "module" CACHE STRING "Provider of benchmark library") |
| 123 | set_property(CACHE gRPC_BENCHMARK_PROVIDER PROPERTY STRINGS "module" "package") |
Yuchen Zeng | 1492f6c | 2017-02-02 12:42:54 -0800 | [diff] [blame] | 124 | |
Konstantin Podsvirov | 5baf725 | 2016-07-27 16:25:37 +0300 | [diff] [blame] | 125 | set(gRPC_USE_PROTO_LITE OFF CACHE BOOL "Use the protobuf-lite library") |
Tamas Berghammer | d798a7d | 2016-06-21 13:58:18 +0100 | [diff] [blame] | 126 | |
Jan Tattermusch | 438c0b5 | 2017-01-23 11:24:53 +0100 | [diff] [blame] | 127 | if(UNIX) |
| 128 | if(<%text>${CMAKE_SYSTEM_NAME}</%text> MATCHES "Linux") |
| 129 | set(_gRPC_PLATFORM_LINUX ON) |
| 130 | elseif(<%text>${CMAKE_SYSTEM_NAME}</%text> MATCHES "Darwin") |
| 131 | set(_gRPC_PLATFORM_MAC ON) |
Eric Gribkoff | a32a4c5 | 2018-01-25 13:16:41 -0800 | [diff] [blame] | 132 | elseif(<%text>${CMAKE_SYSTEM_NAME}</%text> MATCHES "Android") |
| 133 | set(_gRPC_PLATFORM_ANDROID ON) |
Jan Tattermusch | 438c0b5 | 2017-01-23 11:24:53 +0100 | [diff] [blame] | 134 | else() |
| 135 | set(_gRPC_PLATFORM_POSIX ON) |
| 136 | endif() |
| 137 | endif() |
| 138 | if(WIN32) |
| 139 | set(_gRPC_PLATFORM_WINDOWS ON) |
| 140 | endif() |
Yuchen Zeng | f39cf46 | 2017-02-10 13:01:25 -0800 | [diff] [blame] | 141 | |
Jan Tattermusch | c09656c | 2017-01-27 13:36:24 +0100 | [diff] [blame] | 142 | ## Some libraries are shared even with BUILD_SHARED_LIBRARIES=OFF |
| 143 | set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) |
Yihua Zhang | 04fb58e | 2018-03-08 06:49:24 -0800 | [diff] [blame] | 144 | |
| 145 | add_definitions(-DPB_FIELD_16BIT) |
Jan Tattermusch | 438c0b5 | 2017-01-23 11:24:53 +0100 | [diff] [blame] | 146 | |
Arkadiy Shapkin | 40beb37 | 2016-08-17 14:42:36 +0300 | [diff] [blame] | 147 | if (MSVC) |
Jan Tattermusch | 5140791 | 2017-02-02 20:44:22 +0100 | [diff] [blame] | 148 | include(cmake/msvc_static_runtime.cmake) |
Jan Tattermusch | 3aab96f | 2017-01-11 16:12:46 +0100 | [diff] [blame] | 149 | add_definitions(-D_WIN32_WINNT=0x600 -D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS -D_WINSOCK_DEPRECATED_NO_WARNINGS) |
Jan Tattermusch | 3aab96f | 2017-01-11 16:12:46 +0100 | [diff] [blame] | 150 | # needed to compile protobuf |
| 151 | add_definitions(/wd4065 /wd4506) |
| 152 | # TODO(jtattermusch): revisit C4267 occurrences throughout the code |
| 153 | add_definitions(/wd4267) |
Jan Tattermusch | 07d2092 | 2017-08-23 16:05:43 +0200 | [diff] [blame] | 154 | # TODO(jtattermusch): needed to build boringssl with VS2017, revisit later |
| 155 | add_definitions(/wd4987 /wd4774 /wd4819 /wd4996 /wd4619) |
Arkadiy Shapkin | 40beb37 | 2016-08-17 14:42:36 +0300 | [diff] [blame] | 156 | endif() |
| 157 | |
Konstantin Podsvirov | 5baf725 | 2016-07-27 16:25:37 +0300 | [diff] [blame] | 158 | if (gRPC_USE_PROTO_LITE) |
| 159 | set(_gRPC_PROTOBUF_LIBRARY_NAME "libprotobuf-lite") |
Tamas Berghammer | 2391156 | 2016-07-27 15:24:05 +0100 | [diff] [blame] | 160 | add_definitions("-DGRPC_USE_PROTO_LITE") |
| 161 | else() |
Konstantin Podsvirov | 5baf725 | 2016-07-27 16:25:37 +0300 | [diff] [blame] | 162 | set(_gRPC_PROTOBUF_LIBRARY_NAME "libprotobuf") |
| 163 | endif() |
| 164 | |
Jan Tattermusch | f38b152 | 2017-12-19 14:05:41 -0800 | [diff] [blame] | 165 | include(cmake/zlib.cmake) |
| 166 | include(cmake/cares.cmake) |
| 167 | include(cmake/protobuf.cmake) |
| 168 | include(cmake/ssl.cmake) |
| 169 | include(cmake/gflags.cmake) |
| 170 | include(cmake/benchmark.cmake) |
Alexander Polcyn | 5de3478 | 2018-01-19 14:48:19 -0800 | [diff] [blame] | 171 | include(cmake/address_sorting.cmake) |
David Garcia Quintas | 7f94702 | 2018-06-04 16:45:06 -0700 | [diff] [blame] | 172 | include(cmake/nanopb.cmake) |
Alexander Polcyn | 690dde6 | 2017-10-18 00:20:33 -0700 | [diff] [blame] | 173 | |
Konstantin Podsvirov | 5baf725 | 2016-07-27 16:25:37 +0300 | [diff] [blame] | 174 | if(NOT MSVC) |
Jan Tattermusch | 438c0b5 | 2017-01-23 11:24:53 +0100 | [diff] [blame] | 175 | set(CMAKE_C_FLAGS "<%text>${CMAKE_C_FLAGS}</%text> -std=c99") |
Konstantin Podsvirov | 5baf725 | 2016-07-27 16:25:37 +0300 | [diff] [blame] | 176 | set(CMAKE_CXX_FLAGS "<%text>${CMAKE_CXX_FLAGS}</%text> -std=c++11") |
| 177 | endif() |
| 178 | |
Mehrdad Afshari | 79ec0ff | 2017-04-19 03:14:26 -0700 | [diff] [blame] | 179 | if(_gRPC_PLATFORM_MAC) |
| 180 | set(_gRPC_ALLTARGETS_LIBRARIES <%text>${CMAKE_DL_LIBS}</%text> m pthread) |
Eric Gribkoff | a32a4c5 | 2018-01-25 13:16:41 -0800 | [diff] [blame] | 181 | elseif(_gRPC_PLATFORM_ANDROID) |
| 182 | set(_gRPC_ALLTARGETS_LIBRARIES <%text>${CMAKE_DL_LIBS}</%text> m) |
Mehrdad Afshari | 79ec0ff | 2017-04-19 03:14:26 -0700 | [diff] [blame] | 183 | elseif(UNIX) |
| 184 | set(_gRPC_ALLTARGETS_LIBRARIES <%text>${CMAKE_DL_LIBS}</%text> rt m pthread) |
Jan Tattermusch | 438c0b5 | 2017-01-23 11:24:53 +0100 | [diff] [blame] | 185 | endif() |
| 186 | |
Konstantin Podsvirov | 5baf725 | 2016-07-27 16:25:37 +0300 | [diff] [blame] | 187 | if(WIN32 AND MSVC) |
| 188 | set(_gRPC_BASELIB_LIBRARIES wsock32 ws2_32) |
Tamas Berghammer | 2391156 | 2016-07-27 15:24:05 +0100 | [diff] [blame] | 189 | endif() |
| 190 | |
Jan Tattermusch | cc64168 | 2017-01-17 11:59:31 +0100 | [diff] [blame] | 191 | # Create directory for generated .proto files |
| 192 | set(_gRPC_PROTO_GENS_DIR <%text>${CMAKE_BINARY_DIR}/gens</%text>) |
| 193 | file(MAKE_DIRECTORY <%text>${_gRPC_PROTO_GENS_DIR}</%text>) |
Yuchen Zeng | e02cbeb | 2017-01-19 16:33:30 -0800 | [diff] [blame] | 194 | |
Jan Tattermusch | cc64168 | 2017-01-17 11:59:31 +0100 | [diff] [blame] | 195 | # protobuf_generate_grpc_cpp |
| 196 | # -------------------------- |
| 197 | # |
| 198 | # Add custom commands to process ``.proto`` files to C++ using protoc and |
| 199 | # GRPC plugin:: |
| 200 | # |
| 201 | # protobuf_generate_grpc_cpp [<ARGN>...] |
| 202 | # |
| 203 | # ``ARGN`` |
| 204 | # ``.proto`` files |
| 205 | # |
| 206 | function(protobuf_generate_grpc_cpp) |
| 207 | if(NOT ARGN) |
| 208 | message(SEND_ERROR "Error: PROTOBUF_GENERATE_GRPC_CPP() called without any proto files") |
| 209 | return() |
| 210 | endif() |
Yuchen Zeng | e02cbeb | 2017-01-19 16:33:30 -0800 | [diff] [blame] | 211 | |
Jan Tattermusch | 586f719 | 2018-01-16 17:57:17 +0100 | [diff] [blame] | 212 | set(_protobuf_include_path -I . -I <%text>${_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR}</%text>) |
Jan Tattermusch | cc64168 | 2017-01-17 11:59:31 +0100 | [diff] [blame] | 213 | foreach(FIL <%text>${ARGN}</%text>) |
| 214 | get_filename_component(ABS_FIL <%text>${FIL}</%text> ABSOLUTE) |
| 215 | get_filename_component(FIL_WE <%text>${FIL}</%text> NAME_WE) |
Jan Tattermusch | ecc457b | 2017-04-07 14:06:16 +0200 | [diff] [blame] | 216 | file(RELATIVE_PATH REL_FIL <%text>${CMAKE_CURRENT_SOURCE_DIR}</%text> <%text>${ABS_FIL}</%text>) |
Jan Tattermusch | cc64168 | 2017-01-17 11:59:31 +0100 | [diff] [blame] | 217 | get_filename_component(REL_DIR <%text>${REL_FIL}</%text> DIRECTORY) |
| 218 | set(RELFIL_WE "<%text>${REL_DIR}/${FIL_WE}</%text>") |
Yuchen Zeng | e02cbeb | 2017-01-19 16:33:30 -0800 | [diff] [blame] | 219 | |
Jan Tattermusch | cc64168 | 2017-01-17 11:59:31 +0100 | [diff] [blame] | 220 | add_custom_command( |
| 221 | OUTPUT <%text>"${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.grpc.pb.cc"</%text> |
| 222 | <%text>"${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.grpc.pb.h"</%text> |
Mahak Mukhi | 78ca0d1 | 2017-04-26 13:39:46 -0700 | [diff] [blame] | 223 | <%text>"${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}_mock.grpc.pb.h"</%text> |
Jan Tattermusch | cc64168 | 2017-01-17 11:59:31 +0100 | [diff] [blame] | 224 | <%text>"${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.pb.cc"</%text> |
| 225 | <%text>"${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.pb.h"</%text> |
Jan Tattermusch | 210f2a5 | 2017-08-24 17:51:47 +0200 | [diff] [blame] | 226 | COMMAND <%text>${_gRPC_PROTOBUF_PROTOC_EXECUTABLE}</%text> |
Mahak Mukhi | 78ca0d1 | 2017-04-26 13:39:46 -0700 | [diff] [blame] | 227 | ARGS --grpc_out=<%text>generate_mock_code=true:${_gRPC_PROTO_GENS_DIR}</%text> |
Jan Tattermusch | cc64168 | 2017-01-17 11:59:31 +0100 | [diff] [blame] | 228 | --cpp_out=<%text>${_gRPC_PROTO_GENS_DIR}</%text> |
| 229 | --plugin=protoc-gen-grpc=$<TARGET_FILE:grpc_cpp_plugin> |
| 230 | <%text>${_protobuf_include_path}</%text> |
| 231 | <%text>${REL_FIL}</%text> |
| 232 | DEPENDS <%text>${ABS_FIL}</%text> <%text>${_gRPC_PROTOBUF_PROTOC}</%text> grpc_cpp_plugin |
Jan Tattermusch | ecc457b | 2017-04-07 14:06:16 +0200 | [diff] [blame] | 233 | WORKING_DIRECTORY <%text>${CMAKE_CURRENT_SOURCE_DIR}</%text> |
Jan Tattermusch | cc64168 | 2017-01-17 11:59:31 +0100 | [diff] [blame] | 234 | COMMENT "Running gRPC C++ protocol buffer compiler on <%text>${FIL}</%text>" |
| 235 | VERBATIM) |
Yuchen Zeng | e02cbeb | 2017-01-19 16:33:30 -0800 | [diff] [blame] | 236 | |
Mahak Mukhi | 78ca0d1 | 2017-04-26 13:39:46 -0700 | [diff] [blame] | 237 | <%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> |
Jan Tattermusch | cc64168 | 2017-01-17 11:59:31 +0100 | [diff] [blame] | 238 | endforeach() |
| 239 | endfunction() |
Yuchen Zeng | e02cbeb | 2017-01-19 16:33:30 -0800 | [diff] [blame] | 240 | |
Jan Tattermusch | 438c0b5 | 2017-01-23 11:24:53 +0100 | [diff] [blame] | 241 | add_custom_target(plugins |
| 242 | DEPENDS |
| 243 | % for tgt in targets: |
| 244 | % if tgt.build == 'protoc': |
| 245 | ${tgt.name} |
| 246 | % endif |
| 247 | % endfor |
| 248 | ) |
Yuchen Zeng | 1492f6c | 2017-02-02 12:42:54 -0800 | [diff] [blame] | 249 | |
Jan Tattermusch | 438c0b5 | 2017-01-23 11:24:53 +0100 | [diff] [blame] | 250 | add_custom_target(tools_c |
| 251 | DEPENDS |
| 252 | % for tgt in targets: |
| 253 | % if tgt.build == 'tool' and not tgt.language == 'c++': |
| 254 | ${tgt.name} |
| 255 | % endif |
| 256 | % endfor |
| 257 | ) |
Yuchen Zeng | 1492f6c | 2017-02-02 12:42:54 -0800 | [diff] [blame] | 258 | |
Jan Tattermusch | 438c0b5 | 2017-01-23 11:24:53 +0100 | [diff] [blame] | 259 | add_custom_target(tools_cxx |
| 260 | DEPENDS |
| 261 | % for tgt in targets: |
| 262 | % if tgt.build == 'tool' and tgt.language == 'c++': |
| 263 | ${tgt.name} |
| 264 | % endif |
| 265 | % endfor |
| 266 | ) |
Yuchen Zeng | 1492f6c | 2017-02-02 12:42:54 -0800 | [diff] [blame] | 267 | |
Jan Tattermusch | 438c0b5 | 2017-01-23 11:24:53 +0100 | [diff] [blame] | 268 | add_custom_target(tools |
| 269 | DEPENDS tools_c tools_cxx) |
Yuchen Zeng | 1492f6c | 2017-02-02 12:42:54 -0800 | [diff] [blame] | 270 | |
Jan Tattermusch | 438c0b5 | 2017-01-23 11:24:53 +0100 | [diff] [blame] | 271 | if (gRPC_BUILD_TESTS) |
| 272 | add_custom_target(buildtests_c) |
| 273 | % for tgt in targets: |
| 274 | % if tgt.build == 'test' and not tgt.language == 'c++' and not tgt.get('external_deps', None) and not tgt.boringssl: |
| 275 | ${get_platforms_condition_begin(tgt.platforms)}\ |
| 276 | add_dependencies(buildtests_c ${tgt.name}) |
| 277 | ${get_platforms_condition_end(tgt.platforms)}\ |
| 278 | % endif |
| 279 | % endfor |
Yuchen Zeng | 1492f6c | 2017-02-02 12:42:54 -0800 | [diff] [blame] | 280 | |
Jan Tattermusch | 438c0b5 | 2017-01-23 11:24:53 +0100 | [diff] [blame] | 281 | add_custom_target(buildtests_cxx) |
| 282 | % for tgt in targets: |
| 283 | % if tgt.build == 'test' and tgt.language == 'c++' and not tgt.get('external_deps', None) and not tgt.boringssl: |
| 284 | ${get_platforms_condition_begin(tgt.platforms)}\ |
| 285 | add_dependencies(buildtests_cxx ${tgt.name}) |
| 286 | ${get_platforms_condition_end(tgt.platforms)}\ |
| 287 | % endif |
| 288 | % endfor |
Yuchen Zeng | 1492f6c | 2017-02-02 12:42:54 -0800 | [diff] [blame] | 289 | |
Jan Tattermusch | 438c0b5 | 2017-01-23 11:24:53 +0100 | [diff] [blame] | 290 | add_custom_target(buildtests |
| 291 | DEPENDS buildtests_c buildtests_cxx) |
| 292 | endif (gRPC_BUILD_TESTS) |
Yuchen Zeng | 1492f6c | 2017-02-02 12:42:54 -0800 | [diff] [blame] | 293 | |
Tamas Berghammer | d798a7d | 2016-06-21 13:58:18 +0100 | [diff] [blame] | 294 | % for lib in libs: |
Jan Tattermusch | 438c0b5 | 2017-01-23 11:24:53 +0100 | [diff] [blame] | 295 | % if lib.build in ["all", "protoc", "tool", "test", "private"] and not lib.boringssl: |
Jan Tattermusch | 0a1701f | 2017-01-17 19:44:08 +0100 | [diff] [blame] | 296 | % if not lib.get('build_system', []) or 'cmake' in lib.get('build_system', []): |
Jan Tattermusch | 3fc14dc | 2017-12-14 01:03:37 +0100 | [diff] [blame] | 297 | % if not lib.name in ['ares', 'benchmark', 'z']: # we build these using CMake instead |
Jan Tattermusch | 0a1701f | 2017-01-17 19:44:08 +0100 | [diff] [blame] | 298 | % if lib.build in ["test", "private"]: |
| 299 | if (gRPC_BUILD_TESTS) |
| 300 | ${cc_library(lib)} |
| 301 | endif (gRPC_BUILD_TESTS) |
Jozef Izso | bbdee16 | 2018-04-26 17:39:17 +0200 | [diff] [blame] | 302 | % elif lib.name in ['grpc_csharp_ext']: |
| 303 | if (gRPC_BUILD_CSHARP_EXT) |
| 304 | ${cc_library(lib)} |
| 305 | ${cc_install(lib)} |
| 306 | endif (gRPC_BUILD_CSHARP_EXT) |
Jan Tattermusch | 0a1701f | 2017-01-17 19:44:08 +0100 | [diff] [blame] | 307 | % else: |
Jan Tattermusch | cc64168 | 2017-01-17 11:59:31 +0100 | [diff] [blame] | 308 | ${cc_library(lib)} |
Vijay Pai | c4cc740 | 2018-03-28 11:25:37 -0700 | [diff] [blame] | 309 | % if not lib.build in ["tool"]: |
Jan Tattermusch | cc64168 | 2017-01-17 11:59:31 +0100 | [diff] [blame] | 310 | ${cc_install(lib)} |
Jan Tattermusch | af7b87f | 2017-01-12 09:41:03 +0100 | [diff] [blame] | 311 | % endif |
Tamas Berghammer | d798a7d | 2016-06-21 13:58:18 +0100 | [diff] [blame] | 312 | % endif |
Tamas Berghammer | d798a7d | 2016-06-21 13:58:18 +0100 | [diff] [blame] | 313 | % endif |
Jan Tattermusch | 438c0b5 | 2017-01-23 11:24:53 +0100 | [diff] [blame] | 314 | % endif |
Vijay Pai | c4cc740 | 2018-03-28 11:25:37 -0700 | [diff] [blame] | 315 | % endif |
Tamas Berghammer | d798a7d | 2016-06-21 13:58:18 +0100 | [diff] [blame] | 316 | % endfor |
| 317 | |
| 318 | % for tgt in targets: |
Jan Tattermusch | 438c0b5 | 2017-01-23 11:24:53 +0100 | [diff] [blame] | 319 | % if tgt.build in ["all", "protoc", "tool", "test", "private"] and not tgt.boringssl: |
Jan Tattermusch | 0a1701f | 2017-01-17 19:44:08 +0100 | [diff] [blame] | 320 | % if tgt.build in ["test", "private"]: |
| 321 | if (gRPC_BUILD_TESTS) |
Jan Tattermusch | 438c0b5 | 2017-01-23 11:24:53 +0100 | [diff] [blame] | 322 | ${get_platforms_condition_begin(tgt.platforms)}\ |
Jan Tattermusch | 0a1701f | 2017-01-17 19:44:08 +0100 | [diff] [blame] | 323 | ${cc_binary(tgt)} |
Jan Tattermusch | 438c0b5 | 2017-01-23 11:24:53 +0100 | [diff] [blame] | 324 | ${get_platforms_condition_end(tgt.platforms)}\ |
Jan Tattermusch | 0a1701f | 2017-01-17 19:44:08 +0100 | [diff] [blame] | 325 | endif (gRPC_BUILD_TESTS) |
Eric Gribkoff | a32a4c5 | 2018-01-25 13:16:41 -0800 | [diff] [blame] | 326 | % elif tgt.build in ["protoc"]: |
| 327 | if (gRPC_BUILD_CODEGEN) |
| 328 | ${get_platforms_condition_begin(tgt.platforms)}\ |
| 329 | ${cc_binary(tgt)} |
| 330 | ${cc_install(tgt)} |
| 331 | ${get_platforms_condition_end(tgt.platforms)}\ |
| 332 | endif (gRPC_BUILD_CODEGEN) |
Jan Tattermusch | 0a1701f | 2017-01-17 19:44:08 +0100 | [diff] [blame] | 333 | % else: |
Jan Tattermusch | 438c0b5 | 2017-01-23 11:24:53 +0100 | [diff] [blame] | 334 | ${get_platforms_condition_begin(tgt.platforms)}\ |
Tamas Berghammer | d798a7d | 2016-06-21 13:58:18 +0100 | [diff] [blame] | 335 | ${cc_binary(tgt)} |
Vijay Pai | c4cc740 | 2018-03-28 11:25:37 -0700 | [diff] [blame] | 336 | % if not tgt.build in ["tool"]: |
Konstantin Podsvirov | d2b8830 | 2016-07-27 23:43:47 +0300 | [diff] [blame] | 337 | ${cc_install(tgt)} |
Vijay Pai | c4cc740 | 2018-03-28 11:25:37 -0700 | [diff] [blame] | 338 | % endif |
Jan Tattermusch | 438c0b5 | 2017-01-23 11:24:53 +0100 | [diff] [blame] | 339 | ${get_platforms_condition_end(tgt.platforms)}\ |
Tamas Berghammer | d798a7d | 2016-06-21 13:58:18 +0100 | [diff] [blame] | 340 | % endif |
Jan Tattermusch | 0a1701f | 2017-01-17 19:44:08 +0100 | [diff] [blame] | 341 | % endif |
Tamas Berghammer | d798a7d | 2016-06-21 13:58:18 +0100 | [diff] [blame] | 342 | % endfor |
| 343 | |
| 344 | <%def name="cc_library(lib)"> |
Eric Gribkoff | a32a4c5 | 2018-01-25 13:16:41 -0800 | [diff] [blame] | 345 | % if any(proto_re.match(src) for src in lib.src): |
| 346 | if (gRPC_BUILD_CODEGEN) |
| 347 | % endif |
Jan Tattermusch | c09656c | 2017-01-27 13:36:24 +0100 | [diff] [blame] | 348 | add_library(${lib.name}${' SHARED' if lib.get('dll', None) == 'only' else ''} |
Tamas Berghammer | d798a7d | 2016-06-21 13:58:18 +0100 | [diff] [blame] | 349 | % for src in lib.src: |
Jan Tattermusch | cc64168 | 2017-01-17 11:59:31 +0100 | [diff] [blame] | 350 | % if not proto_re.match(src): |
Tamas Berghammer | d798a7d | 2016-06-21 13:58:18 +0100 | [diff] [blame] | 351 | ${src} |
Jan Tattermusch | cc64168 | 2017-01-17 11:59:31 +0100 | [diff] [blame] | 352 | % else: |
| 353 | ${proto_replace_ext(src, '.pb.cc')} |
| 354 | ${proto_replace_ext(src, '.grpc.pb.cc')} |
| 355 | ${proto_replace_ext(src, '.pb.h')} |
| 356 | ${proto_replace_ext(src, '.grpc.pb.h')} |
Mahak Mukhi | 78ca0d1 | 2017-04-26 13:39:46 -0700 | [diff] [blame] | 357 | % if src in ["src/proto/grpc/testing/compiler_test.proto", "src/proto/grpc/testing/echo.proto"]: |
| 358 | ${proto_replace_ext(src, '_mock.grpc.pb.h')} |
| 359 | % endif |
Jan Tattermusch | cc64168 | 2017-01-17 11:59:31 +0100 | [diff] [blame] | 360 | % endif |
Tamas Berghammer | d798a7d | 2016-06-21 13:58:18 +0100 | [diff] [blame] | 361 | % endfor |
| 362 | ) |
| 363 | |
Piotr Pietraszkiewicz | 9a61810 | 2017-02-06 19:30:09 +0100 | [diff] [blame] | 364 | if(WIN32 AND MSVC) |
| 365 | set_target_properties(${lib.name} PROPERTIES COMPILE_PDB_NAME "${lib.name}" |
| 366 | COMPILE_PDB_OUTPUT_DIRECTORY <%text>"${CMAKE_BINARY_DIR}</%text>" |
| 367 | ) |
| 368 | if (gRPC_INSTALL) |
| 369 | install(FILES <%text>${CMAKE_CURRENT_BINARY_DIR}/</%text>${lib.name}.pdb |
Jan Tattermusch | f691556 | 2017-06-23 14:53:55 +0200 | [diff] [blame] | 370 | DESTINATION <%text>${gRPC_INSTALL_LIBDIR}</%text> OPTIONAL |
Piotr Pietraszkiewicz | 9a61810 | 2017-02-06 19:30:09 +0100 | [diff] [blame] | 371 | ) |
| 372 | endif() |
| 373 | endif() |
| 374 | |
Jan Tattermusch | cc64168 | 2017-01-17 11:59:31 +0100 | [diff] [blame] | 375 | % for src in lib.src: |
| 376 | % if proto_re.match(src): |
| 377 | protobuf_generate_grpc_cpp( |
| 378 | ${src} |
| 379 | ) |
| 380 | % endif |
| 381 | % endfor |
Tamas Berghammer | d798a7d | 2016-06-21 13:58:18 +0100 | [diff] [blame] | 382 | |
| 383 | target_include_directories(${lib.name} |
Jan Tattermusch | f567ab0 | 2017-08-25 16:13:30 +0200 | [diff] [blame] | 384 | PUBLIC <%text>$<INSTALL_INTERFACE:${gRPC_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include></%text> |
Tamas Berghammer | d798a7d | 2016-06-21 13:58:18 +0100 | [diff] [blame] | 385 | PRIVATE <%text>${CMAKE_CURRENT_SOURCE_DIR}</%text> |
Jan Tattermusch | 86ef925 | 2017-12-14 02:42:34 +0100 | [diff] [blame] | 386 | PRIVATE <%text>${_gRPC_SSL_INCLUDE_DIR}</%text> |
Jan Tattermusch | 586f719 | 2018-01-16 17:57:17 +0100 | [diff] [blame] | 387 | PRIVATE <%text>${_gRPC_PROTOBUF_INCLUDE_DIR}</%text> |
| 388 | PRIVATE <%text>${_gRPC_ZLIB_INCLUDE_DIR}</%text> |
| 389 | PRIVATE <%text>${_gRPC_BENCHMARK_INCLUDE_DIR}</%text> |
| 390 | PRIVATE <%text>${_gRPC_CARES_INCLUDE_DIR}</%text> |
| 391 | PRIVATE <%text>${_gRPC_GFLAGS_INCLUDE_DIR}</%text> |
Alexander Polcyn | 5de3478 | 2018-01-19 14:48:19 -0800 | [diff] [blame] | 392 | PRIVATE <%text>${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}</%text> |
David Garcia Quintas | 7f94702 | 2018-06-04 16:45:06 -0700 | [diff] [blame] | 393 | PRIVATE <%text>${_gRPC_NANOPB_INCLUDE_DIR}</%text> |
Jan Tattermusch | 0a1701f | 2017-01-17 19:44:08 +0100 | [diff] [blame] | 394 | % if lib.build in ['test', 'private'] and lib.language == 'c++': |
Ken Payson | 975b510 | 2017-03-30 17:38:40 -0700 | [diff] [blame] | 395 | PRIVATE third_party/googletest/googletest/include |
| 396 | PRIVATE third_party/googletest/googletest |
Mahak Mukhi | 78ca0d1 | 2017-04-26 13:39:46 -0700 | [diff] [blame] | 397 | PRIVATE third_party/googletest/googlemock/include |
| 398 | PRIVATE third_party/googletest/googlemock |
Jan Tattermusch | 0a1701f | 2017-01-17 19:44:08 +0100 | [diff] [blame] | 399 | % endif |
Jan Tattermusch | 438c0b5 | 2017-01-23 11:24:53 +0100 | [diff] [blame] | 400 | % if lib.language == 'c++': |
Jan Tattermusch | cc64168 | 2017-01-17 11:59:31 +0100 | [diff] [blame] | 401 | PRIVATE <%text>${_gRPC_PROTO_GENS_DIR}</%text> |
| 402 | % endif |
Tamas Berghammer | d798a7d | 2016-06-21 13:58:18 +0100 | [diff] [blame] | 403 | ) |
| 404 | |
| 405 | % if len(get_deps(lib)) > 0: |
| 406 | target_link_libraries(${lib.name} |
| 407 | % for dep in get_deps(lib): |
| 408 | ${dep} |
| 409 | % endfor |
| 410 | ) |
| 411 | % endif |
Eric Gribkoff | a32a4c5 | 2018-01-25 13:16:41 -0800 | [diff] [blame] | 412 | % if lib.name in ["gpr"]: |
| 413 | if (_gRPC_PLATFORM_ANDROID) |
| 414 | target_link_libraries(gpr |
| 415 | android |
| 416 | log |
| 417 | ) |
| 418 | endif (_gRPC_PLATFORM_ANDROID) |
| 419 | % endif |
Konstantin Podsvirov | d2b8830 | 2016-07-27 23:43:47 +0300 | [diff] [blame] | 420 | |
| 421 | % if len(lib.get('public_headers', [])) > 0: |
| 422 | foreach(_hdr |
| 423 | % for hdr in lib.get('public_headers', []): |
| 424 | ${hdr} |
| 425 | % endfor |
| 426 | ) |
| 427 | string(REPLACE "include/" "" _path <%text>${_hdr}</%text>) |
| 428 | get_filename_component(_path <%text>${_path}</%text> PATH) |
| 429 | install(FILES <%text>${_hdr}</%text> |
Jan Tattermusch | f691556 | 2017-06-23 14:53:55 +0200 | [diff] [blame] | 430 | DESTINATION "<%text>${gRPC_INSTALL_INCLUDEDIR}/${_path}</%text>" |
Konstantin Podsvirov | d2b8830 | 2016-07-27 23:43:47 +0300 | [diff] [blame] | 431 | ) |
| 432 | endforeach() |
| 433 | % endif |
Eric Gribkoff | a32a4c5 | 2018-01-25 13:16:41 -0800 | [diff] [blame] | 434 | % if any(proto_re.match(src) for src in lib.src): |
| 435 | endif (gRPC_BUILD_CODEGEN) |
| 436 | % endif |
Tamas Berghammer | d798a7d | 2016-06-21 13:58:18 +0100 | [diff] [blame] | 437 | </%def> |
| 438 | |
| 439 | <%def name="cc_binary(tgt)"> |
| 440 | add_executable(${tgt.name} |
| 441 | % for src in tgt.src: |
Jan Tattermusch | 438c0b5 | 2017-01-23 11:24:53 +0100 | [diff] [blame] | 442 | % if not proto_re.match(src): |
Tamas Berghammer | d798a7d | 2016-06-21 13:58:18 +0100 | [diff] [blame] | 443 | ${src} |
Jan Tattermusch | 438c0b5 | 2017-01-23 11:24:53 +0100 | [diff] [blame] | 444 | % else: |
| 445 | ${proto_replace_ext(src, '.pb.cc')} |
| 446 | ${proto_replace_ext(src, '.grpc.pb.cc')} |
| 447 | ${proto_replace_ext(src, '.pb.h')} |
| 448 | ${proto_replace_ext(src, '.grpc.pb.h')} |
| 449 | % endif |
Tamas Berghammer | d798a7d | 2016-06-21 13:58:18 +0100 | [diff] [blame] | 450 | % endfor |
Jan Tattermusch | 0a1701f | 2017-01-17 19:44:08 +0100 | [diff] [blame] | 451 | % if tgt.build == 'test' and tgt.language == 'c++': |
Ken Payson | 975b510 | 2017-03-30 17:38:40 -0700 | [diff] [blame] | 452 | third_party/googletest/googletest/src/gtest-all.cc |
Mahak Mukhi | 78ca0d1 | 2017-04-26 13:39:46 -0700 | [diff] [blame] | 453 | third_party/googletest/googlemock/src/gmock-all.cc |
Jan Tattermusch | 0a1701f | 2017-01-17 19:44:08 +0100 | [diff] [blame] | 454 | % endif |
Tamas Berghammer | d798a7d | 2016-06-21 13:58:18 +0100 | [diff] [blame] | 455 | ) |
| 456 | |
Jan Tattermusch | 438c0b5 | 2017-01-23 11:24:53 +0100 | [diff] [blame] | 457 | % for src in tgt.src: |
| 458 | % if proto_re.match(src): |
| 459 | protobuf_generate_grpc_cpp( |
| 460 | ${src} |
| 461 | ) |
| 462 | % endif |
| 463 | % endfor |
Tamas Berghammer | d798a7d | 2016-06-21 13:58:18 +0100 | [diff] [blame] | 464 | |
| 465 | target_include_directories(${tgt.name} |
| 466 | PRIVATE <%text>${CMAKE_CURRENT_SOURCE_DIR}</%text> |
| 467 | PRIVATE <%text>${CMAKE_CURRENT_SOURCE_DIR}</%text>/include |
Jan Tattermusch | 86ef925 | 2017-12-14 02:42:34 +0100 | [diff] [blame] | 468 | PRIVATE <%text>${_gRPC_SSL_INCLUDE_DIR}</%text> |
Jan Tattermusch | 586f719 | 2018-01-16 17:57:17 +0100 | [diff] [blame] | 469 | PRIVATE <%text>${_gRPC_PROTOBUF_INCLUDE_DIR}</%text> |
| 470 | PRIVATE <%text>${_gRPC_ZLIB_INCLUDE_DIR}</%text> |
| 471 | PRIVATE <%text>${_gRPC_BENCHMARK_INCLUDE_DIR}</%text> |
| 472 | PRIVATE <%text>${_gRPC_CARES_INCLUDE_DIR}</%text> |
| 473 | PRIVATE <%text>${_gRPC_GFLAGS_INCLUDE_DIR}</%text> |
Alexander Polcyn | 5de3478 | 2018-01-19 14:48:19 -0800 | [diff] [blame] | 474 | PRIVATE <%text>${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}</%text> |
David Garcia Quintas | 7f94702 | 2018-06-04 16:45:06 -0700 | [diff] [blame] | 475 | PRIVATE <%text>${_gRPC_NANOPB_INCLUDE_DIR}</%text> |
Jan Tattermusch | 0a1701f | 2017-01-17 19:44:08 +0100 | [diff] [blame] | 476 | % if tgt.build in ['test', 'private'] and tgt.language == 'c++': |
Ken Payson | 975b510 | 2017-03-30 17:38:40 -0700 | [diff] [blame] | 477 | PRIVATE third_party/googletest/googletest/include |
| 478 | PRIVATE third_party/googletest/googletest |
Mahak Mukhi | 78ca0d1 | 2017-04-26 13:39:46 -0700 | [diff] [blame] | 479 | PRIVATE third_party/googletest/googlemock/include |
| 480 | PRIVATE third_party/googletest/googlemock |
Jan Tattermusch | 0a1701f | 2017-01-17 19:44:08 +0100 | [diff] [blame] | 481 | % endif |
Jan Tattermusch | 438c0b5 | 2017-01-23 11:24:53 +0100 | [diff] [blame] | 482 | % if tgt.language == 'c++': |
| 483 | PRIVATE <%text>${_gRPC_PROTO_GENS_DIR}</%text> |
| 484 | % endif |
Tamas Berghammer | d798a7d | 2016-06-21 13:58:18 +0100 | [diff] [blame] | 485 | ) |
| 486 | |
| 487 | % if len(get_deps(tgt)) > 0: |
| 488 | target_link_libraries(${tgt.name} |
| 489 | % for dep in get_deps(tgt): |
| 490 | ${dep} |
| 491 | % endfor |
| 492 | ) |
| 493 | % endif |
| 494 | </%def> |
| 495 | |
Konstantin Podsvirov | d2b8830 | 2016-07-27 23:43:47 +0300 | [diff] [blame] | 496 | <%def name="cc_install(tgt)"> |
Arkadiy Shapkin | 40beb37 | 2016-08-17 14:42:36 +0300 | [diff] [blame] | 497 | if (gRPC_INSTALL) |
| 498 | install(TARGETS ${tgt.name} EXPORT gRPCTargets |
Jan Tattermusch | f691556 | 2017-06-23 14:53:55 +0200 | [diff] [blame] | 499 | RUNTIME DESTINATION <%text>${gRPC_INSTALL_BINDIR}</%text> |
| 500 | LIBRARY DESTINATION <%text>${gRPC_INSTALL_LIBDIR}</%text> |
| 501 | ARCHIVE DESTINATION <%text>${gRPC_INSTALL_LIBDIR}</%text> |
Arkadiy Shapkin | 40beb37 | 2016-08-17 14:42:36 +0300 | [diff] [blame] | 502 | ) |
| 503 | endif() |
Konstantin Podsvirov | d2b8830 | 2016-07-27 23:43:47 +0300 | [diff] [blame] | 504 | </%def> |
| 505 | |
Alex Merry | b5984fa | 2017-05-15 21:04:16 +0100 | [diff] [blame] | 506 | if (gRPC_INSTALL) |
| 507 | install(EXPORT gRPCTargets |
Jan Tattermusch | f691556 | 2017-06-23 14:53:55 +0200 | [diff] [blame] | 508 | DESTINATION <%text>${gRPC_INSTALL_CMAKEDIR}</%text> |
Alex Merry | b5984fa | 2017-05-15 21:04:16 +0100 | [diff] [blame] | 509 | NAMESPACE gRPC:: |
| 510 | ) |
| 511 | endif() |
| 512 | |
Konstantin Podsvirov | d2b8830 | 2016-07-27 23:43:47 +0300 | [diff] [blame] | 513 | foreach(_config gRPCConfig gRPCConfigVersion) |
Jan Tattermusch | 9d1d052 | 2017-08-25 14:26:47 +0200 | [diff] [blame] | 514 | configure_file(cmake/<%text>${_config}</%text>.cmake.in |
Konstantin Podsvirov | d2b8830 | 2016-07-27 23:43:47 +0300 | [diff] [blame] | 515 | <%text>${_config}</%text>.cmake @ONLY) |
| 516 | install(FILES <%text>${CMAKE_CURRENT_BINARY_DIR}/${_config}</%text>.cmake |
Jan Tattermusch | f691556 | 2017-06-23 14:53:55 +0200 | [diff] [blame] | 517 | DESTINATION <%text>${gRPC_INSTALL_CMAKEDIR}</%text> |
Konstantin Podsvirov | d2b8830 | 2016-07-27 23:43:47 +0300 | [diff] [blame] | 518 | ) |
| 519 | endforeach() |
Jan Tattermusch | a3992d2 | 2018-05-09 17:37:27 +0200 | [diff] [blame] | 520 | |
| 521 | install(FILES <%text>${CMAKE_CURRENT_SOURCE_DIR}/etc/roots.pem</%text> |
| 522 | DESTINATION <%text>${gRPC_INSTALL_SHAREDIR}</%text>) |