diff --git a/.ci/build-freebsd.sh b/.ci/build-freebsd.sh index c42812f2f0..2d8a3a8ae2 100755 --- a/.ci/build-freebsd.sh +++ b/.ci/build-freebsd.sh @@ -27,6 +27,7 @@ CONFIGURE_ARGS=" -DUSE_SYSTEM_FFMPEG=ON -DUSE_SYSTEM_CURL=ON -DUSE_SYSTEM_LIBPNG=ON + -DUSE_SYSTEM_OPENCV=ON " # shellcheck disable=SC2086 diff --git a/.ci/build-linux-aarch64.sh b/.ci/build-linux-aarch64.sh index 4dca82ffb9..834356c625 100644 --- a/.ci/build-linux-aarch64.sh +++ b/.ci/build-linux-aarch64.sh @@ -25,6 +25,7 @@ cmake .. \ -DUSE_SDL=ON \ -DUSE_SYSTEM_SDL=ON \ -DUSE_SYSTEM_FFMPEG=OFF \ + -DUSE_SYSTEM_OPENCV=ON \ -DUSE_DISCORD_RPC=ON \ -DOpenGL_GL_PREFERENCE=LEGACY \ -DLLVM_DIR=/opt/llvm/lib/cmake/llvm \ diff --git a/.ci/build-linux.sh b/.ci/build-linux.sh index ff061cd7e3..9d58d94fc9 100755 --- a/.ci/build-linux.sh +++ b/.ci/build-linux.sh @@ -44,6 +44,7 @@ cmake .. \ -DUSE_SDL=ON \ -DUSE_SYSTEM_SDL=ON \ -DUSE_SYSTEM_FFMPEG=OFF \ + -DUSE_SYSTEM_OPENCV=ON \ -DUSE_DISCORD_RPC=ON \ -DOpenGL_GL_PREFERENCE=LEGACY \ -DLLVM_DIR=/opt/llvm/lib/cmake/llvm \ diff --git a/.ci/build-mac-arm64.sh b/.ci/build-mac-arm64.sh index a1aefd2b4f..3049ed1c04 100644 --- a/.ci/build-mac-arm64.sh +++ b/.ci/build-mac-arm64.sh @@ -131,6 +131,7 @@ export MACOSX_DEPLOYMENT_TARGET=13.0 -DUSE_SYSTEM_MVK=ON \ -DUSE_SYSTEM_FAUDIO=OFF \ -DUSE_SYSTEM_SDL=ON \ + -DUSE_SYSTEM_OPENCV=ON \ $CMAKE_EXTRA_OPTS \ -DLLVM_TARGET_ARCH=arm64 \ -DCMAKE_OSX_ARCHITECTURES=arm64 \ diff --git a/.ci/build-mac.sh b/.ci/build-mac.sh index 85011afcb2..8b0fe08065 100644 --- a/.ci/build-mac.sh +++ b/.ci/build-mac.sh @@ -98,6 +98,7 @@ export MACOSX_DEPLOYMENT_TARGET=13.0 -DUSE_SYSTEM_MVK=ON \ -DUSE_SYSTEM_FAUDIO=OFF \ -DUSE_SYSTEM_SDL=ON \ + -DUSE_SYSTEM_OPENCV=ON \ $CMAKE_EXTRA_OPTS \ -DLLVM_TARGET_ARCH=X86_64 \ -DCMAKE_OSX_ARCHITECTURES=x86_64 \ diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index 6285ac6798..57a45d7be5 100644 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -344,7 +344,7 @@ add_subdirectory(miniupnp EXCLUDE_FROM_ALL) add_subdirectory(rtmidi EXCLUDE_FROM_ALL) # OPENCV -# TODO: add library and -DHAVE_OPENCV +add_subdirectory(opencv EXCLUDE_FROM_ALL) # add nice ALIAS targets for ease of use if(USE_SYSTEM_LIBUSB) @@ -376,3 +376,4 @@ add_library(3rdparty::soundtouch ALIAS soundtouch) add_library(3rdparty::sdl2 ALIAS ${SDL2_TARGET}) add_library(3rdparty::miniupnpc ALIAS libminiupnpc-static) add_library(3rdparty::rtmidi ALIAS rtmidi) +add_library(3rdparty::opencv ALIAS ${OPENCV_TARGET}) diff --git a/3rdparty/opencv/CMakeLists.txt b/3rdparty/opencv/CMakeLists.txt new file mode 100644 index 0000000000..2071caa5b6 --- /dev/null +++ b/3rdparty/opencv/CMakeLists.txt @@ -0,0 +1,21 @@ +# OpenCV + +set(OPENCV_TARGET 3rdparty_dummy_lib PARENT_SCOPE) + +if (USE_SYSTEM_OPENCV) + message(STATUS "RPCS3: using system OpenCV") + find_package(OpenCV) + + if(OPENCV_FOUND) + message(STATUS "RPCS3: found system OpenCV") + include_directories(${OpenCV_INCLUDE_DIRS}) + add_library(3rdparty_opencv INTERFACE) + target_link_libraries(3rdparty_opencv INTERFACE ${OpenCV_LIBS}) + target_compile_definitions(3rdparty_opencv INTERFACE -DHAVE_OPENCV) + set(OPENCV_TARGET 3rdparty_opencv PARENT_SCOPE) + else() + message(WARNING "RPCS3: OpenCV not found. Building without OpenCV support") + endif() +else() + message(WARNING "RPCS3: Building without OpenCV support") +endif() diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b95d4a838..55a4ce598f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,7 @@ option(USE_SYSTEM_SDL "Prefer system SDL instead of the builtin one" ON) option(USE_SYSTEM_FFMPEG "Prefer system ffmpeg instead of the prebuild one" OFF) option(USE_SYSTEM_OPENAL "Prefer system OpenAL instead of the prebuild one" ON) option(USE_SYSTEM_CURL "Prefer system Curl instead of the prebuild one" ON) +option(USE_SYSTEM_OPENCV "Prefer system OpenCV instead of the builtin one" ON) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/buildfiles/cmake") diff --git a/CMakePresets.json b/CMakePresets.json index f2ad04077c..a81db6227d 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -13,6 +13,7 @@ "USE_SYSTEM_CURL": "OFF", "USE_SYSTEM_ZLIB": "OFF", "USE_SYSTEM_LIBPNG": "OFF", + "USE_SYSTEM_OPENCV": "ON", "BUILD_LLVM": "OFF", "STATIC_LINK_LLVM": "ON" } @@ -29,6 +30,7 @@ "USE_SYSTEM_CURL": "OFF", "USE_SYSTEM_ZLIB": "OFF", "USE_SYSTEM_LIBPNG": "OFF", + "USE_SYSTEM_OPENCV": "ON", "LLVM_ENABLE_LIBCXX": "ON", "BUILD_LLVM": "OFF", "STATIC_LINK_LLVM": "ON" @@ -56,6 +58,7 @@ "USE_SYSTEM_CURL": "OFF", "USE_SYSTEM_ZLIB": "OFF", "USE_SYSTEM_OPENAL": "OFF", + "USE_SYSTEM_OPENCV": "OFF", "BUILD_LLVM": "ON", "STATIC_LINK_LLVM": "ON" }, diff --git a/rpcs3/CMakeLists.txt b/rpcs3/CMakeLists.txt index 6f752ecc73..04a928fa72 100644 --- a/rpcs3/CMakeLists.txt +++ b/rpcs3/CMakeLists.txt @@ -98,9 +98,19 @@ set_target_properties(rpcs3 AUTOMOC ON AUTOUIC ON) -target_link_libraries(rpcs3 PRIVATE rpcs3_emu rpcs3_ui) -target_link_libraries(rpcs3 PRIVATE 3rdparty::discordRPC 3rdparty::qt6 3rdparty::hidapi 3rdparty::libusb 3rdparty::wolfssl 3rdparty::libcurl 3rdparty::zlib) -target_link_libraries(rpcs3 PRIVATE ${ADDITIONAL_LIBS}) +target_link_libraries(rpcs3 + PRIVATE + rpcs3_emu + rpcs3_ui + 3rdparty::discordRPC + 3rdparty::qt6 + 3rdparty::hidapi + 3rdparty::libusb + 3rdparty::wolfssl + 3rdparty::libcurl + 3rdparty::zlib + 3rdparty::opencv + ${ADDITIONAL_LIBS}) # Unix display manager if(X11_FOUND) diff --git a/rpcs3/rpcs3qt/CMakeLists.txt b/rpcs3/rpcs3qt/CMakeLists.txt index 728afcaa35..2629da0880 100644 --- a/rpcs3/rpcs3qt/CMakeLists.txt +++ b/rpcs3/rpcs3qt/CMakeLists.txt @@ -145,11 +145,13 @@ target_compile_definitions(rpcs3_ui PRIVATE WIN32_LEAN_AND_MEAN) target_link_libraries(rpcs3_ui PUBLIC - 3rdparty::qt6 3rdparty::yaml-cpp + 3rdparty::qt6 + 3rdparty::yaml-cpp PRIVATE rpcs3_emu - 3rdparty::zlib 3rdparty::pugixml + 3rdparty::zlib + 3rdparty::pugixml 3rdparty::discordRPC 3rdparty::hidapi 3rdparty::libusb @@ -157,4 +159,5 @@ target_link_libraries(rpcs3_ui 3rdparty::7zip 3rdparty::wolfssl 3rdparty::libcurl + 3rdparty::opencv 3rdparty::rtmidi)