diff options
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/FindONNXRuntime.cmake | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/cmake/FindONNXRuntime.cmake b/cmake/FindONNXRuntime.cmake index 733bdb36..f485ecdd 100644 --- a/cmake/FindONNXRuntime.cmake +++ b/cmake/FindONNXRuntime.cmake @@ -13,10 +13,9 @@ # Output variable # --------------- # -# ONNXRuntime_FOUND Variable indicating that ONNXRuntime has been -# found. -# ONNXRuntime_LIBRARIES Library implementing ONNXRuntime -# ONNXRuntime_INCLUDE_DIRS Headers for ONNXRuntime +# ONNXRuntime_FOUND True if headers and requested libraries were found +# ONNXRuntime_LIBRARIES Component libraries to be linked. +# ONNXRuntime_INCLUDE_DIRS Include directories. find_library(ORT_LIB onnxruntime CMAKE_FIND_ROOT_PATH_BOTH) @@ -25,7 +24,17 @@ find_path(ORT_INCLUDE onnxruntime/core/session/onnxruntime_cxx_api.h if(ORT_LIB AND ORT_INCLUDE) set(ONNXRuntime_FOUND TRUE) - # For CMake output only - set(ONNXRuntime_LIBRARIES "${ORT_LIB}" CACHE STRING "ONNX Runtime libraries") - set(ONNXRuntime_INCLUDE_DIRS "${ORT_INCLUDE}" CACHE STRING "ONNX Runtime include path") + set(ONNXRuntime_INCLUDE_DIRS "${ORT_INCLUDE}") + + if(NOT TARGET onnxruntime) + add_library(onnxruntime UNKNOWN IMPORTED) + set_target_properties(onnxruntime PROPERTIES + IMPORTED_LOCATION "${ORT_LIB}" + INTERFACE_INCLUDE_DIRECTORIES "${ORT_INCLUDE}" + INTERFACE_LINK_LIBRARIES "onnxruntime") + list(APPEND ONNXRuntime_LIBRARIES onnxruntime) + endif() endif() + +unset(ORT_LIB CACHE) +unset(ORT_INCLUDE CACHE) |