|
|
|
@@ -1,32 +1,35 @@ |
|
|
|
set(grpc_USE_STATIC_LIBS ON) |
|
|
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") |
|
|
|
set(grpc_CXXFLAGS "-fstack-protector-all -Wno-uninitialized -Wno-unused-parameter -fPIC -fvisibility=hidden -D_FORTIFY_SOURCE=2 -O2") |
|
|
|
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows") |
|
|
|
set(grpc_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -fPIC -fvisibility=hidden -D_FORTIFY_SOURCE=2 -O2") |
|
|
|
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") |
|
|
|
set(grpc_CXXFLAGS "-fstack-protector-all -Wno-uninitialized -Wno-unused-parameter -fPIC -fvisibility=hidden " |
|
|
|
"-D_FORTIFY_SOURCE=2 -O2") |
|
|
|
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows") |
|
|
|
set(grpc_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -fPIC -fvisibility=hidden " |
|
|
|
"-D_FORTIFY_SOURCE=2 -O2") |
|
|
|
else() |
|
|
|
set(grpc_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -fPIC -fvisibility=hidden -D_FORTIFY_SOURCE=2 -D_GLIBCXX_USE_CXX11_ABI=0 -O2") |
|
|
|
set(grpc_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -fPIC -fvisibility=hidden " |
|
|
|
"-D_FORTIFY_SOURCE=2 -D_GLIBCXX_USE_CXX11_ABI=0 -O2") |
|
|
|
endif() |
|
|
|
|
|
|
|
set(grpc_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack") |
|
|
|
|
|
|
|
|
|
|
|
if (EXISTS ${protobuf_ROOT}/lib64) |
|
|
|
set(_FINDPACKAGE_PROTOBUF_CONFIG_DIR "${protobuf_ROOT}/lib64/cmake/protobuf") |
|
|
|
if(EXISTS ${protobuf_ROOT}/lib64) |
|
|
|
set(_FINDPACKAGE_PROTOBUF_CONFIG_DIR "${protobuf_ROOT}/lib64/cmake/protobuf") |
|
|
|
else() |
|
|
|
set(_FINDPACKAGE_PROTOBUF_CONFIG_DIR "${protobuf_ROOT}/lib/cmake/protobuf") |
|
|
|
set(_FINDPACKAGE_PROTOBUF_CONFIG_DIR "${protobuf_ROOT}/lib/cmake/protobuf") |
|
|
|
endif() |
|
|
|
message("grpc using Protobuf_DIR : " ${_FINDPACKAGE_PROTOBUF_CONFIG_DIR}) |
|
|
|
|
|
|
|
if (EXISTS ${absl_ROOT}/lib64) |
|
|
|
set(_FINDPACKAGE_ABSL_CONFIG_DIR "${absl_ROOT}/lib64/cmake/absl") |
|
|
|
if(EXISTS ${absl_ROOT}/lib64) |
|
|
|
set(_FINDPACKAGE_ABSL_CONFIG_DIR "${absl_ROOT}/lib64/cmake/absl") |
|
|
|
else() |
|
|
|
set(_FINDPACKAGE_ABSL_CONFIG_DIR "${absl_ROOT}/lib/cmake/absl") |
|
|
|
set(_FINDPACKAGE_ABSL_CONFIG_DIR "${absl_ROOT}/lib/cmake/absl") |
|
|
|
endif() |
|
|
|
message("grpc using absl_DIR : " ${_FINDPACKAGE_ABSL_CONFIG_DIR}) |
|
|
|
|
|
|
|
set(_CMAKE_ARGS_OPENSSL_ROOT_DIR "") |
|
|
|
if (OPENSSL_ROOT_DIR) |
|
|
|
set(_CMAKE_ARGS_OPENSSL_ROOT_DIR "-DOPENSSL_ROOT_DIR:PATH=${OPENSSL_ROOT_DIR}") |
|
|
|
if(OPENSSL_ROOT_DIR) |
|
|
|
set(_CMAKE_ARGS_OPENSSL_ROOT_DIR "-DOPENSSL_ROOT_DIR:PATH=${OPENSSL_ROOT_DIR}") |
|
|
|
endif() |
|
|
|
|
|
|
|
mindspore_add_pkg(grpc |
|
|
|
@@ -57,54 +60,15 @@ add_library(mindspore_serving::grpc++ ALIAS grpc::grpc++) |
|
|
|
|
|
|
|
# link other grpc libs |
|
|
|
target_link_libraries(grpc::grpc++ INTERFACE grpc::grpc grpc::gpr grpc::upb grpc::address_sorting) |
|
|
|
set(GRPC_CPP_LIBS gRPC::grpc++_reflection gRPC::grpc++ gRPC::grpc gRPC::gpr gRPC::upb gRPC::address_sorting) |
|
|
|
|
|
|
|
# link built dependencies |
|
|
|
target_link_libraries(grpc::grpc++ INTERFACE mindspore_serving::z) |
|
|
|
target_link_libraries(grpc::grpc++ INTERFACE mindspore_serving::cares) |
|
|
|
target_link_libraries(grpc::grpc++ INTERFACE mindspore_serving::absl_strings mindspore_serving::absl_throw_delegate |
|
|
|
mindspore_serving::absl_raw_logging_internal mindspore_serving::absl_int128 mindspore_serving::absl_bad_optional_access) |
|
|
|
mindspore_serving::absl_raw_logging_internal mindspore_serving::absl_int128 |
|
|
|
mindspore_serving::absl_bad_optional_access) |
|
|
|
|
|
|
|
# link system openssl |
|
|
|
find_package(OpenSSL REQUIRED) |
|
|
|
target_link_libraries(grpc::grpc++ INTERFACE OpenSSL::SSL OpenSSL::Crypto) |
|
|
|
|
|
|
|
|
|
|
|
function(ms_grpc_generate c_var h_var) |
|
|
|
if(NOT ARGN) |
|
|
|
message(SEND_ERROR "Error: ms_grpc_generate() called without any proto files") |
|
|
|
return() |
|
|
|
endif() |
|
|
|
|
|
|
|
set(${c_var}) |
|
|
|
set(${h_var}) |
|
|
|
|
|
|
|
foreach(file ${ARGN}) |
|
|
|
get_filename_component(abs_file ${file} ABSOLUTE) |
|
|
|
get_filename_component(file_name ${file} NAME_WE) |
|
|
|
get_filename_component(file_dir ${abs_file} PATH) |
|
|
|
file(RELATIVE_PATH rel_path ${CMAKE_CURRENT_SOURCE_DIR} ${file_dir}) |
|
|
|
|
|
|
|
list(APPEND ${c_var} "${CMAKE_BINARY_DIR}/proto/${file_name}.pb.cc") |
|
|
|
list(APPEND ${h_var} "${CMAKE_BINARY_DIR}/proto/${file_name}.pb.h") |
|
|
|
list(APPEND ${c_var} "${CMAKE_BINARY_DIR}/proto/${file_name}.grpc.pb.cc") |
|
|
|
list(APPEND ${h_var} "${CMAKE_BINARY_DIR}/proto/${file_name}.grpc.pb.h") |
|
|
|
|
|
|
|
add_custom_command( |
|
|
|
OUTPUT "${CMAKE_BINARY_DIR}/proto/${file_name}.pb.cc" |
|
|
|
"${CMAKE_BINARY_DIR}/proto/${file_name}.pb.h" |
|
|
|
"${CMAKE_BINARY_DIR}/proto/${file_name}.grpc.pb.cc" |
|
|
|
"${CMAKE_BINARY_DIR}/proto/${file_name}.grpc.pb.h" |
|
|
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} |
|
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/proto" |
|
|
|
COMMAND protobuf::protoc --version |
|
|
|
COMMAND protobuf::protoc -I${file_dir} --cpp_out=${CMAKE_BINARY_DIR}/proto |
|
|
|
--grpc_out=${CMAKE_BINARY_DIR}/proto --plugin=protoc-gen-grpc=$<TARGET_FILE:grpc::grpc_cpp_plugin> ${abs_file} |
|
|
|
DEPENDS protobuf::protoc grpc::grpc_cpp_plugin ${abs_file} |
|
|
|
COMMENT "Running C++ gRPC compiler on ${file}" VERBATIM) |
|
|
|
endforeach() |
|
|
|
|
|
|
|
set_source_files_properties(${${c_var}} ${${h_var}} PROPERTIES GENERATED TRUE) |
|
|
|
set(${c_var} ${${c_var}} PARENT_SCOPE) |
|
|
|
set(${h_var} ${${h_var}} PARENT_SCOPE) |
|
|
|
|
|
|
|
endfunction() |