From cf81cfc0b6f8b1d64d80a515f3ad6536715e5a61 Mon Sep 17 00:00:00 2001 From: Kevin Blackburn-Matzen Date: Sat, 18 Jul 2026 16:29:53 -0700 Subject: [PATCH] Support OpenCV 5; cover both majors in CI OpenCV's config treats major versions as incompatible, so find_package(OpenCV 4.0 REQUIRED) rejected 5.x outright. That is what broke macOS CI when Homebrew moved the opencv formula to 5.0.0, and #57 papered over it by pinning to the keg-only opencv@4. Verified before changing anything that OpenCV 5 actually works: a throwaway probe job built the library, the examples and the full suite against 5.0.0 on macOS with only the version constraint relaxed, and everything passed. The OpenCV surface here is small -- cv::Mat, cv::Vec3b, CV_8UC3 -- and none of it changed in 5.x. The constraint is now unversioned with an explicit floor, so a genuinely too-old OpenCV still fails loudly with a readable message rather than the config-file rejection. The resolved version is reported at configure time. CI covers both majors rather than trading one silent breakage for another: pinning only to opencv@4 would let a future 5.x incompatibility land unnoticed, and testing only 5 would drop the version most distributions still ship. Fixes #56 Co-Authored-By: Claude Opus 4.8 (1M context) --- .github/workflows/ci.yml | 18 ++++++++++++------ CMakeLists.txt | 14 +++++++++++++- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 221ff22..386bff6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,8 +14,15 @@ jobs: include: - os: ubuntu-24.04 name: Linux + # Both OpenCV majors are covered. Pinning only to opencv@4 would let + # a 5.x incompatibility land unnoticed; testing only 5 would drop the + # version most distributions still ship. See #56. - os: macos-latest - name: macOS + name: macOS (OpenCV 4) + opencv: opencv@4 + - os: macos-latest + name: macOS (OpenCV 5) + opencv: opencv runs-on: ${{ matrix.os }} name: ${{ matrix.name }} @@ -37,11 +44,10 @@ jobs: - name: Install dependencies (macOS) if: runner.os == 'macOS' run: | - brew install opencv@4 ffmpeg pkg-config x264 x265 - # Homebrew's `opencv` formula is now 5.x, which CMakeLists.txt does - # not accept (see #56). Pin to the 4.x formula, which is keg-only and - # so needs an explicit prefix. - echo "CMAKE_PREFIX_PATH=$(brew --prefix opencv@4)" >> "$GITHUB_ENV" + brew install ${{ matrix.opencv }} ffmpeg pkg-config x264 x265 + # opencv@4 is keg-only, so it needs an explicit prefix; the + # unversioned formula does not, but pointing at it is harmless. + echo "CMAKE_PREFIX_PATH=$(brew --prefix ${{ matrix.opencv }})" >> "$GITHUB_ENV" - name: Set up Python uses: actions/setup-python@v5 diff --git a/CMakeLists.txt b/CMakeLists.txt index 5269253..481bf81 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,19 @@ option(FRAMEWRIGHT_BUILD_PYTHON "Build Python bindings" OFF) # ------------------------------------------------------------------------------ # Dependencies # ------------------------------------------------------------------------------ -find_package(OpenCV 4.0 REQUIRED) +# Deliberately unversioned. OpenCV's config treats major versions as +# incompatible, so find_package(OpenCV 4.0) rejects 5.x outright -- which is +# what broke macOS CI when Homebrew moved the opencv formula to 5.0. The +# floor is enforced below instead, so a genuinely too-old OpenCV still fails +# loudly while newer majors are allowed through. See #56. +find_package(OpenCV REQUIRED) + +if(OpenCV_VERSION VERSION_LESS 4.0) + message(FATAL_ERROR + "framewright requires OpenCV 4.0 or newer, found ${OpenCV_VERSION}") +endif() + +message(STATUS "OpenCV: ${OpenCV_VERSION}") find_package(PkgConfig REQUIRED) pkg_check_modules(FFMPEG REQUIRED libavformat>=58.29 # FFmpeg 4.2+