代码拉取完成,页面将自动刷新
cmake_minimum_required(VERSION 3.11)
project (onnxjs-node)
set(CMAKE_CXX_STANDARD 14)
message(${CMAKE_SOURCE_DIR})
include_directories(${CMAKE_JS_INC})
include_directories(${CMAKE_SOURCE_DIR}/onnxruntime/inc)
include_directories(${CMAKE_SOURCE_DIR}/node_modules/node-addon-api)
file(GLOB SOURCE_FILES ${CMAKE_SOURCE_DIR}/src/*.cc)
# CPU
add_library(onnxruntime SHARED ${SOURCE_FILES})
set_target_properties(onnxruntime PROPERTIES
PREFIX "" SUFFIX ".node"
BUILD_WITH_INSTALL_RPATH TRUE
INSTALL_RPATH_USE_LINK_PATH FALSE
)
target_link_libraries(onnxruntime PRIVATE ${CMAKE_JS_LIB})
if (WIN32)
target_link_libraries(onnxruntime PRIVATE ${CMAKE_SOURCE_DIR}/onnxruntime/bin/win-x64/onnxruntime.lib)
elseif (APPLE)
target_link_libraries(onnxruntime PRIVATE ${CMAKE_SOURCE_DIR}/onnxruntime/bin/darwin-x64/libonnxruntime.0.4.0.dylib)
set_target_properties(onnxruntime PROPERTIES INSTALL_RPATH "@loader_path")
else()
target_link_libraries(onnxruntime PRIVATE ${CMAKE_SOURCE_DIR}/onnxruntime/bin/linux-x64/libonnxruntime.so.0.4.0)
set_target_properties(onnxruntime PROPERTIES INSTALL_RPATH "$ORIGIN/")
endif()
# GPU
if (NOT APPLE)
add_library(onnxruntime_gpu SHARED ${SOURCE_FILES})
set_target_properties(onnxruntime_gpu PROPERTIES
PREFIX "" SUFFIX ".node"
BUILD_WITH_INSTALL_RPATH TRUE
INSTALL_RPATH_USE_LINK_PATH FALSE
)
target_link_libraries(onnxruntime_gpu PRIVATE ${CMAKE_JS_LIB})
if (WIN32)
target_link_libraries(onnxruntime_gpu PRIVATE ${CMAKE_SOURCE_DIR}/onnxruntime/bin/win_gpu-x64/onnxruntime.lib)
else()
target_link_libraries(onnxruntime_gpu PRIVATE ${CMAKE_SOURCE_DIR}/onnxruntime/bin/linux_gpu-x64/libonnxruntime.so.0.4.0)
set_target_properties(onnxruntime_gpu PROPERTIES INSTALL_RPATH "$ORIGIN/")
endif()
endif()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。