diff --git a/cmake_files/LookUpONNXRT.cmake b/cmake_files/LookUpONNXRT.cmake index 17b2e9695..3d2e14681 100644 --- a/cmake_files/LookUpONNXRT.cmake +++ b/cmake_files/LookUpONNXRT.cmake @@ -1,5 +1,25 @@ find_package(onnxruntime QUIET) + +if(${onnxruntime_FOUND} AND NOT onnxruntime_INCLUDE_DIR) + find_path(onnxruntime_INCLUDE_DIR NAMES onnxruntime_cxx_api.h + HINTS + ENV onnxruntime_ROOT + ENV onnxruntime_ROOT_DIR + ${CMAKE_INSTALL_PREFIX}/include + ${KDE4_INCLUDE_DIR} + PATH_SUFFIXES onnxruntime + ) + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(onnxruntime DEFAULT_MSG onnxruntime_INCLUDE_DIR TRUE) + set(onnxruntime_LIBRARIES onnxruntime) + get_filename_component(onnxruntime_INSTALL_PREFIX "${onnxruntime_INCLUDE_DIR}/../../" ABSOLUTE) + find_library(onnxruntime_LIBRARY onnxruntime PATHS "${onnxruntime_INSTALL_PREFIX}/lib") + add_library(${onnxruntime_LIBRARIES} SHARED IMPORTED) + set_target_properties(${onnxruntime_LIBRARIES} PROPERTIES IMPORTED_LOCATION "${onnxruntime_LIBRARY}") + set_target_properties(${onnxruntime_LIBRARIES} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${onnxruntime_INCLUDE_DIR}") +endif() + if(NOT ${onnxruntime_FOUND}) message(STATUS "ONNXrt not found. Attempt to install...") EXECUTE_PROCESS( COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE ARCH ) @@ -30,9 +50,6 @@ if(NOT ${onnxruntime_FOUND}) set(onnxruntime_LIBRARIES onnxruntime) add_library(${onnxruntime_LIBRARIES} SHARED IMPORTED GLOBAL) set_target_properties(${onnxruntime_LIBRARIES} PROPERTIES IMPORTED_LOCATION ${onnxruntime_LIBRARY_DIR}/libonnxruntime.so) - message(STATUS "ORT-INCDIR=${onnxruntime_INCLUDE_DIR}") - message(STATUS "ORT-LIBDIR=${onnxruntime_LIBRARY_DIR}") - message(STATUS "ORT-LIB=${onnxruntime_LIBRARIES}") set(onnxruntime_FOUND TRUE) endif()