Back to home page

EIC code displayed by LXR

 
 

    


Warning, /acts/cmake/FindOnnxRuntime.cmake is written in an unsupported language. File is not indexed.

0001 # Find the ONNX Runtime include directory and library.
0002 #
0003 # This module defines the `onnxruntime` imported target that encodes all
0004 # necessary information in its target properties.
0005 
0006 find_library(
0007     OnnxRuntime_LIBRARY
0008     NAMES onnxruntime
0009     PATHS ${onnxruntime_DIR}
0010     PATH_SUFFIXES lib lib32 lib64
0011     DOC "The ONNXRuntime library"
0012 )
0013 
0014 if(NOT OnnxRuntime_LIBRARY)
0015     message(FATAL_ERROR "onnxruntime library not found")
0016 else()
0017     message(STATUS "Found OnnxRuntime library at ${OnnxRuntime_LIBRARY}")
0018 endif()
0019 
0020 find_path(
0021     OnnxRuntime_INCLUDE_DIR
0022     NAMES onnxruntime_cxx_api.h
0023     PATHS ${onnxruntime_DIR}
0024     PATH_SUFFIXES include include/onnxruntime include/onnxruntime/core/session
0025     DOC "The ONNXRuntime include directory"
0026 )
0027 
0028 if(NOT OnnxRuntime_INCLUDE_DIR)
0029     message(FATAL_ERROR "onnxruntime includes not found")
0030 else()
0031     file(READ ${OnnxRuntime_INCLUDE_DIR}/onnxruntime_c_api.h ver)
0032     string(REGEX MATCH "ORT_API_VERSION ([0-9]*)" _ ${ver})
0033     set(OnnxRuntime_API_VERSION ${CMAKE_MATCH_1})
0034     message(
0035         STATUS
0036         "Found OnnxRuntime includes at ${OnnxRuntime_INCLUDE_DIR} (API version: ${OnnxRuntime_API_VERSION})"
0037     )
0038 endif()
0039 
0040 string(
0041     REPLACE
0042     "."
0043     ";"
0044     OnnxRuntime_MIN_VERSION_LIST
0045     ${_acts_onnxruntime_version}
0046 )
0047 list(GET OnnxRuntime_MIN_VERSION_LIST 1 OnnxRuntime_MIN_API_VERSION)
0048 if("${OnnxRuntime_API_VERSION}" LESS ${OnnxRuntime_MIN_API_VERSION})
0049     message(
0050         FATAL_ERROR
0051         "OnnxRuntime API version ${OnnxRuntime_MIN_API_VERSION} or greater required"
0052     )
0053 endif()
0054 
0055 include(FindPackageHandleStandardArgs)
0056 find_package_handle_standard_args(
0057     OnnxRuntime
0058     REQUIRED_VARS OnnxRuntime_LIBRARY OnnxRuntime_INCLUDE_DIR
0059 )
0060 
0061 add_library(OnnxRuntime SHARED IMPORTED)
0062 set_property(
0063     TARGET OnnxRuntime
0064     PROPERTY IMPORTED_LOCATION ${OnnxRuntime_LIBRARY}
0065 )
0066 set_property(
0067     TARGET OnnxRuntime
0068     PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${OnnxRuntime_INCLUDE_DIR}
0069 )
0070 set_property(
0071     TARGET OnnxRuntime
0072     PROPERTY INTERFACE_SYSTEM_INCLUDE_DIRECTORIES ${OnnxRuntime_INCLUDE_DIR}
0073 )
0074 
0075 mark_as_advanced(OnnxRuntime_FOUND OnnxRuntime_INCLUDE_DIR OnnxRuntime_LIBRARY)