From d798a7d80e80ad1e57b08baec81b860c7f136c47 Mon Sep 17 00:00:00 2001 From: Tamas Berghammer Date: Tue, 21 Jun 2016 13:58:18 +0100 Subject: Generate a simple cmake build file This cmake file only builds the C and C++ code and all the third party dependencies with very few configuration options but it supports building on Linux and OSX as well as cross compiling. (tested {Linux, OSX} -> Android { arm, aarch64, x86 }) --- templates/CMakeLists.txt.template | 133 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 templates/CMakeLists.txt.template (limited to 'templates') diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template new file mode 100644 index 0000000000..00a37de3cb --- /dev/null +++ b/templates/CMakeLists.txt.template @@ -0,0 +1,133 @@ +%YAML 1.2 +--- | + # GRPC global cmake file + # This currently builds C and C++ code. + # This file has been automatically generated from a template file. + # Please look at the templates directory instead. + # This file can be regenerated from the template by running + # tools/buildgen/generate_projects.sh + + # Copyright 2015, Google Inc. + # All rights reserved. + # + # Redistribution and use in source and binary forms, with or without + # modification, are permitted provided that the following conditions are + # met: + # + # * Redistributions of source code must retain the above copyright + # notice, this list of conditions and the following disclaimer. + # * Redistributions in binary form must reproduce the above + # copyright notice, this list of conditions and the following disclaimer + # in the documentation and/or other materials provided with the + # distribution. + # * Neither the name of Google Inc. nor the names of its + # contributors may be used to endorse or promote products derived from + # this software without specific prior written permission. + # + # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + <%! + def get_deps(target_dict): + deps = [] + if target_dict.get('build', None) in ['protoc']: + deps.append("libprotoc") + if target_dict.get('secure', False): + deps = ["ssl"] + if target_dict['name'] in ['grpc++', 'grpc++_unsecure', 'grpc++_codegen_lib']: + deps.append("libprotobuf") + for d in target_dict.get('deps', []): + deps.append(d) + return deps + %> + + cmake_minimum_required(VERSION 2.8) + + if (NOT BORINGSSL_ROOT_DIR) + set(BORINGSSL_ROOT_DIR <%text>${CMAKE_CURRENT_SOURCE_DIR}/third_party/boringssl) + endif() + if (NOT PROTOBUF_ROOT_DIR) + set(PROTOBUF_ROOT_DIR <%text>${CMAKE_CURRENT_SOURCE_DIR}/third_party/protobuf) + endif() + if (NOT ZLIB_ROOT_DIR) + set(ZLIB_ROOT_DIR <%text>${CMAKE_CURRENT_SOURCE_DIR}/third_party/zlib) + endif() + + add_subdirectory(<%text>${BORINGSSL_ROOT_DIR} third_party/boringssl) + add_subdirectory(<%text>${PROTOBUF_ROOT_DIR}/cmake third_party/protobuf) + add_subdirectory(<%text>${ZLIB_ROOT_DIR} third_party/zlib) + + set(CMAKE_C_FLAGS "<%text>${CMAKE_C_FLAGS} -std=c11") + set(CMAKE_CXX_FLAGS "<%text>${CMAKE_CXX_FLAGS} -std=c++11") + + % for lib in libs: + % if lib.build in ["all", "protoc"]: + ${cc_library(lib)} + % endif + % endfor + + % for tgt in targets: + % if tgt.build == 'protoc': + ${cc_binary(tgt)} + % endif + % endfor + + <%def name="cc_library(lib)"> + add_library(${lib.name} + % for src in lib.src: + ${src} + % endfor + ) + + target_include_directories(${lib.name} + PRIVATE <%text>${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE <%text>${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE <%text>${BORINGSSL_ROOT_DIR}/include + PRIVATE <%text>${PROTOBUF_ROOT_DIR}/src + PRIVATE <%text>${ZLIB_ROOT_DIR} + PRIVATE <%text>${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib + ) + + % if len(get_deps(lib)) > 0: + target_link_libraries(${lib.name} + % for dep in get_deps(lib): + ${dep} + % endfor + ) + % endif + + + <%def name="cc_binary(tgt)"> + add_executable(${tgt.name} + % for src in tgt.src: + ${src} + % endfor + ) + + target_include_directories(${tgt.name} + PRIVATE <%text>${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE <%text>${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE <%text>${BORINGSSL_ROOT_DIR}/include + PRIVATE <%text>${PROTOBUF_ROOT_DIR}/src + PRIVATE <%text>${ZLIB_ROOT_DIR} + PRIVATE <%text>${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib + ) + + % if len(get_deps(tgt)) > 0: + target_link_libraries(${tgt.name} + % for dep in get_deps(tgt): + ${dep} + % endfor + ) + % endif + + -- cgit v1.2.3 From df6a44cd93ba069b6927006cd761b44921e6da41 Mon Sep 17 00:00:00 2001 From: Tamas Berghammer Date: Wed, 22 Jun 2016 13:38:55 +0100 Subject: Improve the generated cmake build files * Add project name and version number * Fix zlib dependency of grpc * Include more target (all, protoc, tool groups) --- CMakeLists.txt | 108 ++++++++++++++++++++++++++++++++++++-- templates/CMakeLists.txt.template | 21 +++++--- 2 files changed, 119 insertions(+), 10 deletions(-) (limited to 'templates') diff --git a/CMakeLists.txt b/CMakeLists.txt index 5bd48b78ea..a81517a6a0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,13 +38,20 @@ cmake_minimum_required(VERSION 2.8) -if (NOT BORINGSSL_ROOT_DIR) +set(PACKAGE_NAME "grpc") +set(PACKAGE_VERSION "0.15.0-dev") +set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") +set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") +set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") +project(${PACKAGE_NAME} C CXX) + +if(NOT BORINGSSL_ROOT_DIR) set(BORINGSSL_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/boringssl) endif() -if (NOT PROTOBUF_ROOT_DIR) +if(NOT PROTOBUF_ROOT_DIR) set(PROTOBUF_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/protobuf) endif() -if (NOT ZLIB_ROOT_DIR) +if(NOT ZLIB_ROOT_DIR) set(ZLIB_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/zlib) endif() @@ -52,7 +59,7 @@ add_subdirectory(${BORINGSSL_ROOT_DIR} third_party/boringssl) add_subdirectory(${PROTOBUF_ROOT_DIR}/cmake third_party/protobuf) add_subdirectory(${ZLIB_ROOT_DIR} third_party/zlib) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") @@ -313,6 +320,7 @@ target_include_directories(grpc target_link_libraries(grpc ssl + zlibstatic gpr ) @@ -831,6 +839,98 @@ target_link_libraries(grpc_csharp_ext +add_executable(gen_hpack_tables + tools/codegen/core/gen_hpack_tables.c +) + +target_include_directories(gen_hpack_tables + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${BORINGSSL_ROOT_DIR}/include + PRIVATE ${PROTOBUF_ROOT_DIR}/src + PRIVATE ${ZLIB_ROOT_DIR} + PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib +) + +target_link_libraries(gen_hpack_tables + gpr + grpc +) + + +add_executable(gen_legal_metadata_characters + tools/codegen/core/gen_legal_metadata_characters.c +) + +target_include_directories(gen_legal_metadata_characters + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${BORINGSSL_ROOT_DIR}/include + PRIVATE ${PROTOBUF_ROOT_DIR}/src + PRIVATE ${ZLIB_ROOT_DIR} + PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib +) + + + +add_executable(grpc_create_jwt + test/core/security/create_jwt.c +) + +target_include_directories(grpc_create_jwt + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${BORINGSSL_ROOT_DIR}/include + PRIVATE ${PROTOBUF_ROOT_DIR}/src + PRIVATE ${ZLIB_ROOT_DIR} + PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib +) + +target_link_libraries(grpc_create_jwt + ssl + grpc + gpr +) + + +add_executable(grpc_print_google_default_creds_token + test/core/security/print_google_default_creds_token.c +) + +target_include_directories(grpc_print_google_default_creds_token + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${BORINGSSL_ROOT_DIR}/include + PRIVATE ${PROTOBUF_ROOT_DIR}/src + PRIVATE ${ZLIB_ROOT_DIR} + PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib +) + +target_link_libraries(grpc_print_google_default_creds_token + grpc + gpr +) + + +add_executable(grpc_verify_jwt + test/core/security/verify_jwt.c +) + +target_include_directories(grpc_verify_jwt + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${BORINGSSL_ROOT_DIR}/include + PRIVATE ${PROTOBUF_ROOT_DIR}/src + PRIVATE ${ZLIB_ROOT_DIR} + PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib +) + +target_link_libraries(grpc_verify_jwt + grpc + gpr +) + + add_executable(grpc_cpp_plugin src/compiler/cpp_plugin.cc ) diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template index 00a37de3cb..06085eb722 100644 --- a/templates/CMakeLists.txt.template +++ b/templates/CMakeLists.txt.template @@ -45,6 +45,8 @@ deps = ["ssl"] if target_dict['name'] in ['grpc++', 'grpc++_unsecure', 'grpc++_codegen_lib']: deps.append("libprotobuf") + elif target_dict['name'] in ['grpc']: + deps.append("zlibstatic") for d in target_dict.get('deps', []): deps.append(d) return deps @@ -52,13 +54,20 @@ cmake_minimum_required(VERSION 2.8) - if (NOT BORINGSSL_ROOT_DIR) + set(PACKAGE_NAME "grpc") + set(PACKAGE_VERSION "${settings.core_version}") + set(PACKAGE_STRING "<%text>${PACKAGE_NAME} ${PACKAGE_VERSION}") + set(PACKAGE_TARNAME "<%text>${PACKAGE_NAME}-${PACKAGE_VERSION}") + set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") + project(<%text>${PACKAGE_NAME} C CXX) + + if(NOT BORINGSSL_ROOT_DIR) set(BORINGSSL_ROOT_DIR <%text>${CMAKE_CURRENT_SOURCE_DIR}/third_party/boringssl) endif() - if (NOT PROTOBUF_ROOT_DIR) + if(NOT PROTOBUF_ROOT_DIR) set(PROTOBUF_ROOT_DIR <%text>${CMAKE_CURRENT_SOURCE_DIR}/third_party/protobuf) endif() - if (NOT ZLIB_ROOT_DIR) + if(NOT ZLIB_ROOT_DIR) set(ZLIB_ROOT_DIR <%text>${CMAKE_CURRENT_SOURCE_DIR}/third_party/zlib) endif() @@ -66,17 +75,17 @@ add_subdirectory(<%text>${PROTOBUF_ROOT_DIR}/cmake third_party/protobuf) add_subdirectory(<%text>${ZLIB_ROOT_DIR} third_party/zlib) - set(CMAKE_C_FLAGS "<%text>${CMAKE_C_FLAGS} -std=c11") + set(CMAKE_C_FLAGS "<%text>${CMAKE_C_FLAGS} -std=c11") set(CMAKE_CXX_FLAGS "<%text>${CMAKE_CXX_FLAGS} -std=c++11") % for lib in libs: - % if lib.build in ["all", "protoc"]: + % if lib.build in ["all", "protoc", "tool"]: ${cc_library(lib)} % endif % endfor % for tgt in targets: - % if tgt.build == 'protoc': + % if tgt.build in ["all", "protoc", "tool"]: ${cc_binary(tgt)} % endif % endfor -- cgit v1.2.3 From b360c8acc7b53aabb2af7f76ddf7310f3d025acc Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Sat, 2 Jul 2016 00:54:28 +0200 Subject: Regenerating project files, and adding experimental disclaimer. --- CMakeLists.txt | 13 +++++++++++-- templates/CMakeLists.txt.template | 5 ++++- third_party/protobuf | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) (limited to 'templates') diff --git a/CMakeLists.txt b/CMakeLists.txt index a81517a6a0..9caf03191f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,10 @@ # Please look at the templates directory instead. # This file can be regenerated from the template by running # tools/buildgen/generate_projects.sh - +# +# Additionally, this is currently very experimental, and unsupported. +# Further work will happen on that file. +# # Copyright 2015, Google Inc. # All rights reserved. # @@ -39,7 +42,7 @@ cmake_minimum_required(VERSION 2.8) set(PACKAGE_NAME "grpc") -set(PACKAGE_VERSION "0.15.0-dev") +set(PACKAGE_VERSION "0.16.0-dev") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") @@ -142,6 +145,7 @@ add_library(grpc src/core/lib/iomgr/endpoint_pair_posix.c src/core/lib/iomgr/endpoint_pair_windows.c src/core/lib/iomgr/error.c + src/core/lib/iomgr/ev_epoll_linux.c src/core/lib/iomgr/ev_poll_and_epoll_posix.c src/core/lib/iomgr/ev_poll_posix.c src/core/lib/iomgr/ev_posix.c @@ -152,6 +156,7 @@ add_library(grpc src/core/lib/iomgr/iomgr_posix.c src/core/lib/iomgr/iomgr_windows.c src/core/lib/iomgr/load_file.c + src/core/lib/iomgr/network_status_tracker.c src/core/lib/iomgr/polling_entity.c src/core/lib/iomgr/pollset_set_windows.c src/core/lib/iomgr/pollset_windows.c @@ -345,6 +350,7 @@ add_library(grpc_cronet src/core/lib/iomgr/endpoint_pair_posix.c src/core/lib/iomgr/endpoint_pair_windows.c src/core/lib/iomgr/error.c + src/core/lib/iomgr/ev_epoll_linux.c src/core/lib/iomgr/ev_poll_and_epoll_posix.c src/core/lib/iomgr/ev_poll_posix.c src/core/lib/iomgr/ev_posix.c @@ -355,6 +361,7 @@ add_library(grpc_cronet src/core/lib/iomgr/iomgr_posix.c src/core/lib/iomgr/iomgr_windows.c src/core/lib/iomgr/load_file.c + src/core/lib/iomgr/network_status_tracker.c src/core/lib/iomgr/polling_entity.c src/core/lib/iomgr/pollset_set_windows.c src/core/lib/iomgr/pollset_windows.c @@ -525,6 +532,7 @@ add_library(grpc_unsecure src/core/lib/iomgr/endpoint_pair_posix.c src/core/lib/iomgr/endpoint_pair_windows.c src/core/lib/iomgr/error.c + src/core/lib/iomgr/ev_epoll_linux.c src/core/lib/iomgr/ev_poll_and_epoll_posix.c src/core/lib/iomgr/ev_poll_posix.c src/core/lib/iomgr/ev_posix.c @@ -535,6 +543,7 @@ add_library(grpc_unsecure src/core/lib/iomgr/iomgr_posix.c src/core/lib/iomgr/iomgr_windows.c src/core/lib/iomgr/load_file.c + src/core/lib/iomgr/network_status_tracker.c src/core/lib/iomgr/polling_entity.c src/core/lib/iomgr/pollset_set_windows.c src/core/lib/iomgr/pollset_windows.c diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template index 06085eb722..76299cb21b 100644 --- a/templates/CMakeLists.txt.template +++ b/templates/CMakeLists.txt.template @@ -6,7 +6,10 @@ # Please look at the templates directory instead. # This file can be regenerated from the template by running # tools/buildgen/generate_projects.sh - + # + # Additionally, this is currently very experimental, and unsupported. + # Further work will happen on that file. + # # Copyright 2015, Google Inc. # All rights reserved. # diff --git a/third_party/protobuf b/third_party/protobuf index d4d13a4349..3470b6895a 160000 --- a/third_party/protobuf +++ b/third_party/protobuf @@ -1 +1 @@ -Subproject commit d4d13a4349e4e59d67f311185ddcc1890d956d7a +Subproject commit 3470b6895aa659b7559ed678e029a5338e535f14 -- cgit v1.2.3