From 25a67602b755345931355f55da76cab39f9d4da8 Mon Sep 17 00:00:00 2001 From: liubuyu Date: Tue, 11 Aug 2020 12:40:23 +0800 Subject: [PATCH] bug fix for glog level don't work --- cmake/package.cmake | 6 ++++++ mindspore/ccsrc/CMakeLists.txt | 4 +++- mindspore/ccsrc/minddata/dataset/CMakeLists.txt | 2 +- mindspore/ccsrc/minddata/mindrecord/CMakeLists.txt | 4 ++-- mindspore/core/CMakeLists.txt | 3 ++- mindspore/core/gvar/CMakeLists.txt | 11 +++++++++++ serving/CMakeLists.txt | 2 +- tests/ut/cpp/CMakeLists.txt | 4 ++-- 8 files changed, 28 insertions(+), 8 deletions(-) create mode 100644 mindspore/core/gvar/CMakeLists.txt diff --git a/cmake/package.cmake b/cmake/package.cmake index a57b8a130f..e5b4a75dc9 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 c7b8e9f467..7409981f3a 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 a13121d588..81032180b6 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 5bd3752d6b..4b2a30c9f1 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 609fc7ac75..8e018df2e4 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 0000000000..26ff5ff870 --- /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 91a9cd678a..8b60168228 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 3d2c29d067..eddf8f66ba 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)