diff --git a/cmake/package.cmake b/cmake/package.cmake index a57b8a130f7f7fc563d97ed91d6a957c9397d42b..e5b4a75dc9d1d3aa96bb53ede354ec25d0b2cf34 100644 --- a/cmake/package.cmake +++ b/cmake/package.cmake @@ -52,6 +52,12 @@ install( COMPONENT mindspore ) +install( + TARGETS mindspore_gvar + DESTINATION ${INSTALL_LIB_DIR} + COMPONENT mindspore +) + if (USE_GLOG) file(GLOB_RECURSE GLOG_LIB_LIST ${glog_LIBPATH}/libglog*) install( diff --git a/mindspore/ccsrc/CMakeLists.txt b/mindspore/ccsrc/CMakeLists.txt index c7b8e9f467e895c37a5d1ba9b81488924c8c3b35..7409981f3a05257c66c19003366d0d62ccb2d559 100644 --- a/mindspore/ccsrc/CMakeLists.txt +++ b/mindspore/ccsrc/CMakeLists.txt @@ -235,6 +235,7 @@ set_target_properties(_c_expression PROPERTIES INSTALL_RPATH ${ORIGIN_PATH}) if (CMAKE_SYSTEM_NAME MATCHES "Windows") target_link_libraries(mindspore mindspore::pybind11_module) + target_link_libraries(mindspore mindspore_gvar) target_link_libraries(_c_expression PRIVATE -Wl,--whole-archive mindspore -Wl,--no-whole-archive) else () if (ENABLE_CPU AND (ENABLE_D OR ENABLE_GPU)) @@ -245,6 +246,7 @@ else () endif() target_link_libraries(_c_expression PRIVATE -Wl,--whole-archive mindspore -Wl,--no-whole-archive) target_link_libraries(_c_expression PRIVATE mindspore::pybind11_module) + target_link_libraries(_c_expression PRIVATE mindspore_gvar) endif () if (USE_GLOG) @@ -288,7 +290,7 @@ add_library(inference SHARED ${LOAD_ONNX_SRC} ) target_link_libraries(inference PRIVATE ${PYTHON_LIBRARIES} ${SECUREC_LIBRARY} - -Wl,--whole-archive mindspore -Wl,--no-whole-archive mindspore::protobuf) + -Wl,--whole-archive mindspore -Wl,--no-whole-archive mindspore_gvar mindspore::protobuf) if (ENABLE_CPU) target_link_libraries(inference PRIVATE mindspore::dnnl mindspore::mkldnn) diff --git a/mindspore/ccsrc/minddata/dataset/CMakeLists.txt b/mindspore/ccsrc/minddata/dataset/CMakeLists.txt index a13121d5888aa9db5b568e8b5d6f0a9cacdadf5c..81032180b69cf6fa80ef83063fb700afc712e841 100644 --- a/mindspore/ccsrc/minddata/dataset/CMakeLists.txt +++ b/mindspore/ccsrc/minddata/dataset/CMakeLists.txt @@ -126,7 +126,7 @@ endif() ###################################################################### ################# Link with external libraries ######################## -target_link_libraries(_c_dataengine PRIVATE mindspore) +target_link_libraries(_c_dataengine PRIVATE mindspore mindspore_gvar) if (${CMAKE_SYSTEM_NAME} MATCHES "Windows") if (ENABLE_PYTHON) target_link_libraries(_c_dataengine PRIVATE mindspore::pybind11_module ${PYTHON_LIBRARIES} mindspore::protobuf ${SECUREC_LIBRARY}) diff --git a/mindspore/ccsrc/minddata/mindrecord/CMakeLists.txt b/mindspore/ccsrc/minddata/mindrecord/CMakeLists.txt index 5bd3752d6b373c9437e86331c2274528d4142681..4b2a30c9f1f95c62d331cda6697569d3006c858f 100644 --- a/mindspore/ccsrc/minddata/mindrecord/CMakeLists.txt +++ b/mindspore/ccsrc/minddata/mindrecord/CMakeLists.txt @@ -28,9 +28,9 @@ set_target_properties(_c_mindrecord PROPERTIES # add link library if (${CMAKE_SYSTEM_NAME} MATCHES "Windows") - target_link_libraries(_c_mindrecord PRIVATE mindspore::sqlite mindspore mindspore::protobuf) + target_link_libraries(_c_mindrecord PRIVATE mindspore::sqlite mindspore mindspore_gvar mindspore::protobuf) else() - target_link_libraries(_c_mindrecord PRIVATE mindspore::sqlite ${PYTHON_LIB} ${SECUREC_LIBRARY} mindspore mindspore::protobuf) + target_link_libraries(_c_mindrecord PRIVATE mindspore::sqlite ${PYTHON_LIB} ${SECUREC_LIBRARY} mindspore mindspore_gvar mindspore::protobuf) endif() if (USE_GLOG) diff --git a/mindspore/core/CMakeLists.txt b/mindspore/core/CMakeLists.txt index 609fc7ac75be4c75fe88a907f7b9a24598dd2780..8e018df2e45d09346cefe7b9ea332019fe05507c 100644 --- a/mindspore/core/CMakeLists.txt +++ b/mindspore/core/CMakeLists.txt @@ -1,6 +1,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}) include_directories(${CMAKE_BINARY_DIR}) include_directories(${CMAKE_SOURCE_DIR}/mindspore/core) +add_subdirectory(gvar) message("************build core***************") if (CMAKE_SYSTEM_NAME MATCHES "Windows") @@ -14,10 +15,10 @@ file(GLOB_RECURSE CORE_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "c_ops/*.cc" "ir/*.cc" "utils/*.cc" - "gvar/*.cc" ) set_property(SOURCE ${CORE_SRC_LIST} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_CORE) add_library(mindspore_core STATIC ${CORE_SRC_LIST}) +target_link_libraries(mindspore_core PRIVATE mindspore_gvar) if (USE_GLOG) target_link_libraries(mindspore_core PRIVATE mindspore::glog) endif () diff --git a/mindspore/core/gvar/CMakeLists.txt b/mindspore/core/gvar/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..26ff5ff870c25df441ed5afeaad8e7bb850015c8 --- /dev/null +++ b/mindspore/core/gvar/CMakeLists.txt @@ -0,0 +1,11 @@ +file(GLOB_RECURSE MS_GVAR_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cc) +set_property(SOURCE ${MS_GVAR_SRC_LIST} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_COMMON) +if (CMAKE_SYSTEM_NAME MATCHES "Windows") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes -DHAVE_SNPRINTF") + add_compile_definitions(BUILDING_DLL) +endif() + +add_library(mindspore_gvar SHARED ${MS_GVAR_SRC_LIST}) +if (APPLE) + set_target_properties(mindspore_gvar PROPERTIES MACOSX_RPATH ON) +endif () \ No newline at end of file diff --git a/serving/CMakeLists.txt b/serving/CMakeLists.txt index 91a9cd678a2e31b385006801fb3a5fbf3fe0c914..8b60168228a41bd6ba784cbc5f646f3c1f919a1e 100644 --- a/serving/CMakeLists.txt +++ b/serving/CMakeLists.txt @@ -110,5 +110,5 @@ if (ENABLE_ACL) target_link_libraries(ms_serving ${ALC_LIB_SO}) target_link_libraries(ms_serving jpeg_turbo::jpeg) else () - target_link_libraries(ms_serving inference) + target_link_libraries(ms_serving inference mindspore_gvar) endif () diff --git a/tests/ut/cpp/CMakeLists.txt b/tests/ut/cpp/CMakeLists.txt index 3d2c29d06779c817a3071dde6085e7548a6391d7..eddf8f66ba12b4731eb2f0bb559cdacf23fed756 100644 --- a/tests/ut/cpp/CMakeLists.txt +++ b/tests/ut/cpp/CMakeLists.txt @@ -180,12 +180,12 @@ if (ENABLE_GE) endif() if (CMAKE_SYSTEM_NAME MATCHES "Linux") - target_link_libraries(ut_tests PRIVATE mindspore::gtest ${PYTHON_LIBRARIES} pthread util dl) + target_link_libraries(ut_tests PRIVATE mindspore::gtest mindspore_gvar ${PYTHON_LIBRARIES} pthread util dl) if (ENABLE_MINDDATA) target_link_libraries(ut_tests PRIVATE _c_dataengine _c_mindrecord) endif() else() - target_link_libraries(ut_tests PRIVATE mindspore::gtest ${PYTHON_LIBRARIES}) + target_link_libraries(ut_tests PRIVATE mindspore::gtest mindspore_gvar ${PYTHON_LIBRARIES}) endif() if (USE_GLOG) target_link_libraries(ut_tests PRIVATE mindspore::glog)