Back to home page

sPhenix 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 if(NOT OnnxRuntime_LIBRARY)
0014   message(FATAL_ERROR "onnxruntime library not found")
0015 else()
0016   message(STATUS "Found OnnxRuntime library at ${OnnxRuntime_LIBRARY}")
0017 endif()
0018 
0019 find_path(
0020   OnnxRuntime_INCLUDE_DIR
0021   NAMES onnxruntime_cxx_api.h
0022   PATHS ${onnxruntime_DIR}
0023   PATH_SUFFIXES include include/onnxruntime include/onnxruntime/core/session
0024   DOC "The ONNXRuntime include directory")
0025 
0026 if(NOT OnnxRuntime_INCLUDE_DIR)
0027   message(FATAL_ERROR "onnxruntime includes not found")
0028 else()
0029   file(READ ${OnnxRuntime_INCLUDE_DIR}/onnxruntime_c_api.h ver)
0030   string(REGEX MATCH "ORT_API_VERSION ([0-9]*)" _ ${ver})
0031   set(OnnxRuntime_API_VERSION ${CMAKE_MATCH_1})
0032   message(STATUS "Found OnnxRuntime includes at ${OnnxRuntime_INCLUDE_DIR} (API version: ${OnnxRuntime_API_VERSION})")
0033 endif()
0034 
0035 
0036 string(REPLACE "." ";" OnnxRuntime_MIN_VERSION_LIST ${_acts_onnxruntime_version})
0037 list(GET OnnxRuntime_MIN_VERSION_LIST 1 OnnxRuntime_MIN_API_VERSION)
0038 if("${OnnxRuntime_API_VERSION}" LESS ${OnnxRuntime_MIN_API_VERSION})
0039   message(FATAL_ERROR "OnnxRuntime API version ${OnnxRuntime_MIN_API_VERSION} or greater required")
0040 endif()
0041 
0042 include(FindPackageHandleStandardArgs)
0043 find_package_handle_standard_args(
0044   OnnxRuntime
0045   REQUIRED_VARS OnnxRuntime_LIBRARY OnnxRuntime_INCLUDE_DIR)
0046 
0047 add_library(OnnxRuntime SHARED IMPORTED)
0048 set_property(TARGET OnnxRuntime PROPERTY IMPORTED_LOCATION ${OnnxRuntime_LIBRARY})
0049 set_property(TARGET OnnxRuntime PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${OnnxRuntime_INCLUDE_DIR})
0050 set_property(TARGET OnnxRuntime PROPERTY INTERFACE_SYSTEM_INCLUDE_DIRECTORIES ${OnnxRuntime_INCLUDE_DIR})
0051 
0052 mark_as_advanced(OnnxRuntime_FOUND OnnxRuntime_INCLUDE_DIR OnnxRuntime_LIBRARY)