diff options
| -rw-r--r-- | cmake/FindONNXRuntime.cmake | 23 | ||||
| -rw-r--r-- | tracker-neuralnet/CMakeLists.txt | 26 | 
2 files changed, 32 insertions, 17 deletions
| diff --git a/cmake/FindONNXRuntime.cmake b/cmake/FindONNXRuntime.cmake index 733bdb36..f485ecdd 100644 --- a/cmake/FindONNXRuntime.cmake +++ b/cmake/FindONNXRuntime.cmake @@ -13,10 +13,9 @@  # Output variable  # ---------------  #  -#   ONNXRuntime_FOUND           Variable indicating that ONNXRuntime has been -#                               found. -#   ONNXRuntime_LIBRARIES       Library implementing ONNXRuntime -#   ONNXRuntime_INCLUDE_DIRS    Headers for ONNXRuntime +#   ONNXRuntime_FOUND           True if headers and requested libraries were found +#   ONNXRuntime_LIBRARIES       Component libraries to be linked. +#   ONNXRuntime_INCLUDE_DIRS    Include directories.  find_library(ORT_LIB onnxruntime      CMAKE_FIND_ROOT_PATH_BOTH) @@ -25,7 +24,17 @@ find_path(ORT_INCLUDE onnxruntime/core/session/onnxruntime_cxx_api.h  if(ORT_LIB AND ORT_INCLUDE)      set(ONNXRuntime_FOUND TRUE) -    # For CMake output only -    set(ONNXRuntime_LIBRARIES "${ORT_LIB}" CACHE STRING "ONNX Runtime libraries") -    set(ONNXRuntime_INCLUDE_DIRS "${ORT_INCLUDE}" CACHE STRING "ONNX Runtime include path") +    set(ONNXRuntime_INCLUDE_DIRS "${ORT_INCLUDE}") + +    if(NOT TARGET onnxruntime) +        add_library(onnxruntime UNKNOWN IMPORTED) +        set_target_properties(onnxruntime PROPERTIES +            IMPORTED_LOCATION "${ORT_LIB}" +            INTERFACE_INCLUDE_DIRECTORIES "${ORT_INCLUDE}" +            INTERFACE_LINK_LIBRARIES "onnxruntime") +        list(APPEND ONNXRuntime_LIBRARIES onnxruntime) +    endif()  endif() + +unset(ORT_LIB CACHE) +unset(ORT_INCLUDE CACHE) diff --git a/tracker-neuralnet/CMakeLists.txt b/tracker-neuralnet/CMakeLists.txt index c38ba3d8..36395684 100644 --- a/tracker-neuralnet/CMakeLists.txt +++ b/tracker-neuralnet/CMakeLists.txt @@ -1,19 +1,25 @@  include(opentrack-opencv) -find_package(OpenCV QUIET) +find_package(OpenCV QUIET COMPONENTS imgproc core imgcodecs calib3d)  find_package(OpenMP QUIET) # Used to control number of onnx threads.  find_package(ONNXRuntime QUIET)  if(OpenCV_FOUND AND ONNXRuntime_FOUND AND OpenMP_FOUND)      otr_module(tracker-neuralnet) -    target_include_directories(${self} SYSTEM PUBLIC  -        ${OpenCV_INCLUDE_DIRS} "${ONNXRuntime_INCLUDE_DIRS}") -    target_link_libraries(${self} "${ONNXRuntime_LIBRARIES}" -        opentrack-cv opencv_imgproc opencv_core -        opencv_imgcodecs opencv_calib3d -        OpenMP::OpenMP_C) - +    target_include_directories(${self}  +        SYSTEM PRIVATE  +        ${OpenCV_INCLUDE_DIRS}  +        ${ONNXRuntime_INCLUDE_DIRS} +        ) +    target_link_libraries(${self}  +        opentrack-cv  +        ${ONNXRuntime_LIBRARIES}  +        ${OpenCV_LIBS}  +        OpenMP::OpenMP_C +        )      install( -        FILES "models/head-localizer.onnx" "models/head-pose.onnx" +        FILES "models/head-localizer.onnx"  +              "models/head-pose.onnx"          DESTINATION "${opentrack-libexec}/models" -        PERMISSIONS ${opentrack-perms-file}) +        PERMISSIONS ${opentrack-perms-file} +        )  endif() | 
