Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
snnn committed Jul 17, 2024
1 parent 6c7562b commit 1222316
Showing 1 changed file with 11 additions and 40 deletions.
51 changes: 11 additions & 40 deletions js/node/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,11 @@ endif()
file(GLOB ORT_NODEJS_BINDING_SOURCE_FILES ${CMAKE_SOURCE_DIR}/src/*.cc)

add_library(onnxruntime_binding SHARED ${ORT_NODEJS_BINDING_SOURCE_FILES} ${CMAKE_JS_SRC})
file(MAKE_DIRECTORY ${dist_folder})

set_target_properties(onnxruntime_binding PROPERTIES
PREFIX "" SUFFIX ".node"
RUNTIME_OUTPUT_DIRECTORY ${dist_folder}
BUILD_WITH_INSTALL_RPATH TRUE
INSTALL_RPATH_USE_LINK_PATH FALSE)
target_link_libraries(onnxruntime_binding PRIVATE ${CMAKE_JS_LIB})
Expand Down Expand Up @@ -95,52 +98,20 @@ else()
set_target_properties(onnxruntime_binding PROPERTIES INSTALL_RPATH "$ORIGIN/")
endif()

# post build

add_custom_command(
TARGET onnxruntime_binding POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${dist_folder}
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:onnxruntime_binding> ${dist_folder}
)

if (WIN32)
add_custom_command(
TARGET onnxruntime_binding POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${ONNXRUNTIME_WIN_BIN_DIR}/onnxruntime.dll
${dist_folder}
)
file(COPY ${ONNXRUNTIME_WIN_BIN_DIR}/onnxruntime.dll
DESTINATION ${dist_folder})
if (USE_DML)
add_custom_command(
TARGET onnxruntime_binding POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${ONNXRUNTIME_WIN_BIN_DIR}/DirectML.dll
${dist_folder}
)
file(COPY ${ONNXRUNTIME_WIN_BIN_DIR}/DirectML.dll
DESTINATION ${dist_folder})
endif ()
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
add_custom_command(
TARGET onnxruntime_binding POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${ONNXRUNTIME_WIN_BIN_DIR}/onnxruntime.pdb
${dist_folder}
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE_DIR:onnxruntime_binding>/onnxruntime_binding.pdb ${dist_folder}
)
endif()
elseif (APPLE)
add_custom_command(
TARGET onnxruntime_binding POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${ONNXRUNTIME_BUILD_DIR}/libonnxruntime.${ort_version}.dylib
${dist_folder}
)
file(COPY ${ONNXRUNTIME_BUILD_DIR}/libonnxruntime.dylib
DESTINATION ${dist_folder} FOLLOW_SYMLINK_CHAIN)
elseif (UNIX)
add_custom_command(
TARGET onnxruntime_binding POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${ONNXRUNTIME_BUILD_DIR}/libonnxruntime.so.${ort_version}
${dist_folder}
)
file(COPY ${ONNXRUNTIME_BUILD_DIR}/libonnxruntime.so
DESTINATION ${dist_folder} FOLLOW_SYMLINK_CHAIN)
else()
message(FATAL_ERROR "Platform not supported.")
endif()

0 comments on commit 1222316

Please sign in to comment.