diff --git a/CMakeLists.txt b/CMakeLists.txt index 29f283cf..148d349d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 3.16...3.21) set(CMAKE_CXX_STANDARD 20) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") # Change obs-plugintemplate to your plugin's name in a machine-readable format (e.g.: # obs-myawesomeplugin) and set @@ -45,8 +46,43 @@ configure_file(src/plugin-macros.h.in ${CMAKE_SOURCE_DIR}/src/plugin-macros.gene target_sources(${CMAKE_PROJECT_NAME} PRIVATE src/plugin-macros.generated.h) -include(cmake/BuildMyOnnxruntime.cmake) -include(cmake/BuildMyOpenCV.cmake) +set(USE_SYSTEM_ONNXRUNTIME + OFF + CACHE STRING "Use system ONNX Runtime") +if(USE_SYSTEM_ONNXRUNTIME) + if(OS_LINUX) + find_package(Onnxruntime 1.14.1 REQUIRED) + add_library(Onnxruntime SHARED IMPORTED) + set_target_properties(Onnxruntime PROPERTIES IMPORTED_LOCATION ${Onnxruntime_LIBRARIES}) + set(Onnxruntime_INCLUDE_PATH + ${Onnxruntime_INCLUDE_DIR} ${Onnxruntime_INCLUDE_DIR}/onnxruntime + ${Onnxruntime_INCLUDE_DIR}/onnxruntime/core/session + ${Onnxruntime_INCLUDE_DIR}/onnxruntime/core/providers/cpu) + set_target_properties(Onnxruntime PROPERTIES INTERFACE_INCLUDE_DIRECTORIES + "${Onnxruntime_INCLUDE_PATH}") + else() + message(FATAL_ERROR "System ONNX Runtime is only supported on Linux!") + endif() +else() + include(cmake/BuildMyOnnxruntime.cmake) +endif() + +set(USE_SYSTEM_OPENCV + OFF + CACHE STRING "Use system OpenCV") +if(USE_SYSTEM_OPENCV) + if(OS_LINUX) + find_package(OpenCV REQUIRED COMPONENTS core imgproc) + add_library(OpenCV SHARED IMPORTED) + set_target_properties(OpenCV PROPERTIES IMPORTED_LOCATION ${OpenCV_LIBRARIES}) + set_target_properties(OpenCV PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${OpenCV_INCLUDE_DIRS}") + else() + message(FATAL_ERROR "System OpenCV is only supported on Linux!") + endif() +else() + include(cmake/BuildMyOpenCV.cmake) +endif() + if(OS_WINDOWS) install(IMPORTED_RUNTIME_ARTIFACTS Onnxruntime::DirectML DESTINATION "${OBS_PLUGIN_DESTINATION}") endif()