|
|
|
@ -1,13 +1,17 @@
|
|
|
|
|
set(protobuf_USE_STATIC_LIBS ON)
|
|
|
|
|
if(BUILD_LITE)
|
|
|
|
|
set(protobuf_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -fPIC -fvisibility=hidden -D_FORTIFY_SOURCE=2 -O2")
|
|
|
|
|
set(protobuf_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -fPIC \
|
|
|
|
|
-fvisibility=hidden -D_FORTIFY_SOURCE=2 -O2")
|
|
|
|
|
else()
|
|
|
|
|
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
|
|
|
|
set(protobuf_CXXFLAGS "-fstack-protector-all -Wno-uninitialized -Wno-unused-parameter -fPIC -fvisibility=hidden -D_FORTIFY_SOURCE=2 -O2")
|
|
|
|
|
set(protobuf_CXXFLAGS "-fstack-protector-all -Wno-uninitialized -Wno-unused-parameter -fPIC \
|
|
|
|
|
-fvisibility=hidden -D_FORTIFY_SOURCE=2 -O2")
|
|
|
|
|
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
|
|
|
|
set(protobuf_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -fPIC -fvisibility=hidden -D_FORTIFY_SOURCE=2 -O2")
|
|
|
|
|
set(protobuf_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -fPIC \
|
|
|
|
|
-fvisibility=hidden -D_FORTIFY_SOURCE=2 -O2")
|
|
|
|
|
else()
|
|
|
|
|
set(protobuf_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(protobuf_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()
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
@ -69,7 +73,6 @@ function(ms_protobuf_generate c_var h_var)
|
|
|
|
|
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()
|
|
|
|
|
|
|
|
|
|
function(ms_protobuf_generate_py c_var h_var py_var)
|
|
|
|
@ -100,8 +103,10 @@ function(ms_protobuf_generate_py c_var h_var py_var)
|
|
|
|
|
COMMAND protobuf::protoc -I${file_dir} --cpp_out=${CMAKE_BINARY_DIR}/proto ${abs_file}
|
|
|
|
|
COMMAND protobuf::protoc -I${file_dir} --python_out=${CMAKE_BINARY_DIR}/proto ${abs_file}
|
|
|
|
|
COMMAND protobuf::protoc -I${file_dir} --python_out=${CMAKE_BINARY_DIR}/proto ${abs_file}
|
|
|
|
|
COMMAND perl -pi.bak -e "s/import (.+_pb2.*)/from . import \\1/" "${CMAKE_BINARY_DIR}/proto/${file_name}_pb2.py"
|
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/proto/${file_name}_pb2.py" "${PROJECT_SOURCE_DIR}/mindspore/train/"
|
|
|
|
|
COMMAND perl -pi.bak -e "s/import (.+_pb2.*)/from . import \\1/"
|
|
|
|
|
"${CMAKE_BINARY_DIR}/proto/${file_name}_pb2.py"
|
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/proto/${file_name}_pb2.py"
|
|
|
|
|
"${PROJECT_SOURCE_DIR}/mindspore/train/"
|
|
|
|
|
DEPENDS protobuf::protoc ${abs_file}
|
|
|
|
|
COMMENT "Running C++ protocol buffer compiler on ${file}" VERBATIM)
|
|
|
|
|
else()
|
|
|
|
@ -114,7 +119,8 @@ function(ms_protobuf_generate_py c_var h_var py_var)
|
|
|
|
|
COMMAND protobuf::protoc -I${file_dir} --cpp_out=${CMAKE_BINARY_DIR}/proto ${abs_file}
|
|
|
|
|
COMMAND protobuf::protoc -I${file_dir} --python_out=${CMAKE_BINARY_DIR}/proto ${abs_file}
|
|
|
|
|
COMMAND protobuf::protoc -I${file_dir} --python_out=${CMAKE_BINARY_DIR}/proto ${abs_file}
|
|
|
|
|
COMMAND perl -pi -e "s/import (.+_pb2.*)/from . import \\1/" "${CMAKE_BINARY_DIR}/proto/${file_name}_pb2.py"
|
|
|
|
|
COMMAND perl -pi -e "s/import (.+_pb2.*)/from . import \\1/"
|
|
|
|
|
"${CMAKE_BINARY_DIR}/proto/${file_name}_pb2.py"
|
|
|
|
|
COMMAND cp "${CMAKE_BINARY_DIR}/proto/${file_name}_pb2.py" "${PROJECT_SOURCE_DIR}/mindspore/train/"
|
|
|
|
|
DEPENDS protobuf::protoc ${abs_file}
|
|
|
|
|
COMMENT "Running C++ protocol buffer compiler on ${file}" VERBATIM)
|
|
|
|
@ -124,5 +130,4 @@ function(ms_protobuf_generate_py c_var h_var py_var)
|
|
|
|
|
set(${c_var} ${${c_var}} PARENT_SCOPE)
|
|
|
|
|
set(${h_var} ${${h_var}} PARENT_SCOPE)
|
|
|
|
|
set(${py_var} ${${py_var}} PARENT_SCOPE)
|
|
|
|
|
|
|
|
|
|
endfunction()
|
|
|
|
|