增加MNN模型支持
This commit is contained in:
@ -10,7 +10,7 @@ if(NOT DEFINED CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Release)
|
||||
endif()
|
||||
|
||||
|
||||
set(NODE_COMMON_SOURCES)
|
||||
set(NODE_ADDON_FOUND OFF)
|
||||
|
||||
include_directories(cxx)
|
||||
@ -74,10 +74,15 @@ if(EXISTS ${MNN_CMAKE_FILE})
|
||||
message(STATUS "MNN_LIB_DIR: ${MNN_LIB_DIR}")
|
||||
message(STATUS "MNN_INCLUDE_DIR: ${MNN_INCLUDE_DIR}")
|
||||
message(STATUS "MNN_LIBS: ${MNN_LIBS}")
|
||||
include_directories(${MNN_INCLUDE_DIRS})
|
||||
include_directories(${MNN_INCLUDE_DIR})
|
||||
link_directories(${MNN_LIB_DIR})
|
||||
add_compile_definitions(USE_MNN)
|
||||
set(USE_MNN ON)
|
||||
|
||||
if(NODE_ADDON_FOUND)
|
||||
add_node_targert(mnn cxx/mnn/node.cc)
|
||||
target_link_libraries(mnn ${MNN_LIBS})
|
||||
target_compile_definitions(mnn PUBLIC USE_MNN)
|
||||
list(APPEND NODE_COMMON_SOURCES cxx/mnn/node.cc)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# OpenCV
|
||||
@ -94,6 +99,7 @@ if(EXISTS ${OpenCV_CMAKE_FILE})
|
||||
add_node_targert(cv cxx/cv/node.cc)
|
||||
target_link_libraries(cv ${OpenCV_LIBS})
|
||||
target_compile_definitions(cv PUBLIC USE_OPENCV)
|
||||
list(APPEND NODE_COMMON_SOURCES cxx/cv/node.cc)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@ -111,12 +117,34 @@ if(EXISTS ${ONNXRuntime_CMAKE_FILE})
|
||||
add_node_targert(ort cxx/ort/node.cc)
|
||||
target_link_libraries(ort ${ONNXRuntime_LIBS})
|
||||
target_compile_definitions(ort PUBLIC USE_ONNXRUNTIME)
|
||||
list(APPEND NODE_COMMON_SOURCES cxx/ort/node.cc)
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
# 统一的NodeJS插件
|
||||
if(NODE_ADDON_FOUND)
|
||||
add_node_targert(addon cxx/node.cc)
|
||||
target_sources(addon PRIVATE ${NODE_COMMON_SOURCES})
|
||||
target_compile_definitions(addon PUBLIC BUILD_MAIN_WORD)
|
||||
# MNN
|
||||
if(EXISTS ${MNN_CMAKE_FILE})
|
||||
target_link_libraries(addon ${MNN_LIBS})
|
||||
target_compile_definitions(addon PUBLIC USE_MNN)
|
||||
endif()
|
||||
# OnnxRuntime
|
||||
if(EXISTS ${ONNXRuntime_CMAKE_FILE})
|
||||
target_link_libraries(addon ${ONNXRuntime_LIBS})
|
||||
target_compile_definitions(addon PUBLIC USE_ONNXRUNTIME)
|
||||
endif()
|
||||
# OpenCV
|
||||
if(EXISTS ${OpenCV_CMAKE_FILE})
|
||||
target_link_libraries(addon ${OpenCV_LIBS})
|
||||
target_compile_definitions(addon PUBLIC USE_OPENCV)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
if(MSVC AND NODE_ADDON_FOUND)
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
|
||||
execute_process(COMMAND ${CMAKE_AR} /def:${CMAKE_JS_NODELIB_DEF} /out:${CMAKE_JS_NODELIB_TARGET} ${CMAKE_STATIC_LINKER_FLAGS})
|
||||
endif()
|
||||
|
Reference in New Issue
Block a user