diff --git a/cmake/external_libs/protobuf.cmake b/cmake/external_libs/protobuf.cmake index c354bcb65d4d45d2d25fe70d5cde6a7500445aa9..9e64785a7a710a4a3c900307ac38d0163af0a400 100644 --- a/cmake/external_libs/protobuf.cmake +++ b/cmake/external_libs/protobuf.cmake @@ -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) diff --git a/cmake/utils.cmake b/cmake/utils.cmake index 99c064fdd48cefa07a2ded2400dc3e3b89eadee6..c9b7d944f03ef87858ac49bf90aba29718cf407a 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -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} diff --git a/graphengine b/graphengine index 5bd0dc1ed59a9ec4ea6a602bf1385c59d845f922..40e9f6f834469d2d228f9782a0a41f95be94d429 160000 --- a/graphengine +++ b/graphengine @@ -1 +1 @@ -Subproject commit 5bd0dc1ed59a9ec4ea6a602bf1385c59d845f922 +Subproject commit 40e9f6f834469d2d228f9782a0a41f95be94d429 diff --git a/mindspore/ccsrc/CMakeLists.txt b/mindspore/ccsrc/CMakeLists.txt index c49c962bdd26a7cc5a86f7ea6c2a6f676f03e504..f3100f62c98d43b84a57553b08fbdf12bd5075f7 100644 --- a/mindspore/ccsrc/CMakeLists.txt +++ b/mindspore/ccsrc/CMakeLists.txt @@ -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) diff --git a/mindspore/ccsrc/dataset/CMakeLists.txt b/mindspore/ccsrc/dataset/CMakeLists.txt index 477d37051e43da165c75b6901cf7398410392cd3..5bf210a8ba7432c4c7d0349cb9b956437cd8723e 100644 --- a/mindspore/ccsrc/dataset/CMakeLists.txt +++ b/mindspore/ccsrc/dataset/CMakeLists.txt @@ -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) diff --git a/mindspore/ccsrc/dataset/engine/datasetops/source/CMakeLists.txt b/mindspore/ccsrc/dataset/engine/datasetops/source/CMakeLists.txt index 5a02a2ec31da41cf6d1d3255de84614f1f88d02e..a7c0dfd725b3837e52690111b03fa7eb67aa84ce 100644 --- a/mindspore/ccsrc/dataset/engine/datasetops/source/CMakeLists.txt +++ b/mindspore/ccsrc/dataset/engine/datasetops/source/CMakeLists.txt @@ -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) diff --git a/mindspore/ccsrc/dataset/engine/tdt/CMakeLists.txt b/mindspore/ccsrc/dataset/engine/tdt/CMakeLists.txt index 4a2adff3102bbb84a10a5d44d64f3d5e05519c1d..9c6ec4b388138085cdbd931712955a1e9c2b594f 100644 --- a/mindspore/ccsrc/dataset/engine/tdt/CMakeLists.txt +++ b/mindspore/ccsrc/dataset/engine/tdt/CMakeLists.txt @@ -4,4 +4,4 @@ add_library(engine-tdt OBJECT ${FEATURE_SRCS} ) -add_dependencies(engine-tdt protobuf::libprotobuf) +add_dependencies(engine-tdt mindspore::protobuf) diff --git a/mindspore/ccsrc/mindrecord/CMakeLists.txt b/mindspore/ccsrc/mindrecord/CMakeLists.txt index eb1c1fb591f2b8828e870b8a279f584582da8dd5..4b8448287d72dc7dc9e7ae2f16368521a1d5e49f 100644 --- a/mindspore/ccsrc/mindrecord/CMakeLists.txt +++ b/mindspore/ccsrc/mindrecord/CMakeLists.txt @@ -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)