From 12223163e43548bf4933d09b74e5ba55fcdcb18f Mon Sep 17 00:00:00 2001 From: Changming Sun Date: Wed, 17 Jul 2024 23:23:26 +0000 Subject: [PATCH] update --- js/node/CMakeLists.txt | 51 +++++++++--------------------------------- 1 file changed, 11 insertions(+), 40 deletions(-) diff --git a/js/node/CMakeLists.txt b/js/node/CMakeLists.txt index 5c32f62f3a802..e0f9465565ab6 100644 --- a/js/node/CMakeLists.txt +++ b/js/node/CMakeLists.txt @@ -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}) @@ -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 $ ${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 $/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()