diff --git a/cmake/external_libs/gflags.cmake b/cmake/external_libs/gflags.cmake index 22ed9e6..d77b2e3 100755 --- a/cmake/external_libs/gflags.cmake +++ b/cmake/external_libs/gflags.cmake @@ -3,7 +3,6 @@ if (HAVE_GFLAGS) endif() include(ExternalProject) -#set(CMAKE_INSTALL_PREFIX ${PARSER_DIR}/output) if ((${CMAKE_INSTALL_PREFIX} STREQUAL /usr/local) OR (${CMAKE_INSTALL_PREFIX} STREQUAL "C:/Program Files (x86)/ascend")) @@ -11,6 +10,7 @@ if ((${CMAKE_INSTALL_PREFIX} STREQUAL /usr/local) OR message(STATUS "No install prefix selected, default to ${CMAKE_INSTALL_PREFIX}.") endif() +set (gflags_CXXFLAGS "-D_GLIBCXX_USE_CXX11_ABI=0 -Dgoogle=ascend_private") if (ENABLE_GITEE) set(REQ_URL "https://gitee.com/mirrors/gflags/repository/archive/v2.2.2.tar.gz") set(MD5 "") @@ -22,8 +22,8 @@ endif () ExternalProject_Add(gflags_build URL ${REQ_URL} #URL /home/txd/workspace/linux_cmake/pkg/protobuf-3.8.0.tar.gz - #SOURCE_DIR ${PARSER_DIR}/../../third_party/gflags/src/gflags-2.2.2 - CONFIGURE_COMMAND ${CMAKE_COMMAND} -DCMAKE_CXX_FLAGS="-D_GLIBCXX_USE_CXX11_ABI=0" -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}/gflags + #SOURCE_DIR ${METADEF_DIR}/../../third_party/gflags/src/gflags-2.2.2 + CONFIGURE_COMMAND ${CMAKE_COMMAND} -DCMAKE_CXX_FLAGS=${gflags_CXXFLAGS} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}/gflags BUILD_COMMAND $(MAKE) INSTALL_COMMAND $(MAKE) install EXCLUDE_FROM_ALL TRUE diff --git a/cmake/external_libs/protobuf_shared.cmake b/cmake/external_libs/protobuf_shared.cmake index aa820fa..53d8ca4 100755 --- a/cmake/external_libs/protobuf_shared.cmake +++ b/cmake/external_libs/protobuf_shared.cmake @@ -19,25 +19,20 @@ else() set(MD5 "3d9e32700639618a4d2d342c99d4507a") endif () -set(protobuf_CXXFLAGS "-Wno-maybe-uninitialized -Wno-unused-parameter -fPIC -fstack-protector-all -D_FORTIFY_SOURCE=2 -D_GLIBCXX_USE_CXX11_ABI=0 -O2") +set(protobuf_CXXFLAGS "-Wno-maybe-uninitialized -Wno-unused-parameter -fPIC -fstack-protector-all -D_FORTIFY_SOURCE=2 -D_GLIBCXX_USE_CXX11_ABI=0 -O2 -Dgoogle=ascend_private") set(protobuf_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack") ExternalProject_Add(protobuf_build - URL ${REQ_URL} - #URL /home/txd/workspace/linux_cmake/pkg/protobuf-3.8.0.tar.gz - #SOURCE_DIR ${PARSER_DIR}/../third_party/protobuf/src/protobuf-3.8.0 - #DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E copy_directory ${PARSER_DIR}/../third_party/protobuf/src/protobuf-3.8.0 - #CONFIGURE_COMMAND ${CMAKE_COMMAND} - #-DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} - #-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} - #-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} - #-DCMAKE_LINKER=${CMAKE_LINKER} - #-DCMAKE_AR=${CMAKE_AR} - #-DCMAKE_RANLIB=${CMAKE_RANLIB} - #-Dprotobuf_WITH_ZLIB=OFF - #-Dprotobuf_BUILD_TESTS=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_CXX_FLAGS=${protobuf_CXXFLAGS} -DCMAKE_CXX_LDFLAGS=${protobuf_LDFLAGS} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}/protobuf /cmake - CONFIGURE_COMMAND cd - && ./autogen.sh && cd && /configure --prefix=${CMAKE_INSTALL_PREFIX}/protobuf --with-zlib=no CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} CXXFLAGS=${protobuf_CXXFLAGS} LDFLAGS=${protobuf_LDFLAGS} - && bash -c "sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=\"\"|g' libtool && sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool" + URL https://github.com/protocolbuffers/protobuf/archive/v3.8.0.tar.gz + CONFIGURE_COMMAND ${CMAKE_COMMAND} + -Dprotobuf_WITH_ZLIB=OFF + -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} + -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} + -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} + -DCMAKE_LINKER=${CMAKE_LINKER} + -DCMAKE_AR=${CMAKE_AR} + -DCMAKE_RANLIB=${CMAKE_RANLIB} + -DLIB_PREFIX=ascend_ + -Dprotobuf_BUILD_TESTS=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_CXX_FLAGS=${protobuf_CXXFLAGS} -DCMAKE_CXX_LDFLAGS=${protobuf_LDFLAGS} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}/protobuf /cmake BUILD_COMMAND $(MAKE) INSTALL_COMMAND $(MAKE) install EXCLUDE_FROM_ALL TRUE @@ -46,23 +41,25 @@ include(GNUInstallDirs) set(PROTOBUF_SHARED_PKG_DIR ${CMAKE_INSTALL_PREFIX}/protobuf) -add_library(protobuf SHARED IMPORTED) +add_library(ascend_protobuf SHARED IMPORTED) file(MAKE_DIRECTORY ${PROTOBUF_SHARED_PKG_DIR}/include) -set_target_properties(protobuf PROPERTIES - IMPORTED_LOCATION ${PROTOBUF_SHARED_PKG_DIR}/lib/libprotobuf.so +set_target_properties(ascend_protobuf PROPERTIES + IMPORTED_LOCATION ${PROTOBUF_SHARED_PKG_DIR}/${CMAKE_INSTALL_LIBDIR}/libascend_protobuf.so ) -target_include_directories(protobuf INTERFACE ${PROTOBUF_SHARED_PKG_DIR}/include) +target_include_directories(ascend_protobuf INTERFACE ${PROTOBUF_SHARED_PKG_DIR}/include) set(INSTALL_BASE_DIR "") set(INSTALL_LIBRARY_DIR lib) -install(FILES ${PROTOBUF_SHARED_PKG_DIR}/lib/libprotobuf.so ${PROTOBUF_SHARED_PKG_DIR}/lib/libprotobuf.so.19.0.0 OPTIONAL +install(FILES ${PROTOBUF_SHARED_PKG_DIR}/${CMAKE_INSTALL_LIBDIR}/ascend_protobuf.so.3.8.0.0 OPTIONAL + DESTINATION ${INSTALL_LIBRARY_DIR}) +install(FILES ${PROTOBUF_SHARED_PKG_DIR}/${CMAKE_INSTALL_LIBDIR}/ascend_protobuf.so OPTIONAL DESTINATION ${INSTALL_LIBRARY_DIR}) -add_dependencies(protobuf protobuf_build) +add_dependencies(ascend_protobuf protobuf_build) #set(HAVE_PROTOBUF TRUE CACHE BOOL "protobuf build add") set(HAVE_PROTOBUF TRUE) diff --git a/cmake/external_libs/protobuf_static.cmake b/cmake/external_libs/protobuf_static.cmake index a917aea..c147561 100755 --- a/cmake/external_libs/protobuf_static.cmake +++ b/cmake/external_libs/protobuf_static.cmake @@ -16,7 +16,7 @@ else() set(MD5 "3d9e32700639618a4d2d342c99d4507a") endif () -set(protobuf_CXXFLAGS "-Wno-maybe-uninitialized -Wno-unused-parameter -fPIC -fstack-protector-all -D_FORTIFY_SOURCE=2 -D_GLIBCXX_USE_CXX11_ABI=0 -O2") +set(protobuf_CXXFLAGS "-Wno-maybe-uninitialized -Wno-unused-parameter -fPIC -fstack-protector-all -D_FORTIFY_SOURCE=2 -D_GLIBCXX_USE_CXX11_ABI=0 -O2 -Dgoogle=ascend_private") set(protobuf_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack") set(PROTOBUF_STATIC_PKG_DIR ${CMAKE_INSTALL_PREFIX}/protobuf_static) ExternalProject_Add(protobuf_static_build @@ -38,14 +38,14 @@ ExternalProject_Add(protobuf_static_build ) include(GNUInstallDirs) -add_library(protobuf_static_lib STATIC IMPORTED) +add_library(ascend_protobuf_static_lib STATIC IMPORTED) -set_target_properties(protobuf_static_lib PROPERTIES - IMPORTED_LOCATION ${PROTOBUF_STATIC_PKG_DIR}/${CMAKE_INSTALL_LIBDIR}/libprotobuf.a +set_target_properties(ascend_protobuf_static_lib PROPERTIES + IMPORTED_LOCATION ${PROTOBUF_STATIC_PKG_DIR}/${CMAKE_INSTALL_LIBDIR}/libascend_protobuf.a ) -add_library(protobuf_static INTERFACE) -target_include_directories(protobuf_static INTERFACE ${PROTOBUF_STATIC_PKG_DIR}/include) -target_link_libraries(protobuf_static INTERFACE protobuf_static_lib) +add_library(ascend_protobuf_static INTERFACE) +target_include_directories(ascend_protobuf_static INTERFACE ${PROTOBUF_STATIC_PKG_DIR}/include) +target_link_libraries(ascend_protobuf_static INTERFACE ascend_protobuf_static_lib) -add_dependencies(protobuf_static protobuf_static_build) +add_dependencies(ascend_protobuf_static protobuf_static_build) diff --git a/parser/CMakeLists.txt b/parser/CMakeLists.txt index 59cdb65..75e2fa8 100644 --- a/parser/CMakeLists.txt +++ b/parser/CMakeLists.txt @@ -52,6 +52,7 @@ target_compile_options(fmk_parser PRIVATE target_compile_definitions(fmk_parser PRIVATE PROTOBUF_INLINE_NOT_IN_HEADERS=0 + google=ascend_private ) target_include_directories(fmk_parser PRIVATE @@ -91,7 +92,7 @@ target_include_directories(fmk_parser PRIVATE target_link_libraries(fmk_parser $ -Wl,--no-as-needed - protobuf + ascend_protobuf error_manager parser_common graph diff --git a/parser/common/CMakeLists.txt b/parser/common/CMakeLists.txt index 276d2c2..f5e987b 100644 --- a/parser/common/CMakeLists.txt +++ b/parser/common/CMakeLists.txt @@ -35,6 +35,7 @@ target_compile_options(parser_common PRIVATE target_compile_definitions(parser_common PRIVATE PROTOBUF_INLINE_NOT_IN_HEADERS=0 + google=ascend_private ) target_include_directories(parser_common PRIVATE @@ -74,7 +75,7 @@ target_link_libraries(parser_common PRIVATE $ -Wl,--no-as-needed graph - protobuf + ascend_protobuf register c_sec slog diff --git a/parser/common/module.mk b/parser/common/module.mk index 4eb3e74..dad01b0 100644 --- a/parser/common/module.mk +++ b/parser/common/module.mk @@ -5,7 +5,7 @@ include $(CLEAR_VARS) LOCAL_MODULE := libparser_common LOCAL_CFLAGS += -DPROTOBUF_INLINE_NOT_IN_HEADERS=0 -LOCAL_CFLAGS += -Werror +LOCAL_CFLAGS += -Werror -Dgoogle=ascend_private ifeq ($(DEBUG), 1) LOCAL_CFLAGS += -g -O0 endif @@ -83,7 +83,7 @@ LOCAL_C_INCLUDES := \ third_party/openssl/include/x86/include \ LOCAL_SHARED_LIBRARIES := \ - libprotobuf \ + libascend_protobuf \ libslog \ libgraph \ libmmpa \ diff --git a/parser/module.mk b/parser/module.mk index 502d44b..2a09c8b 100644 --- a/parser/module.mk +++ b/parser/module.mk @@ -52,7 +52,7 @@ include $(CLEAR_VARS) LOCAL_MODULE := libfmk_parser LOCAL_CFLAGS += -DPROTOBUF_INLINE_NOT_IN_HEADERS=0 -LOCAL_CFLAGS += -Werror +LOCAL_CFLAGS += -Werror -Dgoogle=ascend_private ifeq ($(DEBUG), 1) LOCAL_CFLAGS += -g -O0 endif @@ -107,7 +107,7 @@ LOCAL_SRC_FILES += $(FMK_COMMON_SRC_FILES) LOCAL_C_INCLUDES := $(COMMON_LOCAL_C_INCLUDES) LOCAL_SHARED_LIBRARIES := \ - libprotobuf \ + libascend_protobuf \ libslog \ libmmpa \ libc_sec \ diff --git a/parser/onnx/CMakeLists.txt b/parser/onnx/CMakeLists.txt index 84d1178..99d2059 100644 --- a/parser/onnx/CMakeLists.txt +++ b/parser/onnx/CMakeLists.txt @@ -22,6 +22,7 @@ target_compile_options(fmk_onnx_parser PRIVATE target_compile_definitions(fmk_onnx_parser PRIVATE PROTOBUF_INLINE_NOT_IN_HEADERS=0 + google=ascend_private ) target_include_directories(fmk_onnx_parser PRIVATE @@ -61,7 +62,7 @@ target_include_directories(fmk_onnx_parser PRIVATE target_link_libraries(fmk_onnx_parser PRIVATE $ -Wl,--no-as-needed - protobuf + ascend_protobuf register c_sec parser_common diff --git a/parser/onnx/module.mk b/parser/onnx/module.mk index 531be98..3710780 100644 --- a/parser/onnx/module.mk +++ b/parser/onnx/module.mk @@ -6,7 +6,7 @@ include $(CLEAR_VARS) LOCAL_MODULE := libfmk_onnx_parser LOCAL_CFLAGS += -DPROTOBUF_INLINE_NOT_IN_HEADERS=0 -LOCAL_CFLAGS += -Werror +LOCAL_CFLAGS += -Werror -Dgoogle=ascend_private ifeq ($(DEBUG), 1) LOCAL_CFLAGS += -g -O0 endif @@ -38,7 +38,7 @@ LOCAL_C_INCLUDES := \ third_party/openssl/include/x86/include \ LOCAL_SHARED_LIBRARIES := \ - libprotobuf \ + libascend_protobuf \ libslog \ libmmpa \ libc_sec \ diff --git a/parser/proto/caffe/CMakeLists.txt b/parser/proto/caffe/CMakeLists.txt index 957411f..8cdfd4d 100644 --- a/parser/proto/caffe/CMakeLists.txt +++ b/parser/proto/caffe/CMakeLists.txt @@ -7,6 +7,10 @@ protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST}) ############ lib_caffe_parser.so ############ add_library(_caffe_parser SHARED ${PROTO_SRCS}) +target_compile_definitions(_caffe_parser PRIVATE + google=ascend_private +) + target_include_directories(_caffe_parser PRIVATE ${CMAKE_CURRENT_LIST_DIR} ) @@ -14,7 +18,7 @@ target_include_directories(_caffe_parser PRIVATE target_link_libraries(_caffe_parser PRIVATE $ -Wl,--no-as-needed - protobuf + ascend_protobuf -Wl,--as-needed ) diff --git a/parser/proto/caffe/module.mk b/parser/proto/caffe/module.mk index a4c6fdd..f6e5d9d 100644 --- a/parser/proto/caffe/module.mk +++ b/parser/proto/caffe/module.mk @@ -4,6 +4,7 @@ include $(CLEAR_VARS) LOCAL_MODULE := lib_caffe_parser +LOCAL_CFLAGS += -Dgoogle=ascend_private ifeq ($(DEBUG), 1) LOCAL_CFLAGS += -g -O0 endif @@ -15,6 +16,6 @@ LOCAL_C_INCLUDES := \ third_party/protobuf/include \ LOCAL_SHARED_LIBRARIES := \ - libprotobuf \ + libascend_protobuf \ include $(BUILD_HOST_SHARED_LIBRARY)