diff --git a/_cmake/externals/FindOrt.cmake b/_cmake/externals/FindOrt.cmake index 4da06c38..fd39ca29 100644 --- a/_cmake/externals/FindOrt.cmake +++ b/_cmake/externals/FindOrt.cmake @@ -133,19 +133,19 @@ function(ort_add_dependency name folder_copy) foreach(file_i ${ORT_LIB_FILES}) message(STATUS "ort: copy ${file_i} to '${destination_dir}'") add_custom_command( - TARGET ${name} POST_BUILD + TARGET ${name} PRE_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy ${file_i} ${destination_dir}) if(folder_copy) message(STATUS "ort: copy '${file_i}' to '${ROOT_PROJECT_PATH}/${folder_copy}'") add_custom_command( - TARGET ${name} POST_BUILD + TARGET ${name} PRE_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy "${file_i}" "${ROOT_PROJECT_PATH}/${folder_copy}") message(STATUS "ort: copy '${file_i}' to '${SETUP_BUILD_LIB}/${folder_copy}'") add_custom_command( - TARGET ${name} POST_BUILD + TARGET ${name} PRE_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E make_directory "${SETUP_BUILD_LIB}/${folder_copy}") add_custom_command( - TARGET ${name} POST_BUILD + TARGET ${name} PRE_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy "${file_i}" "${SETUP_BUILD_LIB}/${folder_copy}") endif() endforeach() diff --git a/_cmake/targets/ortinf.cmake b/_cmake/targets/ortinf.cmake index 28cbf4c0..4365ff51 100644 --- a/_cmake/targets/ortinf.cmake +++ b/_cmake/targets/ortinf.cmake @@ -11,12 +11,23 @@ target_include_directories( ${ROOT_INCLUDE_PATH}) target_link_libraries(lib_ortapi PRIVATE common) +set(ORTAPI_INCLUDE_DIR "${ROOT_PROJECT_PATH}/onnx_extended/ortcy/wrap") + cython_add_module( ortinf ../onnx_extended/ortcy/wrap/ortinf.pyx OpenMP::OpenMP_CXX) -target_link_directories(ortinf PRIVATE ${ONNXRUNTIME_LIB_DIR}) -message(STATUS " LINK ortinf <- lib_ortapi onnxruntime") + +message(STATUS " LINK ortinf <- lib_ortapi onnxruntime ${ORTAPI_INCLUDE_DIR}") + +ort_add_dependency( + ortinf + onnx_extended/ortcy/wrap) + +# If ONNXRUNTIME_LIB_DIR is used, then it seems a local installation does +# does not the binaries anymore if they are removed. +target_link_directories(ortinf PRIVATE ${ORTAPI_INCLUDE_DIR}) + target_link_libraries( ortinf PRIVATE @@ -24,11 +35,6 @@ target_link_libraries( onnxruntime common_kernels) target_include_directories(ortinf PRIVATE ${ROOT_INCLUDE_PATH}) -ort_add_dependency( - ortinf - onnx_extended/ortcy/wrap) - -set(ORTAPI_INCLUDE_DIR "${ROOT_INCLUDE_PATH}/onnx_extended/ortcy/wrap") add_executable(test_ortcy_inference_cpp ../_unittests/ut_ortcy/test_inference.cpp) target_compile_definitions(test_ortcy_inference_cpp PRIVATE PYTHON_MANYLINUX=${PYTHON_MANYLINUX})