diff --git a/cmake/external_libs/protobuf.cmake b/cmake/external_libs/protobuf.cmake index e963fae5..bbd86bc4 100644 --- a/cmake/external_libs/protobuf.cmake +++ b/cmake/external_libs/protobuf.cmake @@ -1,27 +1,24 @@ -if (NOT TARGET protobuf::libprotobuf) +if (NOT TARGET protobuf::protobuf) +set(protobuf_USE_STATIC_LIBS ON) +set(protobuf_CXXFLAGS "-Wno-maybe-uninitialized -Wno-unused-parameter -fPIC -fstack-protector-all -D_FORTIFY_SOURCE=2 -O2") +set(protobuf_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack") +set(_ge_tmp_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) +string(REPLACE " -Wall" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") +string(REPLACE " -Werror" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") graphengine_add_pkg(protobuf VER 3.8.0 - HEAD_ONLY ./ + LIBS protobuf + EXE protoc URL https://github.com/protocolbuffers/protobuf/archive/v3.8.0.tar.gz - MD5 3d9e32700639618a4d2d342c99d4507a) -set(protobuf_BUILD_TESTS OFF CACHE BOOL "Disahble protobuf test") -set(protobuf_BUILD_SHARED_LIBS ON CACHE BOOL "Gen shared library") -set(_ms_tmp_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) -string(REPLACE " -Wall" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") -string(REPLACE " -Werror" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - -set(PROTOBUF_CMAKE_FILE "${protobuf_DIRPATH}/cmake/libprotobuf.cmake" ) -FILE(READ ${PROTOBUF_CMAKE_FILE} GE_MR_PROTOBUF_CMAKE) -STRING(REPLACE "VERSION \${protobuf_VERSION}" "VERSION 19" GE_MR_PROTOBUF_CMAKE_V19 "${GE_MR_PROTOBUF_CMAKE}" ) -FILE(WRITE ${PROTOBUF_CMAKE_FILE} "${GE_MR_PROTOBUF_CMAKE_V19}") - -add_subdirectory(${protobuf_DIRPATH}/cmake ${protobuf_DIRPATH}/build) -set(CMAKE_CXX_FLAGS ${_ms_tmp_CMAKE_CXX_FLAGS}) + MD5 3d9e32700639618a4d2d342c99d4507a + CMAKE_PATH ../cmake/ + CMAKE_OPTION -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_SHARED_LIBS=OFF) +set(CMAKE_CXX_FLAGS ${_ge_tmp_CMAKE_CXX_FLAGS}) endif() - -set(PROTOBUF_LIBRARY protobuf::libprotobuf) +add_library(graphengine::protobuf ALIAS protobuf::protobuf) +set(PROTOBUF_LIBRARY protobuf::protobuf) +include_directories(${protobuf_INC}) include_directories(${protobuf_DIRPATH}/src) -add_library(ge_protobuf::protobuf ALIAS libprotobuf) function(ge_protobuf_generate comp c_var h_var) if(NOT ARGN) diff --git a/cmake/ge_utils.cmake b/cmake/ge_utils.cmake index 0c0bacd6..ded0b440 100644 --- a/cmake/ge_utils.cmake +++ b/cmake/ge_utils.cmake @@ -190,10 +190,14 @@ set(GE_FIND_NO_DEFAULT_PATH ${GE_FIND_NO_DEFAULT_PATH} PARENT_SCOPE) function(graphengine_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}") @@ -302,7 +306,7 @@ function(graphengine_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_CMAKE_PATH} WORKING_DIRECTORY ${${pkg_name}_SOURCE_DIR}/_build) __exec_cmd(COMMAND ${CMAKE_COMMAND} --build . --target install -- -j${THNUM} diff --git a/src/common/graph/CMakeLists.txt b/src/common/graph/CMakeLists.txt index c6bd0c3d..03c93421 100755 --- a/src/common/graph/CMakeLists.txt +++ b/src/common/graph/CMakeLists.txt @@ -59,8 +59,6 @@ include_directories(${GE_SOURCE_DIR}/inc/graph) include_directories(${GE_SOURCE_DIR}/inc/common) include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc) include_directories(${GE_SOURCE_DIR}/third_party/securec/include) -include_directories(${GE_SOURCE_DIR}/third_party/json/include) -include_directories(${GE_SOURCE_DIR}/third_party/protobuf/src) include_directories(${CMAKE_BINARY_DIR}) include_directories(${CMAKE_BINARY_DIR}/proto/ge) include_directories(${GE_SOURCE_DIR}/build) diff --git a/src/ge/CMakeLists.txt b/src/ge/CMakeLists.txt index 6fc26780..4a4cf5cb 100755 --- a/src/ge/CMakeLists.txt +++ b/src/ge/CMakeLists.txt @@ -44,9 +44,6 @@ include_directories(${GE_SOURCE_DIR}/inc/runtime) include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc) include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc/cce) include_directories(${GE_SOURCE_DIR}/third_party/securec/include) -include_directories(${GE_SOURCE_DIR}/third_party/protobuf/src) -include_directories(${GE_SOURCE_DIR}/third_party/json/include) -include_directories(${GE_SOURCE_DIR}/third_party/eigen) include_directories(${CMAKE_BINARY_DIR}) include_directories(${CMAKE_BINARY_DIR}/proto/ge) diff --git a/tests/depends/cce/CMakeLists.txt b/tests/depends/cce/CMakeLists.txt index 24aaa096..21ff8231 100644 --- a/tests/depends/cce/CMakeLists.txt +++ b/tests/depends/cce/CMakeLists.txt @@ -67,7 +67,7 @@ file(GLOB_RECURSE SRCS RELATIVE ${CMAKE_CURRENT_LIST_DIR} "${GE_SOURCE_DIR}/src/common/graph/opsproto/opsproto_manager.cc" ) add_library(cce_ge_stub SHARED src/cce_stub.cc ${PROTO_SRCS} ${PROTO_HDRS}) -target_link_libraries(cce_ge_stub ge_protobuf::protobuf) +target_link_libraries(cce_ge_stub protobuf::protobuf) add_library(cce_stub SHARED ${SRCS} ${PROTO_SRCS} ${PROTO_HDRS}) -target_link_libraries(cce_stub ge_protobuf::protobuf) +target_link_libraries(cce_stub protobuf::protobuf) diff --git a/tests/depends/mmpa/CMakeLists.txt b/tests/depends/mmpa/CMakeLists.txt index 8485a600..6185c8fe 100644 --- a/tests/depends/mmpa/CMakeLists.txt +++ b/tests/depends/mmpa/CMakeLists.txt @@ -28,4 +28,4 @@ include_directories(${GE_SOURCE_DIR}/inc/external) include_directories(${GE_SOURCE_DIR}/third_party/securec/include) add_library(mmpa_stub SHARED ${SRCS}) -target_link_libraries(mmpa_stub ge_protobuf::protobuf) +target_link_libraries(mmpa_stub protobuf::protobuf) diff --git a/tests/depends/omg/CMakeLists.txt b/tests/depends/omg/CMakeLists.txt index fb63dc90..158a1ff4 100644 --- a/tests/depends/omg/CMakeLists.txt +++ b/tests/depends/omg/CMakeLists.txt @@ -43,4 +43,4 @@ file(GLOB_RECURSE SRCS RELATIVE ${CMAKE_CURRENT_LIST_DIR} ) add_library(omg_stub SHARED ${SRCS} ${PROTO_SRCS} ${PROTO_HDRS}) -target_link_libraries(omg_stub ge_protobuf::protobuf) +target_link_libraries(omg_stub protobuf::protobuf) diff --git a/tests/ut/common/graph/CMakeLists.txt b/tests/ut/common/graph/CMakeLists.txt index 9ac2d428..674e2c1f 100644 --- a/tests/ut/common/graph/CMakeLists.txt +++ b/tests/ut/common/graph/CMakeLists.txt @@ -37,7 +37,6 @@ include_directories(${GE_SOURCE_DIR}/inc/graph) include_directories(${GE_SOURCE_DIR}/inc/common) include_directories(${GE_SOURCE_DIR}/inc/ops) include_directories(${GE_SOURCE_DIR}/third_party/securec/include) -include_directories(${GE_SOURCE_DIR}/third_party/json/include) include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc/ops) include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc) include_directories(/usr/local/HiAI/opp/op_proto/built-in/inc) @@ -97,4 +96,4 @@ file(GLOB_RECURSE SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ) add_executable(ut_libgraph ${UT_FILES} ${SRC_FILES} ${PROTO_SRCS} ${PROTO_HDRS}) -target_link_libraries(ut_libgraph graphengine::gtest graphengine::gtest_main slog_stub ge_protobuf::protobuf ${c_sec} rt dl) +target_link_libraries(ut_libgraph graphengine::gtest graphengine::gtest_main slog_stub protobuf::protobuf ${c_sec} rt dl) diff --git a/tests/ut/ge/CMakeLists.txt b/tests/ut/ge/CMakeLists.txt index 46f18e84..69b93905 100755 --- a/tests/ut/ge/CMakeLists.txt +++ b/tests/ut/ge/CMakeLists.txt @@ -44,9 +44,7 @@ include_directories(${GE_SOURCE_DIR}/inc/graph) include_directories(${GE_SOURCE_DIR}/inc/framework) include_directories(${GE_SOURCE_DIR}/inc/common) include_directories(${GE_SOURCE_DIR}/inc/ops) -include_directories(${GE_SOURCE_DIR}/third_party/eigen) include_directories(${GE_SOURCE_DIR}/third_party/securec/include) -include_directories(${GE_SOURCE_DIR}/third_party/json/include) include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc/ops) include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc) include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc/cce) @@ -540,9 +538,9 @@ add_executable(ut_libge_multiparts_utest target_link_libraries(ut_libge_multiparts_utest ge_build_common ge_load_common ge_build_common ge_execute_common ge_optimize_common ge_partition_common ge_pass_common ge_prepare_common ge_single_op ge_ut_common - graphengine::gtest graphengine::gtest_main ge_protobuf::protobuf rt dl + graphengine::gtest graphengine::gtest_main protobuf::protobuf rt dl ) -target_link_libraries(ut_libge_multiparts_utest ${COMMON_SHARED_LIBRARIES} ge_protobuf::protobuf) +target_link_libraries(ut_libge_multiparts_utest ${COMMON_SHARED_LIBRARIES} protobuf::protobuf) # libge_others_utest add_executable(ut_libge_others_utest @@ -554,9 +552,9 @@ add_executable(ut_libge_others_utest ) target_link_libraries(ut_libge_others_utest ge_execute_common ge_load_common ge_pass_common ge_ut_common - graphengine::gtest graphengine::gtest_main ge_protobuf::protobuf rt dl + graphengine::gtest graphengine::gtest_main protobuf::protobuf rt dl ) -target_link_libraries(ut_libge_others_utest ${COMMON_SHARED_LIBRARIES} ge_protobuf::protobuf) +target_link_libraries(ut_libge_others_utest ${COMMON_SHARED_LIBRARIES} protobuf::protobuf) # libge_kernel_utest add_executable(ut_libge_kernel_utest @@ -567,9 +565,9 @@ add_executable(ut_libge_kernel_utest ) target_link_libraries(ut_libge_kernel_utest ge_pass_common ge_ut_common ge_load_common - graphengine::gtest graphengine::gtest_main ge_protobuf::protobuf rt dl + graphengine::gtest graphengine::gtest_main protobuf::protobuf rt dl ) -target_link_libraries(ut_libge_kernel_utest ${COMMON_SHARED_LIBRARIES} ge_protobuf::protobuf) +target_link_libraries(ut_libge_kernel_utest ${COMMON_SHARED_LIBRARIES} protobuf::protobuf) # libge_distinct_load_utest add_executable(ut_libge_distinct_load_utest @@ -583,5 +581,5 @@ target_link_libraries(ut_libge_distinct_load_utest ${COMMON_SHARED_LIBRARIES} ge_execute_common ge_ut_common ge_ut_common_format ge_pass_common ge_load_common ge_single_op ge_prepare_common ge_optimize_common ge_build_common ge_partition_common - graphengine::gtest graphengine::gtest_main ge_protobuf::protobuf rt dl pthread + graphengine::gtest graphengine::gtest_main protobuf::protobuf rt dl pthread )