diff --git a/cmake_files/LookUpONNXRT.cmake b/cmake_files/LookUpONNXRT.cmake index a0272167..5f872c27 100644 --- a/cmake_files/LookUpONNXRT.cmake +++ b/cmake_files/LookUpONNXRT.cmake @@ -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}) @@ -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() diff --git a/cmake_files/soptConfig.in.cmake b/cmake_files/soptConfig.in.cmake index f1090de2..c117b0a2 100644 --- a/cmake_files/soptConfig.in.cmake +++ b/cmake_files/soptConfig.in.cmake @@ -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()