Skip to content

Commit

Permalink
add ncnn custom ops to sdk (open-mmlab#284)
Browse files Browse the repository at this point in the history
  • Loading branch information
lvhan028 authored Dec 15, 2021
1 parent 3eabeae commit 75b5939
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions csrc/net/ncnn/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,28 @@
cmake_minimum_required(VERSION 3.14)
project(mmdeploy_ncnn_net)

if ("cpu" IN_LIST MMDEPLOY_TARGET_DEVICES)
include(${CMAKE_SOURCE_DIR}/cmake/common.cmake)
if("cpu" IN_LIST MMDEPLOY_TARGET_DEVICES)
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)

find_package(ncnn REQUIRED)
find_package(ncnn REQUIRED)

build_object_target(${NCNN_NET_OBJ} ncnn_net.cpp)
target_link_libraries(${NCNN_NET_OBJ} PRIVATE
mmdeploy::core::static
ncnn)
build_object_target(${NCNN_NET_OBJ} ncnn_net.cpp)
target_link_libraries(${NCNN_NET_OBJ} PRIVATE mmdeploy::core::static ncnn)

build_static_target(${NCNN_NET_STATIC} ${NCNN_NET_OBJ} "PUBLIC")
add_library(mmdeploy::ncnn_net::static ALIAS ${NCNN_NET_STATIC})
build_static_target(${NCNN_NET_STATIC} ${NCNN_NET_OBJ} "PUBLIC")
add_library(mmdeploy::ncnn_net::static ALIAS ${NCNN_NET_STATIC})

build_shared_target(${NCNN_NET_SHARED} ${NCNN_NET_OBJ} "PRIVATE")
add_library(mmdeploy::ncnn_net ALIAS ${NCNN_NET_SHARED})
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})

export_module(${NCNN_NET_STATIC} ${NCNN_NET_SHARED} ${NCNN_NET_OBJ})
else ()
message(ERROR "'ncnn_net' is NOT supported in target devices: ${MMDEPLOY_TARGET_DEVICES}")
endif ()
export_module(${NCNN_NET_STATIC} ${NCNN_NET_SHARED} ${NCNN_NET_OBJ})
else()
message(
ERROR
"'ncnn_net' is NOT supported in target devices: ${MMDEPLOY_TARGET_DEVICES}")
endif()

0 comments on commit 75b5939

Please sign in to comment.