Skip to content

Commit afeb64d

Browse files
authored
Merge pull request #440 from astro-informatics/cg_onnxrt_cmake_tweaks
Propagate external ONNXrt config
2 parents 7791c4d + ac05d11 commit afeb64d

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

cmake_files/LookUpONNXRT.cmake

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ if(${onnxruntime_FOUND})
1515
set(onnxruntime_LIBRARIES onnxruntime::onnxruntime)
1616
get_filename_component(onnxruntime_INSTALL_PREFIX "${onnxruntime_INCLUDE_DIR}/../../" ABSOLUTE)
1717
find_library(onnxruntime_LIBRARY onnxruntime PATHS "${onnxruntime_INSTALL_PREFIX}/lib")
18-
set_target_properties(${onnxruntime_LIBRARIES} PROPERTIES IMPORTED_LOCATION "${onnxruntime_LIBRARY}")
19-
set_target_properties(${onnxruntime_LIBRARIES} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${onnxruntime_INCLUDE_DIR}")
18+
set_target_properties(${onnxruntime_LIBRARIES}
19+
PROPERTIES
20+
IMPORTED_LOCATION "${onnxruntime_LIBRARY}"
21+
INTERFACE_INCLUDE_DIRECTORIES "${onnxruntime_INCLUDE_DIR}")
2022
endif()
2123

2224
if(NOT ${onnxruntime_FOUND})
@@ -48,7 +50,10 @@ if(NOT ${onnxruntime_FOUND})
4850
set(onnxruntime_LIBRARY_DIR "${onnxruntime_DIR}/lib")
4951
set(onnxruntime_LIBRARIES onnxruntime::onnxruntime)
5052
add_library(${onnxruntime_LIBRARIES} SHARED IMPORTED GLOBAL)
51-
set_target_properties(${onnxruntime_LIBRARIES} PROPERTIES IMPORTED_LOCATION ${onnxruntime_LIBRARY_DIR}/libonnxruntime.so)
53+
set_target_properties(${onnxruntime_LIBRARIES}
54+
PROPERTIES
55+
IMPORTED_LOCATION ${onnxruntime_LIBRARY_DIR}/libonnxruntime.so
56+
INTERFACE_INCLUDE_DIRECTORIES ${onnxruntime_INCLUDE_DIR})
5257
set(onnxruntime_FOUND TRUE)
5358
endif()
5459

cmake_files/soptConfig.in.cmake

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
get_filename_component(sopt_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
22
message(STATUS "Linking to sopt package in ${sopt_CMAKE_DIR}")
33
set(sopt_INCLUDE_DIR "@ALL_INCLUDE_DIRS@")
4+
5+
if(onnxrt)
6+
# try and find ORT from the environment
7+
find_package(onnxruntime QUIET)
8+
if(NOT ${onnxruntime_FOUND})
9+
# if not found, it was installed on the fly
10+
set(onnxruntime_LIBRARIES onnxruntime::onnxruntime)
11+
add_library(${onnxruntime_LIBRARIES} SHARED IMPORTED GLOBAL)
12+
set_target_properties(${onnxruntime_LIBRARIES}
13+
PROPERTIES
14+
IMPORTED_LOCATION "@onnxruntime_DIR@/lib/libonnxruntime.so"
15+
INTERFACE_INCLUDE_DIRECTORIES "@onnxruntime_INCLUDE_DIR@")
16+
endif()
17+
endif()
18+
419
if(NOT TARGET libsopt AND EXISTS "${sopt_CMAKE_DIR}/soptCTargets.cmake")
520
include("${sopt_CMAKE_DIR}/soptCTargets.cmake")
621
endif()

0 commit comments

Comments
 (0)