onnxruntime/cmake/onnxruntime_providers_rknpu...

44 строки
2.1 KiB
CMake

# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-variable -Wno-unused-parameter")
add_definitions(-DUSE_RKNPU=1)
option(DNN_READ_ONNX "" ON)
set(DNN_CUSTOM_PROTOC_EXECUTABLE ${ONNX_CUSTOM_PROTOC_EXECUTABLE})
option(DNN_CMAKE_INSTALL "" OFF)
option(DNN_BUILD_BIN "" OFF)
if (NOT RKNPU_DDK_PATH)
message(FATAL_ERROR "RKNPU_DDK_PATH required for onnxruntime_USE_RKNPU")
endif()
set(RKNPU_DDK_INCLUDE_DIR ${RKNPU_DDK_PATH}/include)
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
set(RKNPU_DDK_LIB_DIR ${RKNPU_DDK_PATH}/lib64)
else()
set(RKNPU_DDK_LIB_DIR ${RKNPU_DDK_PATH}/lib)
endif()
file(GLOB_RECURSE
onnxruntime_providers_rknpu_cc_srcs CONFIGURE_DEPENDS
"${ONNXRUNTIME_ROOT}/core/providers/rknpu/*.h"
"${ONNXRUNTIME_ROOT}/core/providers/rknpu/*.cc"
)
source_group(TREE ${ONNXRUNTIME_ROOT}/core FILES ${onnxruntime_providers_rknpu_cc_srcs})
onnxruntime_add_static_library(onnxruntime_providers_rknpu ${onnxruntime_providers_rknpu_cc_srcs})
onnxruntime_add_include_to_target(onnxruntime_providers_rknpu
onnxruntime_common onnxruntime_framework onnx onnx_proto ${PROTOBUF_LIB} flatbuffers::flatbuffers Boost::mp11 safeint_interface
)
target_link_libraries(onnxruntime_providers_rknpu PRIVATE -lrknpu_ddk)
add_dependencies(onnxruntime_providers_rknpu onnx ${onnxruntime_EXTERNAL_DEPENDENCIES})
set_target_properties(onnxruntime_providers_rknpu PROPERTIES FOLDER "ONNXRuntime")
target_include_directories(onnxruntime_providers_rknpu PRIVATE
${ONNXRUNTIME_ROOT} ${rknpu_INCLUDE_DIRS} ${RKNPU_DDK_INCLUDE_DIR}
)
link_directories(onnxruntime_providers_rknpu ${RKNPU_DDK_LIB_DIR})
set_target_properties(onnxruntime_providers_rknpu PROPERTIES LINKER_LANGUAGE CXX)
if (NOT onnxruntime_BUILD_SHARED_LIB)
install(TARGETS onnxruntime_providers_rknpu
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
FRAMEWORK DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()