Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propagate external ONNXrt config #440

Merged
merged 2 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions cmake_files/LookUpONNXRT.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ if(${onnxruntime_FOUND})
set(onnxruntime_LIBRARIES onnxruntime::onnxruntime)
get_filename_component(onnxruntime_INSTALL_PREFIX "${onnxruntime_INCLUDE_DIR}/../../" ABSOLUTE)
find_library(onnxruntime_LIBRARY onnxruntime PATHS "${onnxruntime_INSTALL_PREFIX}/lib")
set_target_properties(${onnxruntime_LIBRARIES} PROPERTIES IMPORTED_LOCATION "${onnxruntime_LIBRARY}")
set_target_properties(${onnxruntime_LIBRARIES} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${onnxruntime_INCLUDE_DIR}")
set_target_properties(${onnxruntime_LIBRARIES}
PROPERTIES
IMPORTED_LOCATION "${onnxruntime_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${onnxruntime_INCLUDE_DIR}")
endif()

if(NOT ${onnxruntime_FOUND})
Expand Down Expand Up @@ -48,7 +50,10 @@ if(NOT ${onnxruntime_FOUND})
set(onnxruntime_LIBRARY_DIR "${onnxruntime_DIR}/lib")
set(onnxruntime_LIBRARIES onnxruntime::onnxruntime)
add_library(${onnxruntime_LIBRARIES} SHARED IMPORTED GLOBAL)
set_target_properties(${onnxruntime_LIBRARIES} PROPERTIES IMPORTED_LOCATION ${onnxruntime_LIBRARY_DIR}/libonnxruntime.so)
set_target_properties(${onnxruntime_LIBRARIES}
PROPERTIES
IMPORTED_LOCATION ${onnxruntime_LIBRARY_DIR}/libonnxruntime.so
INTERFACE_INCLUDE_DIRECTORIES ${onnxruntime_INCLUDE_DIR})
set(onnxruntime_FOUND TRUE)
endif()

15 changes: 15 additions & 0 deletions cmake_files/soptConfig.in.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
get_filename_component(sopt_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
message(STATUS "Linking to sopt package in ${sopt_CMAKE_DIR}")
set(sopt_INCLUDE_DIR "@ALL_INCLUDE_DIRS@")

if(onnxrt)
# try and find ORT from the environment
find_package(onnxruntime QUIET)
if(NOT ${onnxruntime_FOUND})
# if not found, it was installed on the fly
set(onnxruntime_LIBRARIES onnxruntime::onnxruntime)
add_library(${onnxruntime_LIBRARIES} SHARED IMPORTED GLOBAL)
set_target_properties(${onnxruntime_LIBRARIES}
PROPERTIES
IMPORTED_LOCATION "@onnxruntime_DIR@/lib/libonnxruntime.so"
INTERFACE_INCLUDE_DIRECTORIES "@onnxruntime_INCLUDE_DIR@")
endif()
endif()

if(NOT TARGET libsopt AND EXISTS "${sopt_CMAKE_DIR}/soptCTargets.cmake")
include("${sopt_CMAKE_DIR}/soptCTargets.cmake")
endif()
Expand Down
Loading