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
0025         include
0026         include/onnxruntime
0027         include/onnxruntime/core/session
0028         include/core/session
0029     DOC "The ONNXRuntime include directory"
0030 )
0031 
0032 if(NOT onnxruntime_INCLUDE_DIR)
0033     message(FATAL_ERROR "onnxruntime includes not found")
0034 else()
0035     file(READ ${onnxruntime_INCLUDE_DIR}/onnxruntime_c_api.h ver)
0036     string(REGEX MATCH "ORT_API_VERSION ([0-9]*)" _ ${ver})
0037     set(onnxruntime_API_VERSION ${CMAKE_MATCH_1})
0038     message(
0039         STATUS
0040         "Found onnxruntime includes at ${onnxruntime_INCLUDE_DIR} (API version: ${onnxruntime_API_VERSION})"
0041     )
0042 endif()
0043 
0044 if("${onnxruntime_API_VERSION}" VERSION_LESS "${onnxruntime_MIN_API_VERSION}")
0045     message(
0046         FATAL_ERROR
0047         "onnxruntime API version ${onnxruntime_MIN_API_VERSION} or greater required"
0048     )
0049 endif()
0050 
0051 include(FindPackageHandleStandardArgs)
0052 find_package_handle_standard_args(
0053     onnxruntime
0054     REQUIRED_VARS onnxruntime_LIBRARY onnxruntime_INCLUDE_DIR
0055 )
0056 
0057 add_library(onnxruntime SHARED IMPORTED)
0058 set_property(
0059     TARGET onnxruntime
0060     PROPERTY IMPORTED_LOCATION ${onnxruntime_LIBRARY}
0061 )
0062 set_property(
0063     TARGET onnxruntime
0064     PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${onnxruntime_INCLUDE_DIR}
0065 )
0066 set_property(
0067     TARGET onnxruntime
0068     PROPERTY INTERFACE_SYSTEM_INCLUDE_DIRECTORIES ${onnxruntime_INCLUDE_DIR}
0069 )
0070 mark_as_advanced(onnxruntime_FOUND onnxruntime_INCLUDE_DIR onnxruntime_LIBRARY)
0071 
0072 add_library(onnxruntime::onnxruntime ALIAS onnxruntime)