Skip to content

Commit

Permalink
Update dependent libraries (#510)
Browse files Browse the repository at this point in the history
* Update dependent libraries

* Update FetchOnnxruntime.cmake

* Update FetchOnnxruntime.cmake

* Remove float16.h as this is already included in onnxruntime distribution

* Update FetchOnnxruntime.cmake

* Update FetchOnnxruntime.cmake

* Update FetchOpenCV.cmake

* Update FetchOnnxruntime.cmake

* Update FetchOnnxruntime.cmake

* Update FetchOpenCV.cmake
  • Loading branch information
umireon authored Jan 3, 2024
1 parent d77ff28 commit c1d30cd
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 636 deletions.
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ elseif(UNIX)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE CurlClient)
endif()

target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE vendor/onnxruntime/include)

target_sources(
${CMAKE_PROJECT_NAME}
PRIVATE src/plugin-main.c
Expand Down
21 changes: 0 additions & 21 deletions cmake/BuildMyCurl.cmake

This file was deleted.

92 changes: 37 additions & 55 deletions cmake/FetchOnnxruntime.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,54 @@ set(CUSTOM_ONNXRUNTIME_URL
""
CACHE STRING "URL of a downloaded ONNX Runtime tarball")

set(CUSTOM_ONNXRUNTIME_MD5
set(CUSTOM_ONNXRUNTIME_HASH
""
CACHE STRING "MD5 Hash of a downloaded ONNX Runtime tarball")
CACHE STRING "Hash of a downloaded ONNX Runtime tarball")

if(CUSTOM_ONNXRUNTIME_URL STREQUAL "")
set(USE_PREDEFINED_ONNXRUNTIME ON)
else()
if(CUSTOM_ONNXRUNTIME_MD5 STREQUAL "")
message(FATAL_ERROR "Both of CUSTOM_ONNXRUNTIME_URL and CUSTOM_ONNXRUNTIME_MD5 must be present!")
if(CUSTOM_ONNXRUNTIME_HASH STREQUAL "")
message(FATAL_ERROR "Both of CUSTOM_ONNXRUNTIME_URL and CUSTOM_ONNXRUNTIME_HASH must be present!")
else()
set(USE_PREDEFINED_ONNXRUNTIME OFF)
endif()
endif()

set(Onnxruntime_VERSION "1.16.3")
if(USE_PREDEFINED_ONNXRUNTIME)
set(Onnxruntime_VERSION "1.16.3")
set(Onnxruntime_BASEURL "https://github.com/microsoft/onnxruntime/releases/download/v${Onnxruntime_VERSION}")
set(Onnxruntime_WINDOWS_VERSION "v${Onnxruntime_VERSION}-2")
set(Onnxruntime_WINDOWS_BASEURL
"https://github.com/occ-ai/onnxruntime-static-win/releases/download/${Onnxruntime_WINDOWS_VERSION}")

if(OS_MACOS)
if(USE_PREDEFINED_ONNXRUNTIME)
FetchContent_Declare(
Onnxruntime
URL "https://github.com/microsoft/onnxruntime/releases/download/v${Onnxruntime_VERSION}/onnxruntime-osx-universal2-${Onnxruntime_VERSION}.tgz"
URL_HASH SHA256=6428d0f0ff1386e8e8256a708e187c1f8861387c9554bfc9c5f3390ffa0df5cc)
if(APPLE)
set(Onnxruntime_URL "${Onnxruntime_BASEURL}/onnxruntime-osx-universal2-${Onnxruntime_VERSION}.tgz")
set(Onnxruntime_HASH SHA256=6428d0f0ff1386e8e8256a708e187c1f8861387c9554bfc9c5f3390ffa0df5cc)
elseif(MSVC)
set(Onnxruntime_URL "${Onnxruntime_WINDOWS_BASEURL}/onnxruntime-windows-${Onnxruntime_WINDOWS_VERSION}-Release.zip")
set(OOnnxruntime_HASH SHA256=d545d1040be3c5c173b4f03a58f391f47fb039f1e799c4f2be706c678d8444f4)
else()
FetchContent_Declare(
Onnxruntime
URL "${CUSTOM_ONNXRUNTIME_URL}"
URL_HASH MD5=${CUSTOM_ONNXRUNTIME_MD5})
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
set(Onnxruntime_URL "${Onnxruntime_BASEURL}/onnxruntime-linux-aarch64-${Onnxruntime_VERSION}.tgz")
set(Onnxruntime_HASH SHA256=784dbef93b40196aa668d29d78294a81c0d21361d36530b817bb24d87e8730e8)
else()
set(Onnxruntime_URL "${Onnxruntime_BASEURL}/onnxruntime-linux-x64-gpu-${Onnxruntime_VERSION}.tgz")
set(Onnxruntime_HASH SHA256=bbdc33367c056029b3ac0c042cbca2236b8f59a3a53b4daf23432ef1d8bf52de)
endif()
endif()
FetchContent_MakeAvailable(Onnxruntime)
else()
set(Onnxruntime_URL "${CUSTOM_ONNXRUNTIME_URL}")
set(Onnxruntime_HASH "${CUSTOM_ONNXRUNTIME_HASH}")
endif()

FetchContent_Declare(
onnxruntime
URL ${Onnxruntime_URL}
URL_HASH ${Onnxruntime_HASH})
FetchContent_MakeAvailable(onnxruntime)

if(APPLE)
set(Onnxruntime_LIB "${onnxruntime_SOURCE_DIR}/lib/libonnxruntime.${Onnxruntime_VERSION}.dylib")
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE "${Onnxruntime_LIB}")
target_include_directories(${CMAKE_PROJECT_NAME} SYSTEM PUBLIC "${onnxruntime_SOURCE_DIR}/include")
Expand All @@ -45,20 +64,7 @@ if(OS_MACOS)
COMMAND
${CMAKE_INSTALL_NAME_TOOL} -change "@rpath/libonnxruntime.${Onnxruntime_VERSION}.dylib"
"@loader_path/../Frameworks/libonnxruntime.${Onnxruntime_VERSION}.dylib" $<TARGET_FILE:${CMAKE_PROJECT_NAME}>)
elseif(OS_WINDOWS)
if(USE_PREDEFINED_ONNXRUNTIME)
FetchContent_Declare(
Onnxruntime
URL "https://github.com/occ-ai/onnxruntime-static-win/releases/download/v${Onnxruntime_VERSION}-1/onnxruntime-windows-Release.zip"
URL_HASH SHA256=ca7fe4ed8bf888b4ffcc514f39948ded6ca5c3c1e8fc062ceeabf2159e9f09be)
else()
FetchContent_Declare(
Onnxruntime
URL "${CUSTOM_ONNXRUNTIME_URL}"
URL_HASH MD5=${CUSTOM_ONNXRUNTIME_MD5})
endif()
FetchContent_MakeAvailable(Onnxruntime)

