Merge pull request !1 from taoxiangdong/masterpull/1/MERGE
| @@ -0,0 +1,49 @@ | |||||
| cmake_minimum_required(VERSION 3.14) | |||||
| project (Parser[CXX]) | |||||
| set(PARSER_DIR ${CMAKE_CURRENT_LIST_DIR}) | |||||
| option(ENABLE_OPEN_SRC "Enable graphengine compile in opensource." FALSE) | |||||
| if (ENABLE_OPEN_SRC) | |||||
| set(HI_PYTHON python3.7) | |||||
| include(cmake/external_libs/protobuf_shared.cmake) | |||||
| include(cmake/external_libs/protoc.cmake) | |||||
| include(cmake/external_libs/securec.cmake) | |||||
| include(cmake/external_libs/json.cmake) | |||||
| include(cmake/FindModule.cmake) | |||||
| include(cmake/intf_pub_linux.cmake) | |||||
| if(DEFINED ENV{ASCEND_CUSTOM_PATH}) | |||||
| set(ASCEND_DIR $ENV{ASCEND_CUSTOM_PATH}) | |||||
| else() | |||||
| set(ASCEND_DIR /usr/local/Ascend) | |||||
| endif() | |||||
| set(ASCEND_DRIVER_DIR ${ASCEND_DIR}/driver/lib64/common) | |||||
| set(ASCEND_RUNTIME_DIR ${ASCEND_DIR}/fwkacllib/lib64) | |||||
| find_module(slog libslog.so ${ASCEND_DRIVER_DIR}) | |||||
| find_module(mmpa libmmpa.so ${ASCEND_DRIVER_DIR}) | |||||
| find_module(ge_common libge_common.so ${ASCEND_RUNTIME_DIR}) | |||||
| find_module(error_manager liberror_manager.so ${ASCEND_RUNTIME_DIR}) | |||||
| set(METADEF_DIR ${CMAKE_CURRENT_LIST_DIR}/metadef) | |||||
| add_subdirectory(metadef) | |||||
| #add_subdirectory(metadef/graph) | |||||
| #add_subdirectory(metadef/register) | |||||
| else() | |||||
| ####工程tigong | |||||
| set(METADEF_DIR ${CMAKE_CURRENT_LIST_DIR}/../metadef) | |||||
| endif() | |||||
| add_subdirectory(parser) | |||||
| add_subdirectory(parser/common) | |||||
| add_subdirectory(parser/func_to_graph) | |||||
| add_subdirectory(parser/onnx) | |||||
| add_subdirectory(parser/proto/caffe) | |||||
| @@ -0,0 +1,23 @@ | |||||
| #[[ | |||||
| module - the name of export imported target | |||||
| name - find the library name | |||||
| path - find the library path | |||||
| #]] | |||||
| function(find_module module name path) | |||||
| if (TARGET ${module}) | |||||
| return() | |||||
| endif() | |||||
| find_library(${module}_LIBRARY_DIR NAMES ${name} NAMES_PER_DIR PATHS ${path} | |||||
| PATH_SUFFIXES lib | |||||
| ) | |||||
| message(STATUS "find ${name} location ${${module}_LIBRARY_DIR}") | |||||
| if ("${${module}_LIBRARY_DIR}" STREQUAL "${module}_LIBRARY_DIR-NOTFOUND") | |||||
| message(FATAL_ERROR "${name} not found in ${path}") | |||||
| endif() | |||||
| add_library(${module} SHARED IMPORTED) | |||||
| set_target_properties(${module} PROPERTIES | |||||
| IMPORTED_LOCATION ${${module}_LIBRARY_DIR} | |||||
| ) | |||||
| endfunction() | |||||
| @@ -0,0 +1,38 @@ | |||||
| if (HAVE_GFLAGS) | |||||
| return() | |||||
| 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")) | |||||
| set(CMAKE_INSTALL_PREFIX ${PARSER_DIR}/output CACHE STRING "path for install()" FORCE) | |||||
| message(STATUS "No install prefix selected, default to ${CMAKE_INSTALL_PREFIX}.") | |||||
| endif() | |||||
| ExternalProject_Add(gflags_build | |||||
| #URL http://tfk.inhuawei.com/api/containers/container1/download/protobuf-3.8.0.tar.gz | |||||
| #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> | |||||
| BUILD_COMMAND $(MAKE) | |||||
| INSTALL_COMMAND $(MAKE) install | |||||
| EXCLUDE_FROM_ALL TRUE | |||||
| ) | |||||
| set(GFLAGS_PKG_DIR ${CMAKE_INSTALL_PREFIX}/gflags) | |||||
| add_library(gflags_static STATIC IMPORTED) | |||||
| set_target_properties(gflags_static PROPERTIES | |||||
| IMPORTED_LOCATION ${GFLAGS_PKG_DIR}/lib/libgflags.a | |||||
| ) | |||||
| add_library(gflags INTERFACE) | |||||
| target_include_directories(gflags INTERFACE ${GFLAGS_PKG_DIR}/include) | |||||
| target_link_libraries(gflags INTERFACE gflags_static) | |||||
| add_dependencies(gflags gflags_build) | |||||
| set(HAVE_GFLAGS TRUE CACHE BOOL "gflags build add") | |||||
| @@ -0,0 +1,23 @@ | |||||
| if (HAVE_JSON) | |||||
| return() | |||||
| endif() | |||||
| include(ExternalProject) | |||||
| set(JSON_SRC_DIR ${PARSER_DIR}/../third_party/json/include) | |||||
| ExternalProject_Add(json_build | |||||
| #URL https://github.com/nlohmann/json/releases/download/v3.6.1/include.zip | |||||
| #URL /home/txd/workspace/cloud_code/pkg/include.zip | |||||
| SOURCE_DIR ${JSON_SRC_DIR} | |||||
| CONFIGURE_COMMAND "" | |||||
| BUILD_COMMAND "" | |||||
| INSTALL_COMMAND "" | |||||
| EXCLUDE_FROM_ALL TRUE | |||||
| ) | |||||
| add_library(json INTERFACE) | |||||
| target_include_directories(json INTERFACE ${JSON_SRC_DIR}) | |||||
| add_dependencies(json json_build) | |||||
| set(HAVE_JSON TRUE CACHE BOOL "json build add") | |||||
| @@ -0,0 +1,29 @@ | |||||
| include(ExternalProject) | |||||
| #set(ONNX_SRC_DIR /home/txd/workspace/cloud_code/graphengine/build/graphengine/open_source/onnx) | |||||
| #set(ONNX_PROTO ${ONNX_SRC_DIR}/onnx/onnx.proto) | |||||
| set(ONNX_PROTO_DIR ${CMAKE_BINARY_DIR}/onnx) | |||||
| set(ONNX_PROTO_FILE ${ONNX_PROTO_DIR}/onnx.proto) | |||||
| file(MAKE_DIRECTORY ${ONNX_PROTO_DIR}) | |||||
| ExternalProject_Add(onnx | |||||
| #URL https://github.com/onnx/onnx/releases/download/v1.6.0/onnx-1.6.0.tar.gz | |||||
| URL /home/txd/workspace/cloud_code/pkg/onnx-1.6.0.tar.gz | |||||
| #URL_HASH SHA256=3b88c3fe521151651a0403c4d131cb2e0311bd28b753ef692020a432a81ce345 | |||||
| #SOURCE_DIR ${ONNX_SRC_DIR} | |||||
| CONFIGURE_COMMAND "" | |||||
| BUILD_COMMAND "" | |||||
| #INSTALL_COMMAND "" | |||||
| INSTALL_COMMAND ${CMAKE_COMMAND} -E copy <SOURCE_DIR>/onnx/onnx.proto ${ONNX_PROTO_FILE} | |||||
| #BUILD_ALWAYS TRUE | |||||
| EXCLUDE_FROM_ALL TRUE | |||||
| ) | |||||
| macro(onnx_protobuf_generate comp c_var h_var) | |||||
| add_custom_command(OUTPUT ${ONNX_PROTO_FILE} | |||||
| DEPENDS onnx | |||||
| ) | |||||
| ge_protobuf_generate(${comp} ${c_var} ${h_var} ${ONNX_PROTO_FILE}) | |||||
| endmacro() | |||||
| @@ -0,0 +1,59 @@ | |||||
| if (HAVE_PROTOBUF) | |||||
| return() | |||||
| endif() | |||||
| include(ExternalProject) | |||||
| include(GNUInstallDirs) | |||||
| if ((${CMAKE_INSTALL_PREFIX} STREQUAL /usr/local) OR | |||||
| (${CMAKE_INSTALL_PREFIX} STREQUAL "C:/Program Files (x86)/ascend")) | |||||
| set(CMAKE_INSTALL_PREFIX ${PARSER_DIR}/output CACHE STRING "path for install()" FORCE) | |||||
| message(STATUS "No install prefix selected, default to ${CMAKE_INSTALL_PREFIX}.") | |||||
| endif() | |||||
| set(protobuf_CXXFLAGS "-Wno-maybe-uninitialized -Wno-unused-parameter -fPIC -fstack-protector-all -D_FORTIFY_SOURCE=2 $<$<STREQUAL:${PRODUCT_SIDE},host>:-D_GLIBCXX_USE_CXX11_ABI=0> -O2") | |||||
| set(protobuf_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack") | |||||
| ExternalProject_Add(protobuf_build | |||||
| #URL http://tfk.inhuawei.com/api/containers/container1/download/protobuf-3.8.0.tar.gz | |||||
| #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 <SOURCE_DIR> | |||||
| #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 <SOURCE_DIR>/cmake | |||||
| CONFIGURE_COMMAND cd <SOURCE_DIR> | |||||
| && ./autogen.sh && cd <BINARY_DIR> && <SOURCE_DIR>/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" | |||||
| BUILD_COMMAND $(MAKE) | |||||
| INSTALL_COMMAND $(MAKE) install | |||||
| EXCLUDE_FROM_ALL TRUE | |||||
| ) | |||||
| include(GNUInstallDirs) | |||||
| set(PROTOBUF_SHARED_PKG_DIR ${CMAKE_INSTALL_PREFIX}/protobuf) | |||||
| add_library(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 | |||||
| ) | |||||
| target_include_directories(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 | |||||
| DESTINATION ${INSTALL_LIBRARY_DIR}) | |||||
| add_dependencies(protobuf protobuf_build) | |||||
| set(HAVE_PROTOBUF TRUE CACHE BOOL "protobuf build add") | |||||
| @@ -0,0 +1,43 @@ | |||||
| include(ExternalProject) | |||||
| include(GNUInstallDirs) | |||||
| #set(CMAKE_INSTALL_PREFIX ${GE_CODE_DIR}/output) | |||||
| if ((${CMAKE_INSTALL_PREFIX} STREQUAL /usr/local) OR | |||||
| (${CMAKE_INSTALL_PREFIX} STREQUAL "C:/Program Files (x86)/ascend")) | |||||
| set(CMAKE_INSTALL_PREFIX ${GE_CODE_DIR}/output CACHE STRING "path for install()" FORCE) | |||||
| message(STATUS "No install prefix selected, default to ${CMAKE_INSTALL_PREFIX}.") | |||||
| endif() | |||||
| set(protobuf_CXXFLAGS "-Wno-maybe-uninitialized -Wno-unused-parameter -fPIC -fstack-protector-all -D_FORTIFY_SOURCE=2 $<$<STREQUAL:${PRODUCT_SIDE},host>:-D_GLIBCXX_USE_CXX11_ABI=0> -O2") | |||||
| 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 | |||||
| #URL http://tfk.inhuawei.com/api/containers/container1/download/protobuf-3.8.0.tar.gz | |||||
| #URL /home/txd/workspace/linux_cmake/pkg/protobuf-3.8.0.tar.gz | |||||
| SOURCE_DIR ${GE_CODE_DIR}/../third_party/protobuf/src/protobuf-3.8.0 | |||||
| CONFIGURE_COMMAND ${CMAKE_COMMAND} | |||||
| -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} | |||||
| -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} | |||||
| -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} | |||||
| -DCMAKE_LINKER=${CMAKE_LINKER} | |||||
| -DCMAKE_AR=${CMAKE_AR} | |||||
| -DCMAKE_RANLIB=${CMAKE_RANLIB} | |||||
| -Dprotobuf_WITH_ZLIB=OFF | |||||
| -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_CXX_FLAGS=${protobuf_CXXFLAGS} -DCMAKE_CXX_LDFLAGS=${protobuf_LDFLAGS} -DCMAKE_INSTALL_PREFIX=${PROTOBUF_STATIC_PKG_DIR} <SOURCE_DIR>/cmake | |||||
| BUILD_COMMAND $(MAKE) | |||||
| INSTALL_COMMAND $(MAKE) install | |||||
| EXCLUDE_FROM_ALL TRUE | |||||
| ) | |||||
| include(GNUInstallDirs) | |||||
| add_library(protobuf_static_lib STATIC IMPORTED) | |||||
| set_target_properties(protobuf_static_lib PROPERTIES | |||||
| IMPORTED_LOCATION ${PROTOBUF_STATIC_PKG_DIR}/${CMAKE_INSTALL_LIBDIR}/libprotobuf.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_dependencies(protobuf_static protobuf_static_build) | |||||
| @@ -0,0 +1,102 @@ | |||||
| if (HAVE_PROTOC) | |||||
| return() | |||||
| endif() | |||||
| include(ExternalProject) | |||||
| include(GNUInstallDirs) | |||||
| #set(CMAKE_INSTALL_PREFIX ${PARSER_DIR}/output) | |||||
| if ((${CMAKE_INSTALL_PREFIX} STREQUAL /usr/local) OR | |||||
| (${CMAKE_INSTALL_PREFIX} STREQUAL "C:/Program Files (x86)/ascend")) | |||||
| set(CMAKE_INSTALL_PREFIX ${PARSER_DIR}/output CACHE STRING "path for install()" FORCE) | |||||
| message(STATUS "No install prefix selected, default to ${CMAKE_INSTALL_PREFIX}.") | |||||
| 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_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack") | |||||
| ExternalProject_Add(protoc_build | |||||
| #URL http://tfk.inhuawei.com/api/containers/container1/download/protobuf-3.8.0.tar.gz | |||||
| #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 | |||||
| CONFIGURE_COMMAND ${CMAKE_COMMAND} -Dprotobuf_WITH_ZLIB=OFF -Dprotobuf_BUILD_TESTS=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_CXX_FLAGS=${protobuf_CXXFLAGS} -DCMAKE_CXX_LDFLAGS=${protobuf_LDFLAGS} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}/protoc <SOURCE_DIR>/cmake | |||||
| BUILD_COMMAND $(MAKE) | |||||
| INSTALL_COMMAND $(MAKE) install | |||||
| EXCLUDE_FROM_ALL TRUE | |||||
| ) | |||||
| set(PROTOC_PKG_DIR ${CMAKE_INSTALL_PREFIX}/protoc) | |||||
| set(protoc_EXECUTABLE ${PROTOC_PKG_DIR}/${CMAKE_INSTALL_BINDIR}/protoc) | |||||
| function(protobuf_generate comp c_var h_var) | |||||
| if(NOT ARGN) | |||||
| message(SEND_ERROR "Error: protobuf_generate() called without any proto files") | |||||
| return() | |||||
| endif() | |||||
| set(${c_var}) | |||||
| set(${h_var}) | |||||
| foreach(file ${ARGN}) | |||||
| get_filename_component(abs_file ${file} ABSOLUTE) | |||||
| get_filename_component(file_name ${file} NAME_WE) | |||||
| get_filename_component(file_dir ${abs_file} PATH) | |||||
| get_filename_component(parent_subdir ${file_dir} NAME) | |||||
| if("${parent_subdir}" STREQUAL "proto") | |||||
| set(proto_output_path ${CMAKE_BINARY_DIR}/proto/${comp}/proto) | |||||
| else() | |||||
| set(proto_output_path ${CMAKE_BINARY_DIR}/proto/${comp}/proto/${parent_subdir}) | |||||
| endif() | |||||
| list(APPEND ${c_var} "${proto_output_path}/${file_name}.pb.cc") | |||||
| list(APPEND ${h_var} "${proto_output_path}/${file_name}.pb.h") | |||||
| add_custom_command( | |||||
| OUTPUT "${proto_output_path}/${file_name}.pb.cc" "${proto_output_path}/${file_name}.pb.h" | |||||
| WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} | |||||
| COMMAND ${CMAKE_COMMAND} -E make_directory "${proto_output_path}" | |||||
| COMMAND ${protoc_EXECUTABLE} -I${file_dir} --cpp_out=${proto_output_path} ${abs_file} | |||||
| DEPENDS protoc_build ${abs_file} | |||||
| COMMENT "Running C++ protocol buffer compiler on ${file}" VERBATIM ) | |||||
| endforeach() | |||||
| set_source_files_properties(${${c_var}} ${${h_var}} PROPERTIES GENERATED TRUE) | |||||
| set(${c_var} ${${c_var}} PARENT_SCOPE) | |||||
| set(${h_var} ${${h_var}} PARENT_SCOPE) | |||||
| endfunction() | |||||
| function(protobuf_generate_py comp py_var) | |||||
| if(NOT ARGN) | |||||
| message(SEND_ERROR "Error: protobuf_generate_py() called without any proto files") | |||||
| return() | |||||
| endif() | |||||
| set(${py_var}) | |||||
| foreach(file ${ARGN}) | |||||
| get_filename_component(abs_file ${file} ABSOLUTE) | |||||
| get_filename_component(file_name ${file} NAME_WE) | |||||
| get_filename_component(file_dir ${abs_file} PATH) | |||||
| get_filename_component(parent_subdir ${file_dir} NAME) | |||||
| if("${parent_subdir}" STREQUAL "proto") | |||||
| set(proto_output_path ${CMAKE_BINARY_DIR}/proto/${comp}/proto) | |||||
| else() | |||||
| set(proto_output_path ${CMAKE_BINARY_DIR}/proto/${comp}/proto/${parent_subdir}) | |||||
| endif() | |||||
| list(APPEND ${py_var} "${proto_output_path}/${file_name}_pb2.py") | |||||
| add_custom_command( | |||||
| OUTPUT "${proto_output_path}/${file_name}_pb2.py" | |||||
| WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} | |||||
| COMMAND ${CMAKE_COMMAND} -E make_directory "${proto_output_path}" | |||||
| COMMAND ${protoc_EXECUTABLE} -I${file_dir} --python_out=${proto_output_path} ${abs_file} | |||||
| DEPENDS protoc_build ${abs_file} | |||||
| COMMENT "Running PYTHON protocol buffer compiler on ${file}" VERBATIM ) | |||||
| endforeach() | |||||
| set_source_files_properties(${${py_var}} PROPERTIES GENERATED TRUE) | |||||
| set(${py_var} ${${py_var}} PARENT_SCOPE) | |||||
| endfunction() | |||||
| set(HAVE_PROTOC TRUE CACHE BOOL "protoc build add") | |||||
| @@ -0,0 +1,60 @@ | |||||
| if (HAVE_C_SEC) | |||||
| return() | |||||
| endif() | |||||
| include(ExternalProject) | |||||
| if ((${CMAKE_INSTALL_PREFIX} STREQUAL /usr/local) OR | |||||
| (${CMAKE_INSTALL_PREFIX} STREQUAL "C:/Program Files (x86)/ascend")) | |||||
| set(CMAKE_INSTALL_PREFIX ${PARSER_DIR}/output CACHE STRING "path for install()" FORCE) | |||||
| message(STATUS "No install prefix selected, default to ${CMAKE_INSTALL_PREFIX}.") | |||||
| endif() | |||||
| ExternalProject_Add(c_sec_build | |||||
| #URL http://tfk.inhuawei.com/api/containers/container1/download/protobuf-3.8.0.tar.gz | |||||
| #URL /home/txd/workspace/linux_cmake/pkg/protobuf-3.8.0.tar.gz | |||||
| SOURCE_DIR ${PARSER_DIR}/../libc_sec | |||||
| CONFIGURE_COMMAND ${CMAKE_COMMAND} | |||||
| -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} | |||||
| -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} | |||||
| -DCMAKE_LINKER=${CMAKE_LINKER} | |||||
| -DCMAKE_AR=${CMAKE_AR} | |||||
| -DCMAKE_RANLIB=${CMAKE_RANLIB} | |||||
| -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}/c_sec <SOURCE_DIR> | |||||
| BUILD_COMMAND $(MAKE) | |||||
| INSTALL_COMMAND $(MAKE) install | |||||
| EXCLUDE_FROM_ALL TRUE | |||||
| ) | |||||
| set(C_SEC_PKG_DIR ${CMAKE_INSTALL_PREFIX}/c_sec) | |||||
| add_library(c_sec SHARED IMPORTED) | |||||
| file(MAKE_DIRECTORY ${C_SEC_PKG_DIR}/include) | |||||
| set_target_properties(c_sec PROPERTIES | |||||
| IMPORTED_LOCATION ${C_SEC_PKG_DIR}/lib/libc_sec.so | |||||
| ) | |||||
| target_include_directories(c_sec INTERFACE ${C_SEC_PKG_DIR}/include) | |||||
| add_dependencies(c_sec c_sec_build) | |||||
| set(INSTALL_BASE_DIR "") | |||||
| set(INSTALL_LIBRARY_DIR lib) | |||||
| install(FILES ${C_SEC_PKG_DIR}/lib/libc_sec.so OPTIONAL | |||||
| DESTINATION ${INSTALL_LIBRARY_DIR}) | |||||
| add_library(c_sec_static_lib STATIC IMPORTED) | |||||
| set_target_properties(c_sec_static_lib PROPERTIES | |||||
| IMPORTED_LOCATION ${C_SEC_PKG_DIR}/lib/libc_sec.a | |||||
| ) | |||||
| add_library(c_sec_static INTERFACE) | |||||
| target_include_directories(c_sec_static INTERFACE ${C_SEC_PKG_DIR}/include) | |||||
| target_link_libraries(c_sec_static INTERFACE c_sec_static_lib) | |||||
| add_dependencies(c_sec_static c_sec_build) | |||||
| set(HAVE_C_SEC TRUE CACHE BOOL "c_sec build add") | |||||
| @@ -0,0 +1,52 @@ | |||||
| add_library(intf_pub INTERFACE) | |||||
| target_compile_options(intf_pub INTERFACE | |||||
| -Wall | |||||
| -fPIC | |||||
| -fstack-protector-strong | |||||
| ) | |||||
| target_compile_definitions(intf_pub INTERFACE | |||||
| $<$<STREQUAL:${PRODUCT_SIDE},host>:_GLIBCXX_USE_CXX11_ABI=0> | |||||
| $<$<CONFIG:Release>:CFG_BUILD_NDEBUG> | |||||
| $<$<CONFIG:Debug>:CFG_BUILD_DEBUG> | |||||
| WIN64=1 | |||||
| LINUX=0 | |||||
| ) | |||||
| target_link_options(intf_pub INTERFACE | |||||
| -Wl,-z,relro | |||||
| -Wl,-z,now | |||||
| -Wl,-z,noexecstack | |||||
| $<$<CONFIG:Release>:-Wl,--build-id=none> | |||||
| ) | |||||
| target_link_directories(intf_pub INTERFACE | |||||
| ) | |||||
| add_library(intf_ccec INTERFACE) | |||||
| target_compile_options(intf_ccec INTERFACE | |||||
| -mcpu=cortex-a73 | |||||
| --target=aarch64-linux-android29 | |||||
| --sysroot=${HCC_PATH}/../sysroot | |||||
| -L${HCC_PATH}/../lib/gcc/aarch64-linux-android/4.9.x | |||||
| -Wall | |||||
| -fPIC | |||||
| -fstack-protector-strong | |||||
| ) | |||||
| target_compile_definitions(intf_ccec INTERFACE | |||||
| $<$<STREQUAL:${PRODUCT_SIDE},host>:_GLIBCXX_USE_CXX11_ABI=0> | |||||
| $<$<CONFIG:Release>:CFG_BUILD_NDEBUG> | |||||
| $<$<CONFIG:Debug>:CFG_BUILD_DEBUG> | |||||
| ) | |||||
| target_link_options(intf_ccec INTERFACE | |||||
| -mcpu=cortex-a73 | |||||
| --target=aarch64-linux-android29 | |||||
| --sysroot=${HCC_PATH}/../sysroot | |||||
| -L${HCC_PATH}/../lib/gcc/aarch64-linux-android/4.9.x | |||||
| -Wl,-cce-host-android | |||||
| -Wl,-z,relro | |||||
| -Wl,-z,now | |||||
| -Wl,-z,noexecstack | |||||
| $<$<CONFIG:Release>:-Wl,--build-id=none> | |||||
| ) | |||||
| @@ -0,0 +1,32 @@ | |||||
| if (HAVE_PUB) | |||||
| return() | |||||
| endif() | |||||
| add_library(intf_pub INTERFACE) | |||||
| target_compile_options(intf_pub INTERFACE | |||||
| -Wall | |||||
| -fPIC | |||||
| $<IF:$<STREQUAL:${CMAKE_SYSTEM_NAME},centos>,-fstack-protector-all,-fstack-protector-strong> | |||||
| $<$<COMPILE_LANGUAGE:CXX>:-std=c++11> | |||||
| ) | |||||
| target_compile_definitions(intf_pub INTERFACE | |||||
| $<$<STREQUAL:${PRODUCT_SIDE},host>:_GLIBCXX_USE_CXX11_ABI=0> | |||||
| $<$<CONFIG:Release>:CFG_BUILD_NDEBUG> | |||||
| $<$<CONFIG:Debug>:CFG_BUILD_DEBUG> | |||||
| WIN64=1 | |||||
| LINUX=0 | |||||
| ) | |||||
| target_link_options(intf_pub INTERFACE | |||||
| -Wl,-z,relro | |||||
| -Wl,-z,now | |||||
| -Wl,-z,noexecstack | |||||
| $<$<CONFIG:Release>:-Wl,--build-id=none> | |||||
| ) | |||||
| target_link_directories(intf_pub INTERFACE | |||||
| ) | |||||
| target_link_libraries(intf_pub INTERFACE | |||||
| -lpthread | |||||
| ) | |||||
| set(HAVE_PUB TRUE CACHE BOOL "pub add") | |||||
| @@ -0,0 +1,24 @@ | |||||
| add_library(intf_pub INTERFACE) | |||||
| target_compile_options(intf_pub INTERFACE | |||||
| -Wall | |||||
| -fPIC | |||||
| $<IF:$<STREQUAL:${OS_TYPE},centos>,-fstack-protector-all,-fstack-protector-strong> | |||||
| $<$<COMPILE_LANGUAGE:CXX>:-std=c++11> | |||||
| ) | |||||
| target_compile_definitions(intf_pub INTERFACE | |||||
| $<$<STREQUAL:${PRODUCT_SIDE},host>:_GLIBCXX_USE_CXX11_ABI=0> | |||||
| OS_TYPE=WIN64 | |||||
| WIN64=1 | |||||
| LINUX=0 | |||||
| $<$<CONFIG:Release>:CFG_BUILD_NDEBUG> | |||||
| $<$<CONFIG:Debug>:CFG_BUILD_DEBUG> | |||||
| ) | |||||
| target_link_options(intf_pub INTERFACE | |||||
| $<$<CONFIG:Release>:-Wl,--build-id=none> | |||||
| ) | |||||
| target_link_directories(intf_pub INTERFACE | |||||
| ) | |||||
| target_link_libraries(intf_pub INTERFACE | |||||
| ) | |||||
| @@ -1,5 +1,5 @@ | |||||
| set(PROTO_LIST | set(PROTO_LIST | ||||
| "${TOP_DIR}/inc/register/proto/tensorflow/graph_library.proto" | |||||
| "${METADEF_DIR}/proto/tensorflow/graph_library.proto" | |||||
| ) | ) | ||||
| set(SRC_LIST | set(SRC_LIST | ||||
| @@ -56,16 +56,25 @@ target_compile_definitions(fmk_parser PRIVATE | |||||
| target_include_directories(fmk_parser PRIVATE | target_include_directories(fmk_parser PRIVATE | ||||
| ${CMAKE_CURRENT_LIST_DIR} | ${CMAKE_CURRENT_LIST_DIR} | ||||
| ${TOP_DIR}/framework/domi | |||||
| ${TOP_DIR}/framework/domi/common | |||||
| ${TOP_DIR}/framework/domi/parser | |||||
| ${TOP_DIR}/inc | |||||
| ${TOP_DIR}/inc/external | |||||
| ${TOP_DIR}/inc/external/parser | |||||
| ${TOP_DIR}/inc/external/graph | |||||
| ${TOP_DIR}/inc/framework | |||||
| ${PARSER_DIR} | |||||
| ${PARSER_DIR}/inc | |||||
| ${PARSER_DIR}/parser | |||||
| ${PARSER_DIR}/../inc | |||||
| ${PARSER_DIR}/../inc/common/util | |||||
| ${METADEF_DIR}/inc | |||||
| ${METADEF_DIR}/inc/graph | |||||
| ${METADEF_DIR}/inc/register | |||||
| ${METADEF_DIR}/inc/external | |||||
| ${METADEF_DIR}/inc/external/graph | |||||
| ${METADEF_DIR}/inc/external/register | |||||
| #### temp #### | |||||
| ${PARSER_DIR}/../graphengine/inc/common/util | |||||
| ${PARSER_DIR}/../graphengine/inc/external | |||||
| ${PARSER_DIR}/../graphengine/inc/framework | |||||
| ${PARSER_DIR}/../graphengine/inc | |||||
| ${PARSER_DIR}/../graphengine/ge | |||||
| ${CMAKE_BINARY_DIR} | ${CMAKE_BINARY_DIR} | ||||
| ${CMAKE_BINARY_DIR}/proto/ge | |||||
| ${CMAKE_BINARY_DIR}/proto/ge | |||||
| ) | ) | ||||
| target_link_libraries(fmk_parser | target_link_libraries(fmk_parser | ||||
| @@ -90,12 +99,12 @@ add_custom_command( | |||||
| OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/stub_tensorflow_parser.cc | OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/stub_tensorflow_parser.cc | ||||
| ${CMAKE_CURRENT_BINARY_DIR}/stub_caffe_parser.cc | ${CMAKE_CURRENT_BINARY_DIR}/stub_caffe_parser.cc | ||||
| COMMAND echo "Generating stub files." | COMMAND echo "Generating stub files." | ||||
| && ${HI_PYTHON} ${CMAKE_CURRENT_LIST_DIR}/../stub/gen_stubapi.py ${TOP_DIR}/inc/external ${CMAKE_CURRENT_BINARY_DIR} | |||||
| && ${HI_PYTHON} ${CMAKE_CURRENT_LIST_DIR}/stub/gen_stubapi.py ${PARSER_DIR}/inc/external ${CMAKE_CURRENT_BINARY_DIR} | |||||
| && mv tensorflow_parser.cc stub_tensorflow_parser.cc | && mv tensorflow_parser.cc stub_tensorflow_parser.cc | ||||
| && mv caffe_parser.cc stub_caffe_parser.cc | && mv caffe_parser.cc stub_caffe_parser.cc | ||||
| && echo "Generating stub files end." | && echo "Generating stub files end." | ||||
| WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} | |||||
| DEPENDS ../stub/gen_stubapi.py ${TOP_DIR}/inc/external ${CMAKE_CURRENT_BINARY_DIR} | |||||
| #WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} | |||||
| #DEPENDS ../stub/gen_stubapi.py ${TOP_DIR}/inc/external ${CMAKE_CURRENT_BINARY_DIR} | |||||
| ) | ) | ||||
| ################################################################## | ################################################################## | ||||
| @@ -119,13 +128,24 @@ target_compile_definitions(fmk_parser_stub PRIVATE | |||||
| target_include_directories(fmk_parser_stub PRIVATE | target_include_directories(fmk_parser_stub PRIVATE | ||||
| ${CMAKE_CURRENT_LIST_DIR} | ${CMAKE_CURRENT_LIST_DIR} | ||||
| ${TOP_DIR}/inc | |||||
| ${TOP_DIR}/inc/external | |||||
| ${TOP_DIR}/inc/external/parser | |||||
| ${TOP_DIR}/inc/external/graph | |||||
| ${TOP_DIR}/inc/framework | |||||
| ${CMAKE_BINARY_DIR} | |||||
| ${CMAKE_CURRENT_BINARY_DIR} | |||||
| ${PARSER_DIR} | |||||
| ${PARSER_DIR}/inc | |||||
| ${PARSER_DIR}/inc/external | |||||
| ${PARSER_DIR}/parser | |||||
| ${PARSER_DIR}/../inc | |||||
| ${PARSER_DIR}/../inc/common/util | |||||
| ${METADEF_DIR}/inc | |||||
| ${METADEF_DIR}/inc/graph | |||||
| ${METADEF_DIR}/inc/register | |||||
| ${METADEF_DIR}/inc/external | |||||
| ${METADEF_DIR}/inc/external/graph | |||||
| ${METADEF_DIR}/inc/external/register | |||||
| #### temp #### | |||||
| ${PARSER_DIR}/../graphengine/inc/common/util | |||||
| ${PARSER_DIR}/../graphengine/inc/external | |||||
| ${PARSER_DIR}/../graphengine/inc/framework | |||||
| ${PARSER_DIR}/../graphengine/inc | |||||
| ${PARSER_DIR}/../graphengine/ge | |||||
| ) | ) | ||||
| target_link_libraries(fmk_parser_stub PRIVATE | target_link_libraries(fmk_parser_stub PRIVATE | ||||
| @@ -0,0 +1,27 @@ | |||||
| set(PROTO_LIST | |||||
| "${METADEF_DIR}/proto/caffe/caffe.proto" | |||||
| ) | |||||
| protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST}) | |||||
| ############ lib_caffe_parser.so ############ | |||||
| add_library(_caffe_parser SHARED ${PROTO_SRCS}) | |||||
| target_include_directories(_caffe_parser PRIVATE | |||||
| ${CMAKE_CURRENT_LIST_DIR} | |||||
| ) | |||||
| target_link_libraries(_caffe_parser PRIVATE | |||||
| $<BUILD_INTERFACE:intf_pub> | |||||
| -Wl,--no-as-needed | |||||
| protobuf | |||||
| -Wl,--as-needed | |||||
| ) | |||||
| ############ install ############ | |||||
| set(INSTALL_BASE_DIR "") | |||||
| set(INSTALL_LIBRARY_DIR lib) | |||||
| install(TARGETS _caffe_parser OPTIONAL | |||||
| LIBRARY DESTINATION ${INSTALL_LIBRARY_DIR} | |||||
| ) | |||||
| @@ -39,14 +39,22 @@ target_compile_definitions(parser_common PRIVATE | |||||
| target_include_directories(parser_common PRIVATE | target_include_directories(parser_common PRIVATE | ||||
| ${CMAKE_CURRENT_LIST_DIR} | ${CMAKE_CURRENT_LIST_DIR} | ||||
| ${TOP_DIR}/framework/domi | |||||
| ${TOP_DIR}/framework/domi/common | |||||
| ${TOP_DIR}/framework/domi/parser | |||||
| ${TOP_DIR}/inc | |||||
| ${TOP_DIR}/inc/common/util | |||||
| ${TOP_DIR}/inc/external | |||||
| ${TOP_DIR}/inc/external/graph | |||||
| ${TOP_DIR}/inc/framework | |||||
| ${PARSER_DIR} | |||||
| ${PARSER_DIR}/parser | |||||
| ${PARSER_DIR}/../inc | |||||
| ${PARSER_DIR}/../inc/common/util | |||||
| ${METADEF_DIR}/inc | |||||
| ${METADEF_DIR}/inc/graph | |||||
| ${METADEF_DIR}/inc/register | |||||
| ${METADEF_DIR}/inc/external | |||||
| ${METADEF_DIR}/inc/external/graph | |||||
| ${METADEF_DIR}/inc/external/register | |||||
| #### temp #### | |||||
| ${PARSER_DIR}/../graphengine/inc/common/util | |||||
| ${PARSER_DIR}/../graphengine/inc/external | |||||
| ${PARSER_DIR}/../graphengine/inc/framework | |||||
| ${PARSER_DIR}/../graphengine/inc | |||||
| ${PARSER_DIR}/../graphengine/ge | |||||
| ${CMAKE_BINARY_DIR} | ${CMAKE_BINARY_DIR} | ||||
| ${CMAKE_BINARY_DIR}/proto/ge | ${CMAKE_BINARY_DIR}/proto/ge | ||||
| ) | ) | ||||
| @@ -1,15 +1,15 @@ | |||||
| set(PROTO_LIST | set(PROTO_LIST | ||||
| "${TOP_DIR}/inc/register/proto/tensorflow/graph.proto" | |||||
| "${TOP_DIR}/inc/register/proto/tensorflow/node_def.proto" | |||||
| "${TOP_DIR}/inc/register/proto/tensorflow/tensor_shape.proto" | |||||
| "${TOP_DIR}/inc/register/proto/tensorflow/attr_value.proto" | |||||
| "${TOP_DIR}/inc/register/proto/tensorflow/function.proto" | |||||
| "${TOP_DIR}/inc/register/proto/tensorflow/op_def.proto" | |||||
| "${TOP_DIR}/inc/register/proto/tensorflow/resource_handle.proto" | |||||
| "${TOP_DIR}/inc/register/proto/tensorflow/tensor.proto" | |||||
| "${TOP_DIR}/inc/register/proto/tensorflow/types.proto" | |||||
| "${TOP_DIR}/inc/register/proto/tensorflow/versions.proto" | |||||
| "${TOP_DIR}/inc/register/proto/tensorflow/graph_library.proto" | |||||
| "${METADEF_DIR}/proto/tensorflow/graph.proto" | |||||
| "${METADEF_DIR}/proto/tensorflow/node_def.proto" | |||||
| "${METADEF_DIR}/proto/tensorflow/tensor_shape.proto" | |||||
| "${METADEF_DIR}/proto/tensorflow/attr_value.proto" | |||||
| "${METADEF_DIR}/proto/tensorflow/function.proto" | |||||
| "${METADEF_DIR}/proto/tensorflow/op_def.proto" | |||||
| "${METADEF_DIR}/proto/tensorflow/resource_handle.proto" | |||||
| "${METADEF_DIR}/proto/tensorflow/tensor.proto" | |||||
| "${METADEF_DIR}/proto/tensorflow/types.proto" | |||||
| "${METADEF_DIR}/proto/tensorflow/versions.proto" | |||||
| "${METADEF_DIR}/proto/tensorflow/graph_library.proto" | |||||
| ) | ) | ||||
| protobuf_generate_py(ge PROTO_SRCS ${PROTO_LIST}) | protobuf_generate_py(ge PROTO_SRCS ${PROTO_LIST}) | ||||
| @@ -1,6 +1,6 @@ | |||||
| set(PROTO_LIST | set(PROTO_LIST | ||||
| "${TOP_DIR}/inc/register/proto/onnx/ge_onnx.proto" | |||||
| "${TOP_DIR}/inc/common/proto/om.proto" | |||||
| "${METADEF_DIR}/proto/onnx/ge_onnx.proto" | |||||
| "${METADEF_DIR}/proto/om.proto" | |||||
| ) | ) | ||||
| set(SRC_LIST | set(SRC_LIST | ||||
| @@ -26,12 +26,23 @@ target_compile_definitions(fmk_onnx_parser PRIVATE | |||||
| target_include_directories(fmk_onnx_parser PRIVATE | target_include_directories(fmk_onnx_parser PRIVATE | ||||
| ${CMAKE_CURRENT_LIST_DIR} | ${CMAKE_CURRENT_LIST_DIR} | ||||
| ${TOP_DIR}/framework/domi/parser | |||||
| ${TOP_DIR}/framework/domi | |||||
| ${TOP_DIR}/inc | |||||
| ${TOP_DIR}/inc/external | |||||
| ${TOP_DIR}/inc/external/graph | |||||
| ${TOP_DIR}/inc/framework | |||||
| ${PARSER_DIR} | |||||
| ${PARSER_DIR}/inc | |||||
| ${PARSER_DIR}/parser | |||||
| ${PARSER_DIR}/../inc | |||||
| ${PARSER_DIR}/../inc/common/util | |||||
| ${METADEF_DIR}/inc | |||||
| ${METADEF_DIR}/inc/graph | |||||
| ${METADEF_DIR}/inc/register | |||||
| ${METADEF_DIR}/inc/external | |||||
| ${METADEF_DIR}/inc/external/graph | |||||
| ${METADEF_DIR}/inc/external/register | |||||
| #### temp #### | |||||
| ${PARSER_DIR}/../graphengine/inc/common/util | |||||
| ${PARSER_DIR}/../graphengine/inc/external | |||||
| ${PARSER_DIR}/../graphengine/inc/framework | |||||
| ${PARSER_DIR}/../graphengine/inc | |||||
| ${PARSER_DIR}/../graphengine/ge | |||||
| ${CMAKE_BINARY_DIR} | ${CMAKE_BINARY_DIR} | ||||
| ${CMAKE_BINARY_DIR}/proto/ge | ${CMAKE_BINARY_DIR}/proto/ge | ||||
| ) | ) | ||||