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+