add ncnn custom ops to sdk (#284)

pull/1/head
lvhan028 2021-12-15 21:34:32 +08:00 committed by GitHub
parent 3eabeae071
commit 75b5939471
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 16 deletions

View File

@ -2,7 +2,7 @@
cmake_minimum_required(VERSION 3.14) cmake_minimum_required(VERSION 3.14)
project(mmdeploy_ncnn_net) project(mmdeploy_ncnn_net)
if ("cpu" IN_LIST MMDEPLOY_TARGET_DEVICES) if("cpu" IN_LIST MMDEPLOY_TARGET_DEVICES)
include(${CMAKE_SOURCE_DIR}/cmake/common.cmake) include(${CMAKE_SOURCE_DIR}/cmake/common.cmake)
set_targets(${PROJECT_NAME} NCNN_NET_OBJ NCNN_NET_STATIC NCNN_NET_SHARED) set_targets(${PROJECT_NAME} NCNN_NET_OBJ NCNN_NET_STATIC NCNN_NET_SHARED)
@ -10,17 +10,20 @@ if ("cpu" IN_LIST MMDEPLOY_TARGET_DEVICES)
find_package(ncnn REQUIRED) find_package(ncnn REQUIRED)
build_object_target(${NCNN_NET_OBJ} ncnn_net.cpp) build_object_target(${NCNN_NET_OBJ} ncnn_net.cpp)
target_link_libraries(${NCNN_NET_OBJ} PRIVATE target_link_libraries(${NCNN_NET_OBJ} PRIVATE mmdeploy::core::static ncnn)
mmdeploy::core::static
ncnn)
build_static_target(${NCNN_NET_STATIC} ${NCNN_NET_OBJ} "PUBLIC") build_static_target(${NCNN_NET_STATIC} ${NCNN_NET_OBJ} "PUBLIC")
add_library(mmdeploy::ncnn_net::static ALIAS ${NCNN_NET_STATIC}) add_library(mmdeploy::ncnn_net::static ALIAS ${NCNN_NET_STATIC})
build_shared_target(${NCNN_NET_SHARED} ${NCNN_NET_OBJ} "PRIVATE") build_shared_target(${NCNN_NET_SHARED} ${NCNN_NET_OBJ} "PRIVATE")
target_link_libraries(
${NCNN_NET_SHARED} PRIVATE -Wl,--whole-archive mmdeploy::ncnn_ops::static
-Wl,--no-whole-archive)
add_library(mmdeploy::ncnn_net ALIAS ${NCNN_NET_SHARED}) add_library(mmdeploy::ncnn_net ALIAS ${NCNN_NET_SHARED})
export_module(${NCNN_NET_STATIC} ${NCNN_NET_SHARED} ${NCNN_NET_OBJ}) export_module(${NCNN_NET_STATIC} ${NCNN_NET_SHARED} ${NCNN_NET_OBJ})
else () else()
message(ERROR "'ncnn_net' is NOT supported in target devices: ${MMDEPLOY_TARGET_DEVICES}") message(
endif () ERROR
"'ncnn_net' is NOT supported in target devices: ${MMDEPLOY_TARGET_DEVICES}")
endif()