macOS non-bundle build cannot load Vulkan
envgap__cemu-project__Cemu-1563
01 / FAILURE SIGNATURE
As reported upstream
No identifying execution failure has been captured.
Not a benchmark task.
- In a clean container the reported failure did not reproduce, or the known fix did not make the project run.
02 / ENVIRONMENT RECIPE
- Base commit
7330cdf3a9cdf109a5368ab36cc0543a945b08ee- Manifest
src/CMakeLists.txt- Reproduce
Awaiting issue-specific recipe- Run under trace
Awaiting a meaningful runtime command
03 / ORIGINAL ISSUE TEXT
cemu-project/Cemu #1563 · read the original issue
### Current Behavior
When building Cemu on Mac, the build with default settings is not able to launch games, while the bundled (option `-DMACOS_BUNDLE=ON`) is. I looked through the logs and found this:
```
[18:02:47.090] Vulkan loader not available.
[18:02:49.817] Vulkan cant list devices because Vulkan loader failed
```
It looks like the MoltenVK library is not able to be found. I looked to find what the bundle does differently and found this: https://github.com/cemu-project/Cemu/blob/f801fc1fe85f1e3444f0c1aa7636f52d7c1b7966/src/CMakeLists.txt#L109-L114
This copies the `libMoltenVK` dylib into the Frameworks directory, and adds the directory to the runtime path.
So far, I've tried adding
```
find_library(MOLTENVK_LIB MoltenVK)
if(MOLTENVK_LIB)
target_link_libraries(CemuCafe PRIVATE ${MOLTENVK_LIB})
endif()
```
to [this block](https://github.com/cemu-project/Cemu/blob/f801fc1fe85f1e3444f0c1aa7636f52d7c1b7966/src/Cafe/CMakeLists.txt#L536-L538), as well as setting `LDFLAGS` to `-L/opt/homebrew/opt/molten-vk/lib -lMoltenVK`, and confirmed with `otool` that the dylib appears in the load commands:
```
Load command 13
cmd LC_LOAD_DYLIB
cmdsize 80
name /opt/homebrew/opt/molten-vk/lib/libMoltenVK.dylib (offset 24)
time stamp 2 Wed Dec 31 16:00:02 1969
current version 1.0.0
compatibility version 1.0.0
```
However, this still has not worked.
The following workarounds have succeeded:
1. Using the app bundle with `-DMACOS_BUNDLE=ON`
2. Adding a new runtime path to the binary with `install_name_tool -add_rpath /opt/homebrew/lib bin/Cemu_release`
3. Symlinking the dylib into the existing rpath: `ln -s /opt/homebrew/Cellar/molten-vk/1.3.0/lib/libMoltenVK.dylib build/vcpkg_installed/arm64-osx/lib/`
Any ideas for a way to resolve this through cmake instead of manually?
### Expected Behavior
The Mac non-bundle build should be able to launch games with the Vulkan renderer
### Steps to Reproduce
1. Follow the macOS build steps: https://github.com/cemu-project/Cemu/blob/main/BUILD.md#build-cemu-using-cmake
2. Launch the `./bin/Cemu_release` executable
3. Navigate to Options->General Settings->Graphics and observe the only available Graphics API is OpenGL
### System Info (Optional)
OS: macOS 15.4.1
GPU: Apple M4
### Emulation Settings (Optional)
_No response_
### Logs (Optional)
[log.txt](https://github.com/user-attachments/files/20152630/log.txt)04 / LABELS
Labels from the report text only; not yet run
No supported category has been assigned.
Label rules and the text that matched
[]