Improve the generated cmake build files

* Add project name and version number
* Fix zlib dependency of grpc
* Include more target (all, protoc, tool groups)
pull/6997/head
Tamas Berghammer 9 years ago
parent c82324fa49
commit df6a44cd93
  1. 108
      CMakeLists.txt
  2. 21
      templates/CMakeLists.txt.template

@ -38,13 +38,20 @@
cmake_minimum_required(VERSION 2.8) 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) set(BORINGSSL_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/boringssl)
endif() endif()
if (NOT PROTOBUF_ROOT_DIR) if(NOT PROTOBUF_ROOT_DIR)
set(PROTOBUF_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/protobuf) set(PROTOBUF_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/protobuf)
endif() endif()
if (NOT ZLIB_ROOT_DIR) if(NOT ZLIB_ROOT_DIR)
set(ZLIB_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/zlib) set(ZLIB_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/zlib)
endif() endif()
@ -52,7 +59,7 @@ add_subdirectory(${BORINGSSL_ROOT_DIR} third_party/boringssl)
add_subdirectory(${PROTOBUF_ROOT_DIR}/cmake third_party/protobuf) add_subdirectory(${PROTOBUF_ROOT_DIR}/cmake third_party/protobuf)
add_subdirectory(${ZLIB_ROOT_DIR} third_party/zlib) 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") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
@ -313,6 +320,7 @@ target_include_directories(grpc
target_link_libraries(grpc target_link_libraries(grpc
ssl ssl
zlibstatic
gpr 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 add_executable(grpc_cpp_plugin
src/compiler/cpp_plugin.cc src/compiler/cpp_plugin.cc
) )

@ -45,6 +45,8 @@
deps = ["ssl"] deps = ["ssl"]
if target_dict['name'] in ['grpc++', 'grpc++_unsecure', 'grpc++_codegen_lib']: if target_dict['name'] in ['grpc++', 'grpc++_unsecure', 'grpc++_codegen_lib']:
deps.append("libprotobuf") deps.append("libprotobuf")
elif target_dict['name'] in ['grpc']:
deps.append("zlibstatic")
for d in target_dict.get('deps', []): for d in target_dict.get('deps', []):
deps.append(d) deps.append(d)
return deps return deps
@ -52,13 +54,20 @@
cmake_minimum_required(VERSION 2.8) 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}</%text>")
set(PACKAGE_TARNAME "<%text>${PACKAGE_NAME}-${PACKAGE_VERSION}</%text>")
set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/")
project(<%text>${PACKAGE_NAME}</%text> C CXX)
if(NOT BORINGSSL_ROOT_DIR)
set(BORINGSSL_ROOT_DIR <%text>${CMAKE_CURRENT_SOURCE_DIR}</%text>/third_party/boringssl) set(BORINGSSL_ROOT_DIR <%text>${CMAKE_CURRENT_SOURCE_DIR}</%text>/third_party/boringssl)
endif() endif()
if (NOT PROTOBUF_ROOT_DIR) if(NOT PROTOBUF_ROOT_DIR)
set(PROTOBUF_ROOT_DIR <%text>${CMAKE_CURRENT_SOURCE_DIR}</%text>/third_party/protobuf) set(PROTOBUF_ROOT_DIR <%text>${CMAKE_CURRENT_SOURCE_DIR}</%text>/third_party/protobuf)
endif() endif()
if (NOT ZLIB_ROOT_DIR) if(NOT ZLIB_ROOT_DIR)
set(ZLIB_ROOT_DIR <%text>${CMAKE_CURRENT_SOURCE_DIR}</%text>/third_party/zlib) set(ZLIB_ROOT_DIR <%text>${CMAKE_CURRENT_SOURCE_DIR}</%text>/third_party/zlib)
endif() endif()
@ -66,17 +75,17 @@
add_subdirectory(<%text>${PROTOBUF_ROOT_DIR}</%text>/cmake third_party/protobuf) add_subdirectory(<%text>${PROTOBUF_ROOT_DIR}</%text>/cmake third_party/protobuf)
add_subdirectory(<%text>${ZLIB_ROOT_DIR}</%text> third_party/zlib) add_subdirectory(<%text>${ZLIB_ROOT_DIR}</%text> third_party/zlib)
set(CMAKE_C_FLAGS "<%text>${CMAKE_C_FLAGS}</%text> -std=c11") set(CMAKE_C_FLAGS "<%text>${CMAKE_C_FLAGS}</%text> -std=c11")
set(CMAKE_CXX_FLAGS "<%text>${CMAKE_CXX_FLAGS}</%text> -std=c++11") set(CMAKE_CXX_FLAGS "<%text>${CMAKE_CXX_FLAGS}</%text> -std=c++11")
% for lib in libs: % for lib in libs:
% if lib.build in ["all", "protoc"]: % if lib.build in ["all", "protoc", "tool"]:
${cc_library(lib)} ${cc_library(lib)}
% endif % endif
% endfor % endfor
% for tgt in targets: % for tgt in targets:
% if tgt.build == 'protoc': % if tgt.build in ["all", "protoc", "tool"]:
${cc_binary(tgt)} ${cc_binary(tgt)}
% endif % endif
% endfor % endfor

Loading…
Cancel
Save