Skip to content

Add macOS x64/arm64 CI and runtime packages (port of #1947 to 5.x) - #1955

Merged
shimat merged 3 commits into
5.xfrom
feature/macos-ci-5x
Jun 27, 2026
Merged

shimat merged 3 commits into
5.xfrom
feature/macos-ci-5x

Conversation

@shimat

@shimat shimat commented Jun 27, 2026

Copy link
Copy Markdown
Owner

Ports the macOS support added on main (4.x) in #1947 to the 5.x branch, adapted for OpenCV 5 and the OpenCvSharp5 package naming.

What's included

  • .github/workflows/macos.yml — build_x64 (macos-26-intel), build_arm64 (macos-26), test (arm64), and nuget jobs. Builds OpenCV 5.0.0 from source via vcpkg + CMake/Ninja, then OpenCvSharpExtern, runs arm64 tests, and packs both runtime packages. OPENCV_VERSION=5.0.0, push trigger on 5.x.
  • cmake/triplets/{x64,arm64}-osx-static.cmake — static macOS vcpkg triplets.
  • vcpkg.json — add ffmpeg/hdf5/freetype/harfbuzz/eigen3 (osx platform only).
  • src/OpenCvSharpExtern/CMakeLists.txt — /opt/homebrew/lib for Apple Silicon; pre-resolve Eigen3/HDF5 before OpenCV config on APPLE; link Tesseract on macOS (drop NOT APPLE).
  • nuget — rename OpenCvSharp5.runtime.osx.10.15-x64 → OpenCvSharp5.runtime.osx.x64, add OpenCvSharp5.runtime.osx.arm64; TFM netstandard2.0/2.1/net8.0.
  • publish_nuget.yml — enable macOS artifact download + osx.x64/osx.arm64 validation.
  • docs — package list + supported platforms.

Differences from the 4.x port (#1947)

  • Package prefix OpenCvSharp4 → OpenCvSharp5; OPENCV_VERSION 4.13.0 → 5.0.0; branch main → 5.x.
  • include_opencv.h needs no change on 5.x — opencv2/text.hpp is already included unconditionally (no NO_TEXT guard).
  • OpenCV_DIR stays lib/cmake/opencv4, matching the 5.x full-build convention (see manylinux.yml).

Status

Draft. The mechanical port is complete, but the OpenCV-5-specific macOS build details (the find_package(Eigen3/HDF5) set and the static transitive linker flags) were carried over from the 4.x recipe and may need iteration against the macOS runners. Opening as draft to let the macOS CI surface any OpenCV 5 deltas.

🤖 Generated with Claude Code

shimat and others added 3 commits June 27, 2026 11:46
Port the macOS support added on main (4.x) in #1947 to the 5.x branch,
adapted for OpenCV 5 and the OpenCvSharp5 package naming:

- .github/workflows/macos.yml: build_x64 (macos-26-intel),
  build_arm64 (macos-26), test (arm64), and nuget jobs. Builds OpenCV
  5.0.0 from source via vcpkg + CMake/Ninja, then OpenCvSharpExtern,
  and packs both runtime NuGet packages. OPENCV_VERSION=5.0.0,
  triggers on push to 5.x.
- cmake/triplets/{x64,arm64}-osx-static.cmake: static macOS vcpkg triplets.
- vcpkg.json: add ffmpeg/hdf5/freetype/harfbuzz/eigen3 for osx.
- src/OpenCvSharpExtern/CMakeLists.txt:
  * add /opt/homebrew/lib to APPLE link_directories (Apple Silicon)
  * pre-resolve Eigen3 and HDF5 before OpenCV config on APPLE
  * link Tesseract on macOS too (drop the NOT APPLE guard)
- nuget: rename OpenCvSharp5.runtime.osx.10.15-x64 ->
  OpenCvSharp5.runtime.osx.x64 and add OpenCvSharp5.runtime.osx.arm64;
  target netstandard2.0/2.1/net8.0.
- .github/workflows/publish_nuget.yml: enable macOS artifact download
  and add osx.x64 / osx.arm64 package validation.
- docs: update package list and supported platforms for macOS arm64.

Note: include_opencv.h needs no change on 5.x (text.hpp is already
included unconditionally). The macOS-5 build specifics (find_package
deps, linker flags) may need iteration against the macOS runners.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add the macOS badge (now that macos.yml exists on this branch) and
convert all CI badges to the modern actions/workflows/<file> URL format,
matching the fix already applied on main. The file-path format matches
on filename and links to each workflow's own run history.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Both build_x64 and build_arm64 failed linking OpenCvSharpExtern with:
  Undefined symbols ... "MlasHGemmSupported(CBLAS_TRANSPOSE, CBLAS_TRANSPOSE)"
referenced from compute.cpp.o in libopencv_dnn.a.

OpenCV 5.0.0's vendored MLAS builds in "SGEMM-only" mode here, but its
FP16/GQA path declares and calls MlasHGemmSupported() without ever
defining it, breaking the static link. windows.yml and linux-arm64.yml
already work around this by denying CMake an ASM compiler so MLAS turns
off and DNN falls back to its built-in SGEMM. Apply the same fix to
macOS (-D CMAKE_ASM_COMPILER="") in both Configure OpenCV steps. Image
codecs come from vcpkg, so no ASM language is needed otherwise.

Also drop the hardcoded -D OpenCV_DIR=.../lib/cmake/opencv4: OpenCV 5
installs its config to lib/cmake/opencv5, and find_package already
resolves it via CMAKE_PREFIX_PATH (opencv_artifacts).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@shimat shimat self-assigned this Jun 27, 2026
@shimat
shimat marked this pull request as ready for review June 27, 2026 05:04
@shimat
shimat merged commit 1e25544 into 5.x Jun 27, 2026
15 checks passed
@shimat
shimat deleted the feature/macos-ci-5x branch June 27, 2026 05:04
@shimat shimat added the enhancement New feature or improvement to OpenCvSharp label Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or improvement to OpenCvSharp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant