Skip to content

Commit

Permalink
Support compiling with newer ONNXRuntime (#373)
Browse files Browse the repository at this point in the history
Co-authored-by: jmcarcell <[email protected]>
  • Loading branch information
jmcarcell and jmcarcell authored May 15, 2024
1 parent 6d43e28 commit d39a711
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,11 @@ if(WITH_DD4HEP)
endif()

if(WITH_ONNX)
# New onnxruntime (at least 1.17.1 and above) provide a onnxruntimeConfig.cmake
# and use the name onnxruntime
find_package(onnxruntime)
find_package(ONNXRuntime)
if(ONNXRuntime_FOUND)
if(onnxruntime_FOUND OR ONNXRuntime_FOUND)

elseif(WITH_ONNX STREQUAL AUTO)
message(WARNING "ONNXRuntime not found. Skipping ONNX-dependent analyzers.")
Expand Down
9 changes: 7 additions & 2 deletions addons/ONNXRuntime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ endif()
find_package(ONNXRuntime QUIET)
find_package(nlohmann_json QUIET)
find_package(ROOT COMPONENTS ROOTVecOps QUIET)
if(ONNXRuntime_FOUND AND nlohmann_json_FOUND)
if(nlohmann_json_FOUND)
message(STATUS "includes-------------------------- onnxruntime: ${ONNXRUNTIME_INCLUDE_DIRS}")
elseif(WITH_ONNX STREQUAL AUTO)
message(WARNING "ONNXRuntime and/or nlohmann's JSON libraries not found. Skipping ONNX-dependent analyzers.")
Expand All @@ -14,14 +14,19 @@ elseif(WITH_ONNX STREQUAL AUTO)
else()
message(FATAL_ERROR "Failed to locate ONNXRuntime and/or nlohmann's JSON library!")
endif()
# For the newer versions of ONNXRuntime, including directories is done
# through the onnxruntime::onnxruntime target
if(onnxruntime_FOUND)
set(ONNXRUNTIME_LIBRARIES onnxruntime::onnxruntime)
endif()

file(GLOB sources src/*.cc)
file(GLOB headers *.h)

fccanalyses_addon_build(ONNXRuntime
SOURCES ${sources} ${headers}
EXT_HEADERS ${ONNXRUNTIME_INCLUDE_DIRS}
EXT_LIBS ROOT::ROOTVecOps ${ONNXRUNTIME_LIBRARIES} nlohmann_json::nlohmann_json
EXT_LIBS ROOT::ROOTVecOps ${ONNXRUNTIME_LIBRARIES} nlohmann_json::nlohmann_json ${ONNXRUNTIME_LIBRARIES}
INSTALL_COMPONENT onnxruntime)

add_custom_command(TARGET ONNXRuntime POST_BUILD
Expand Down

0 comments on commit d39a711

Please sign in to comment.