Skip to content

Add macOS (Apple Silicon) build support#1475

Open
mossishahi wants to merge 2 commits intok4yt3x:masterfrom
mossishahi:macos-build-support
Open

Add macOS (Apple Silicon) build support#1475
mossishahi wants to merge 2 commits intok4yt3x:masterfrom
mossishahi:macos-build-support

Conversation

@mossishahi
Copy link
Copy Markdown

Summary

Minimal changes to enable building Video2X on macOS with Apple Silicon (M1/M2/M3/M4) using Homebrew dependencies and MoltenVK.

  • CMakeLists.txt: Add OpenMP discovery (find_package(OpenMP)), skip Linux-only linker flags (--gc-sections, -Wl,-s) on Apple, add Homebrew lib path
  • vulkan_utils.cpp: Enable VK_KHR_portability_enumeration extension required by MoltenVK to enumerate Vulkan devices on macOS

Changes

Only 2 files, 14 lines added/changed. No new dependencies. No breaking changes for Linux/Windows.

Build instructions (macOS)

brew install ffmpeg libomp boost vulkan-headers vulkan-loader spdlog ncnn cmake ninja pkg-config just
export OpenMP_ROOT=/opt/homebrew/opt/libomp
cmake -G Ninja -S . -B build     -DCMAKE_CXX_COMPILER=clang++     -DCMAKE_BUILD_TYPE=Release     -DCMAKE_INSTALL_PREFIX=build/install     -DVIDEO2X_ENABLE_NATIVE=ON     -DOpenMP_CXX_FLAGS="-Xpreprocessor -fopenmp -I/opt/homebrew/opt/libomp/include"     -DOpenMP_CXX_LIB_NAMES="omp"     -DOpenMP_omp_LIBRARY=/opt/homebrew/opt/libomp/lib/libomp.dylib     -DVulkan_INCLUDE_DIR=/opt/homebrew/include     -DVulkan_LIBRARY=/opt/homebrew/lib/libvulkan.dylib
cmake --build build --config Release --parallel --target install

Test environment

  • MacBook Air, Apple M3, macOS 26.3 (Tahoe)
  • All 4 processors tested: Real-ESRGAN (4x upscale), Real-CUGAN, RIFE (frame interpolation), libplacebo (Anime4K)
  • GPU detected via MoltenVK: Apple M3 (Vulkan 1.0.334)

References

Addresses #1189 — based on the patch shared by @savar in that thread, cleaned up and verified on current master.

Made with Cursor

- CMakeLists.txt: Add OpenMP discovery, Apple-specific linker flags
  (skip -Wl,--gc-sections which is Linux-only, add -L/opt/homebrew/lib
  for Homebrew dependencies)
- vulkan_utils.cpp: Enable VK_KHR_portability_enumeration extension
  and VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR flag, required
  for MoltenVK on macOS to enumerate Vulkan devices

Tested on MacBook with Apple M3, macOS 26.3, with dependencies
installed via Homebrew (ffmpeg, ncnn, vulkan-headers, vulkan-loader,
molten-vk, spdlog, boost, libomp, cmake, ninja).

Addresses k4yt3x#1189

Made-with: Cursor
@mossishahi
Copy link
Copy Markdown
Author

Updated to also include the [[gnu::target_clones]] guard from #1367 by @angelobdev — this attribute is x86-specific and fails on ARM/Apple Silicon. Used #ifndef __APPLE__ to skip it on macOS.

This PR now covers the full set of changes needed:

  • CMake: linker flags + OpenMP for Apple
  • Vulkan: MoltenVK portability enumeration
  • Compiler: guard x86-only target_clones on ARM

@nirmalpatelghub
Copy link
Copy Markdown

I didn't make in MAC OS. I am having Macbook Air M4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants