forked from mindspore-Ecosystem/mindspore
!95 Modify cmake of protobuf
Merge pull request !95 from dengwentao/protobuf
This commit is contained in:
commit
7cec28526a
|
@ -1,22 +1,23 @@
|
|||
mindspore_add_pkg(protobuf
|
||||
VER 3.8.0
|
||||
HEAD_ONLY ./
|
||||
URL https://github.com/protocolbuffers/protobuf/archive/v3.8.0.tar.gz
|
||||
MD5 3d9e32700639618a4d2d342c99d4507a)
|
||||
|
||||
set(protobuf_BUILD_TESTS OFF CACHE BOOL "Disable protobuf test")
|
||||
set(protobuf_BUILD_SHARED_LIBS OFF CACHE BOOL "Gen shared library")
|
||||
set(protobuf_USE_STATIC_LIBS ON)
|
||||
set(protobuf_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -fPIC -fvisibility=hidden -D_FORTIFY_SOURCE=2 -O2")
|
||||
set(protobuf_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack")
|
||||
set(_ms_tmp_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
||||
|
||||
set(CMAKE_CXX_FLAGS ${_ms_tmp_CMAKE_CXX_FLAGS})
|
||||
string(REPLACE " -Wall" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
string(REPLACE " -Werror" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
add_subdirectory(${protobuf_DIRPATH}/cmake ${protobuf_DIRPATH}/build)
|
||||
|
||||
set(CMAKE_CXX_FLAGS ${_ms_tmp_CMAKE_CXX_FLAGS})
|
||||
mindspore_add_pkg(protobuf
|
||||
VER 3.8.0
|
||||
LIBS protobuf
|
||||
EXE protoc
|
||||
URL https://github.com/protocolbuffers/protobuf/archive/v3.8.0.tar.gz
|
||||
MD5 3d9e32700639618a4d2d342c99d4507a
|
||||
CMAKE_PATH cmake/
|
||||
CMAKE_OPTION -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_SHARED_LIBS=OFF)
|
||||
|
||||
set(PROTOBUF_LIBRARY protobuf::libprotobuf)
|
||||
include_directories(${protobuf_DIRPATH}/src)
|
||||
add_library(mindspore::protobuf ALIAS libprotobuf)
|
||||
include_directories(${protobuf_INC})
|
||||
add_library(mindspore::protobuf ALIAS protobuf::protobuf)
|
||||
set(CMAKE_CXX_FLAGS ${_ms_tmp_CMAKE_CXX_FLAGS})
|
||||
|
||||
function(ms_protobuf_generate c_var h_var)
|
||||
if(NOT ARGN)
|
||||
|
|
|
@ -192,10 +192,12 @@ set(MS_FIND_NO_DEFAULT_PATH ${MS_FIND_NO_DEFAULT_PATH} PARENT_SCOPE)
|
|||
function(mindspore_add_pkg pkg_name )
|
||||
|
||||
set(options )
|
||||
set(oneValueArgs URL MD5 GIT_REPOSITORY GIT_TAG VER EXE DIR HEAD_ONLY)
|
||||
set(oneValueArgs URL MD5 GIT_REPOSITORY GIT_TAG VER EXE DIR HEAD_ONLY CMAKE_PATH)
|
||||
set(multiValueArgs CMAKE_OPTION LIBS PRE_CONFIGURE_COMMAND CONFIGURE_COMMAND BUILD_OPTION INSTALL_INCS INSTALL_LIBS PATCHES)
|
||||
cmake_parse_arguments(PKG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
|
||||
|
||||
if (NOT PKG_CMAKE_PATH)
|
||||
set(PKG_CMAKE_PATH .)
|
||||
endif ()
|
||||
set(__FIND_PKG_NAME ${pkg_name})
|
||||
string(TOLOWER ${pkg_name} pkg_name)
|
||||
message("pkg name:${__FIND_PKG_NAME},${pkg_name}")
|
||||
|
@ -304,7 +306,7 @@ function(mindspore_add_pkg pkg_name )
|
|||
|
||||
__exec_cmd(COMMAND ${CMAKE_COMMAND} ${PKG_CMAKE_OPTION} -G ${CMAKE_GENERATOR}
|
||||
${${pkg_name}_CMAKE_CFLAGS} ${${pkg_name}_CMAKE_CXXFLAGS} ${${pkg_name}_CMAKE_LDFLAGS}
|
||||
-DCMAKE_INSTALL_PREFIX=${${pkg_name}_BASE_DIR} ..
|
||||
-DCMAKE_INSTALL_PREFIX=${${pkg_name}_BASE_DIR} ${${pkg_name}_SOURCE_DIR}/${PKG_CMAKE_PATH}
|
||||
WORKING_DIRECTORY ${${pkg_name}_SOURCE_DIR}/_build)
|
||||
|
||||
__exec_cmd(COMMAND ${CMAKE_COMMAND} --build . --target install -- -j${THNUM}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 5bd0dc1ed59a9ec4ea6a602bf1385c59d845f922
|
||||
Subproject commit 40e9f6f834469d2d228f9782a0a41f95be94d429
|
|
@ -157,10 +157,9 @@ file(GLOB_RECURSE MEM_REUSE_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
|
|||
if(NOT ENABLE_DUMP_E2E)
|
||||
list(REMOVE_ITEM MINDSPORE_SRC_LIST "debug/e2e_dump.cc")
|
||||
endif()
|
||||
|
||||
file(COPY "${ms_onnx_INC}/onnx/onnx.proto" DESTINATION ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
file(GLOB_RECURSE ONNX_PROTO RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/onnx.proto")
|
||||
message(“onnx proto path is : ${ONNX_PROTO}”)
|
||||
message("onnx proto path is : ${ONNX_PROTO}")
|
||||
ms_protobuf_generate(ONNX_PROTO_SRCS ONNX_PROTO_HDRS ${ONNX_PROTO})
|
||||
list(APPEND MINDSPORE_PROTO_LIST ${ONNX_PROTO_SRCS})
|
||||
|
||||
|
@ -319,7 +318,7 @@ target_link_libraries(mindspore dl)
|
|||
target_link_libraries(mindspore mindspore::flatbuffers)
|
||||
# link protobuf
|
||||
if (ENABLE_D)
|
||||
target_link_libraries(mindspore protobuf::libprotobuf)
|
||||
target_link_libraries(mindspore mindspore::protobuf)
|
||||
endif()
|
||||
|
||||
# set c_expression building
|
||||
|
@ -464,7 +463,7 @@ if(ENABLE_GPU)
|
|||
endif()
|
||||
|
||||
if(ENABLE_DUMP_PROTO)
|
||||
target_link_libraries(_c_expression PRIVATE protobuf::libprotobuf)
|
||||
target_link_libraries(_c_expression PRIVATE mindspore::protobuf)
|
||||
endif()
|
||||
|
||||
if(ENABLE_GPU)
|
||||
|
|
|
@ -76,7 +76,7 @@ set_target_properties(_c_dataengine PROPERTIES
|
|||
|
||||
################# Link with external libraries ########################
|
||||
target_link_libraries(_c_dataengine PRIVATE mindspore mindspore_gvar)
|
||||
target_link_libraries(_c_dataengine PRIVATE mindspore::pybind11_module -ldl protobuf::libprotobuf ${SECUREC_LIBRARY})
|
||||
target_link_libraries(_c_dataengine PRIVATE mindspore::pybind11_module -ldl mindspore::protobuf ${SECUREC_LIBRARY})
|
||||
target_link_libraries(_c_dataengine PUBLIC mindspore::jpeg_turbo mindspore::opencv_core mindspore::opencv_imgcodecs
|
||||
mindspore::opencv_imgproc)
|
||||
if (ENABLE_GPUQUE)
|
||||
|
|
|
@ -20,4 +20,4 @@ add_library(engine-datasetops-source OBJECT
|
|||
celeba_op.cc
|
||||
)
|
||||
|
||||
add_dependencies(engine-datasetops-source protobuf::libprotobuf)
|
||||
add_dependencies(engine-datasetops-source mindspore::protobuf)
|
||||
|
|
|
@ -4,4 +4,4 @@ add_library(engine-tdt OBJECT
|
|||
${FEATURE_SRCS}
|
||||
)
|
||||
|
||||
add_dependencies(engine-tdt protobuf::libprotobuf)
|
||||
add_dependencies(engine-tdt mindspore::protobuf)
|
||||
|
|
|
@ -26,7 +26,7 @@ set_target_properties(_c_mindrecord PROPERTIES
|
|||
)
|
||||
|
||||
# add link library
|
||||
target_link_libraries(_c_mindrecord PRIVATE mindspore::sqlite ${PYTHON_LIB} ${SECUREC_LIBRARY} mindspore mindspore_gvar protobuf::libprotobuf)
|
||||
target_link_libraries(_c_mindrecord PRIVATE mindspore::sqlite ${PYTHON_LIB} ${SECUREC_LIBRARY} mindspore mindspore_gvar mindspore::protobuf)
|
||||
|
||||
if (USE_GLOG)
|
||||
target_link_libraries(_c_mindrecord PRIVATE mindspore::glog)
|
||||
|
|
Loading…
Reference in New Issue