From 7172fa3656d717522427d44484bb50c95bafa35e Mon Sep 17 00:00:00 2001 From: Giulio Romualdi Date: Wed, 12 Apr 2023 18:33:28 +0200 Subject: [PATCH] Add Findonnxruntime.cmake --- cmake/Findonnxruntime.cmake | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 cmake/Findonnxruntime.cmake diff --git a/cmake/Findonnxruntime.cmake b/cmake/Findonnxruntime.cmake new file mode 100644 index 0000000000..aea10a04d3 --- /dev/null +++ b/cmake/Findonnxruntime.cmake @@ -0,0 +1,34 @@ +# SPDX-FileCopyrightText: 2023 Giulio Romualdi +# SPDX-License-Identifier: BSD-3-Clause + +#[=======================================================================[.rst: +Findonnxruntime +----------- + +The following imported targets are created: + +onnxruntime::onnxruntime + +#]=======================================================================] + +include(FindPackageHandleStandardArgs) + +find_path(onnxruntime_INCLUDE_DIR + NAMES onnxruntime_c_api.h) +mark_as_advanced(onnxruntime_INCLUDE_DIR) +find_library(onnxruntime_LIBRARY + NAMES onnxruntime) +mark_as_advanced(onnxruntime_LIBRARY) +mark_as_advanced(onnxruntime_LIBRARY) + +find_package_handle_standard_args(onnxruntime DEFAULT_MSG onnxruntime_INCLUDE_DIR onnxruntime_LIBRARY) + +if(onnxruntime_FOUND) + if(NOT TARGET onnxruntime::onnxruntime) + add_library(onnxruntime::onnxruntime UNKNOWN IMPORTED) + set_target_properties(onnxruntime::onnxruntime PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${onnxruntime_INCLUDE_DIR}") + set_property(TARGET onnxruntime::onnxruntime PROPERTY + IMPORTED_LOCATION "${onnxruntime_LIBRARY}") + endif() +endif()