elseif(MSVC)
add_library(Ort INTERFACE)
set(Onnxruntime_LIB_NAMES
session;providers_shared;providers_dml;optimizer;providers;framework;graph;util;mlas;common;flatbuffers)
Expand Down Expand Up @@ -88,35 +94,11 @@ elseif(OS_WINDOWS)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE Ort)

install(IMPORTED_RUNTIME_ARTIFACTS Ort::DirectML DESTINATION "obs-plugins/64bit")
elseif(OS_LINUX)
else()
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
if(USE_PREDEFINED_ONNXRUNTIME)
FetchContent_Declare(
Onnxruntime
URL "https://github.com/microsoft/onnxruntime/releases/download/v${Onnxruntime_VERSION}/onnxruntime-linux-aarch64-${Onnxruntime_VERSION}.tgz"
URL_HASH SHA256=784dbef93b40196aa668d29d78294a81c0d21361d36530b817bb24d87e8730e8)
else()
FetchContent_Declare(
Onnxruntime
URL "${CUSTOM_ONNXRUNTIME_URL}"
URL_HASH MD5=${CUSTOM_ONNXRUNTIME_MD5})
endif()
FetchContent_MakeAvailable(Onnxruntime)
set(Onnxruntime_LINK_LIBS "${onnxruntime_SOURCE_DIR}/lib/libonnxruntime.so.${Onnxruntime_VERSION}")
set(Onnxruntime_INSTALL_LIBS ${Onnxruntime_LINK_LIBS})
else()
if(USE_PREDEFINED_ONNXRUNTIME)
FetchContent_Declare(
Onnxruntime
URL "https://github.com/microsoft/onnxruntime/releases/download/v${Onnxruntime_VERSION}/onnxruntime-linux-x64-gpu-${Onnxruntime_VERSION}.tgz"
URL_HASH SHA256=bbdc33367c056029b3ac0c042cbca2236b8f59a3a53b4daf23432ef1d8bf52de)
else()
FetchContent_Declare(
Onnxruntime
URL "${CUSTOM_ONNXRUNTIME_URL}"
URL_HASH MD5=${CUSTOM_ONNXRUNTIME_MD5})
endif()
FetchContent_MakeAvailable(Onnxruntime)
set(Onnxruntime_LINK_LIBS "${onnxruntime_SOURCE_DIR}/lib/libonnxruntime.so.${Onnxruntime_VERSION}")
set(Onnxruntime_INSTALL_LIBS
${Onnxruntime_LINK_LIBS} "${onnxruntime_SOURCE_DIR}/lib/libonnxruntime_providers_shared.so"
Expand Down
36 changes: 18 additions & 18 deletions cmake/FetchOpenCV.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ else()
endif()

if(USE_PREDEFINED_OPENCV)
set(OpenCV_VERSION "4.8.0-1")
set(OpenCV_VERSION "v4.8.1-1")
set(OpenCV_BASEURL "https://github.com/obs-ai/obs-backgroundremoval-dep-opencv/releases/download/${OpenCV_VERSION}")

if(${CMAKE_BUILD_TYPE} STREQUAL Release OR ${CMAKE_BUILD_TYPE} STREQUAL RelWithDebInfo)
Expand All @@ -29,28 +29,28 @@ if(USE_PREDEFINED_OPENCV)
endif()

if(APPLE)
if(OpenCV_BUILD_TYPE STREQUAL Release)
set(OpenCV_URL "${OpenCV_BASEURL}/opencv-macos-Release.tar.gz")
set(OpenCV_HASH MD5=0875366a03aa44def76ab5a12d3e7b8f)
if(OpenCV_BUILD_TYPE STREQUAL Debug)
set(OpenCV_URL "${OpenCV_BASEURL}/opencv-macos-${OpenCV_VERSION}-Debug.tar.gz")
set(OpenCV_HASH SHA256=2930e335a19cc03a3d825e2b76eadd0d5cf08d8baf6537747d43f503dff32454)
else()
set(OpenCV_URL "${OpenCV_BASEURL}/opencv-macos-Debug.tar.gz")
set(OpenCV_HASH MD5=9ae59653c7f9a4c991fbf59018e45d2c)
set(OpenCV_URL "${OpenCV_BASEURL}/opencv-macos-${OpenCV_VERSION}-Release.tar.gz")
set(OpenCV_HASH SHA256=b0c4fe2370b0bd5aa65c408e875b1ab18508ba31b93083805d7e398a3ecafdac)
endif()
elseif(MSVC)
if(OpenCV_BUILD_TYPE STREQUAL Release)
set(OpenCV_URL "${OpenCV_BASEURL}/opencv-windows-Release.zip")
set(OpenCV_HASH MD5=e653d590cfbcc3a9bf15ef20e64a6e32)
if(OpenCV_BUILD_TYPE STREQUAL Debug)
set(OpenCV_URL "${OpenCV_BASEURL}/opencv-windows-${OpenCV_VERSION}-Debug.zip")
set(OpenCV_HASH SHA256=0c5ef12cf4b4e4db7ea17a24db156165b6f01759f3f1660b069d0722e5d5dc37)
else()
set(OpenCV_URL "${OpenCV_BASEURL}/opencv-windows-Debug.zip")
set(OpenCV_HASH MD5=abad340ccb73da2924544ec9066afcb3)
set(OpenCV_URL "${OpenCV_BASEURL}/opencv-windows-${OpenCV_VERSION}-Release.zip")
set(OpenCV_HASH SHA256=5e468f71d41d3a3ea46cc4f247475877f65d3655a2764a2c01074bda3b3e6864)
endif()
else()
if(OpenCV_BUILD_TYPE STREQUAL Release)
set(OpenCV_URL "${OpenCV_BASEURL}/opencv-linux-Release.tar.gz")
set(OpenCV_HASH MD5=7a668fbc3ac536812643c6b8c8f96be9)
if(OpenCV_BUILD_TYPE STREQUAL Debug)
set(OpenCV_URL "${OpenCV_BASEURL}/opencv-linux-${OpenCV_VERSION}-Debug.tar.gz")
set(OpenCV_HASH SHA256=e2e246d6b4f279be80e7fd0a78cba8a0eeee7b53ae807f2f57428d6876306422)
else()
set(OpenCV_URL "${OpenCV_BASEURL}/opencv-linux-Debug.tar.gz")
set(OpenCV_HASH MD5=259699c71055ff748c200e62af059104)
set(OpenCV_URL "${OpenCV_BASEURL}/opencv-linux-${OpenCV_VERSION}-Release.tar.gz")
set(OpenCV_HASH SHA256=809922a7cc9f344a2d82a232ed7b02e122c82e77cba94b4047e666a0527cc00e)
endif()
endif()
else()
Expand All @@ -68,8 +68,8 @@ add_library(OpenCV INTERFACE)
if(MSVC)
target_link_libraries(
OpenCV
INTERFACE ${opencv_SOURCE_DIR}/x64/vc17/staticlib/opencv_imgproc480.lib
${opencv_SOURCE_DIR}/x64/vc17/staticlib/opencv_core480.lib
INTERFACE ${opencv_SOURCE_DIR}/x64/vc17/staticlib/opencv_imgproc481.lib
${opencv_SOURCE_DIR}/x64/vc17/staticlib/opencv_core481.lib
${opencv_SOURCE_DIR}/x64/vc17/staticlib/zlib.lib)
target_include_directories(OpenCV SYSTEM INTERFACE ${opencv_SOURCE_DIR}/include)
else()
Expand Down
Loading

0 comments on commit c1d30cd

Please sign in to comment.