1message(STATUS "Compiling GraphEngine") 2if(NOT(BUILD_LITE)) 3 set(GE_SOURCE_DIR ${CMAKE_SOURCE_DIR}/graphengine) 4else() 5 set(GE_SOURCE_DIR ${CMAKE_SOURCE_DIR}/../../graphengine) 6endif() 7 8message(STATUS "[ME] build_path: ${BUILD_PATH}") 9 10function(find_submodule_lib module name path) 11 find_library(${module}_LIBRARY_DIR NAMES ${name} NAMES_PER_DIR PATHS ${path} 12 PATH_SUFFIXES lib 13 ) 14 if("${${module}_LIBRARY_DIR}" STREQUAL "${module}_LIBRARY_DIR-NOTFOUND") 15 message(FATAL_ERROR "${name} not found in any of following paths: ${path}") 16 endif() 17 add_library(${module} SHARED IMPORTED) 18 set_target_properties(${module} PROPERTIES 19 IMPORTED_LOCATION ${${module}_LIBRARY_DIR} 20 ) 21endfunction() 22 23function(ge_protobuf_generate c_var h_var) 24 common_protobuf_generate(${CMAKE_BINARY_DIR}/proto/ge/proto ${c_var} ${h_var} ${ARGN}) 25 set(${c_var} ${${c_var}} PARENT_SCOPE) 26 set(${h_var} ${${h_var}} PARENT_SCOPE) 27endfunction() 28 29if(ENABLE_TESTCASES) 30 set(_ge_tmp_CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) 31 set(_ge_tmp_ENABLE_GITEE ${ENABLE_GITEE}) 32 set(_ge_tmp_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) 33 set(ENABLE_GITEE ON) 34 set(CMAKE_INSTALL_PREFIX ${BUILD_PATH}/graphengine) 35 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__FILE__='\"$(subst $(realpath ${CMAKE_SOURCE_DIR})/,,$(abspath $<))\"' \ 36 -Wno-builtin-macro-redefined") 37 38 if(ENABLE_TESTCASES) 39 # use slog, error manager, mmpa in non ascend mode, e.g. tests 40 set(GE_PREBUILD_PATH ${GE_SOURCE_DIR}/third_party/prebuild/${CMAKE_HOST_SYSTEM_PROCESSOR}) 41 set(ENABLE_MS_TESTCASES TRUE) 42 find_submodule_lib(slog libalog.so ${GE_PREBUILD_PATH}) 43 find_submodule_lib(static_mmpa libmmpa.a ${GE_PREBUILD_PATH}) 44 endif() 45 46 string(REPLACE " -Werror" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 47 add_subdirectory(${GE_SOURCE_DIR}) 48 set(CMAKE_INSTALL_PREFIX ${_ge_tmp_CMAKE_INSTALL_PREFIX}) 49 set(ENABLE_GITEE ${_ge_tmp_ENABLE_GITEE}) 50 set(CMAKE_CXX_FLAGS ${_ge_tmp_CMAKE_CXX_FLAGS}) 51elseif(MODE_ASCEND_ALL OR MODE_ASCEND_ACL) 52 if(NOT(BUILD_LITE)) 53 file(GLOB_RECURSE GE_PROTO_FILE RELATIVE ${CMAKE_SOURCE_DIR} "graphengine/metadef/proto/*.proto") 54 else() 55 file(GLOB_RECURSE GE_PROTO_FILE ${TOP_DIR}/graphengine/metadef/proto/*.proto) 56 endif() 57 set(TMP_FILE_NAME_LIST) 58 foreach(file ${GE_PROTO_FILE}) 59 get_filename_component(file_name ${file} NAME_WE) 60 list(FIND TMP_FILE_NAME_LIST ${file_name} OUT_VAR) 61 if(NOT ${OUT_VAR} EQUAL "-1") 62 list(REMOVE_ITEM GE_PROTO_FILE ${file}) 63 endif() 64 list(APPEND TMP_FILE_NAME_LIST ${file_name}) 65 endforeach() 66 ge_protobuf_generate(GE_PROTO_SRCS GE_PROTO_HDRS ${GE_PROTO_FILE}) 67 add_library(graph SHARED ${GE_PROTO_SRCS}) 68else() 69 message(FATAL_ERROR "No compile option defined for GraphEngine, exiting") 70endif() 71