Lime3DS/src/citra_meta/CMakeLists.txt
Sergei Golishnikov 04f3a93854
macos: fix Vulkan/Metal renderer on macOS 26+ and bump MoltenVK (#2149)
* macos: fix Vulkan/Metal renderer on macOS 26+ and bump MoltenVK

Four related changes that together let the Vulkan backend boot a game
on Apple Silicon Macs running macOS 26.x. Each is needed independently;
the combination was tested on a Mac16,6 (M4 Max) / macOS 26.4.1.

CMakeModules/DownloadExternals.cmake:
  Bump bundled MoltenVK from v1.2.9 to v1.4.1. v1.2.9 does not
  recognize macOS 26 surface objects and traps with an Objective-C
  "unrecognized selector" inside vkGetPhysicalDeviceSurfaceCapabilitiesKHR.

src/video_core/renderer_vulkan/vk_instance.cpp:
  Disable VK_EXT_tooling_info on MoltenVK. MoltenVK advertises the
  extension but does not expose vkGetPhysicalDeviceToolPropertiesEXT
  through its dispatcher, so the call inside CollectToolingInfo()
  trips a vulkan-hpp assertion in Debug and dereferences NULL in
  Release.

src/citra_qt/bootmanager.cpp:
  Force-install a fresh CAMetalLayer on the NSView before handing it
  to createMetalSurfaceEXT. Qt 6.11's QWindow::MetalSurface does not
  always back the view with a CAMetalLayer on macOS 26, and MoltenVK
  1.3+ aborts in MVKSurface::getNaturalExtent() if the layer is not
  the right class. Implemented via objc_msgSend so no .mm conversion
  is needed.

src/citra_meta/CMakeLists.txt:
  Gate LaunchScreen.storyboard behind 'if (IOS)'. The storyboard is
  iOS-only and previously broke the Xcode generator on macOS with
  "iOS storyboards do not support target device type 'mac'."

* Move Metal layer creation logic into MetalUtil::CreateMetalLayer ObjC++ function

This change makes the code much more readable, as the logic is now in its native language

---------

Co-authored-by: SergeyMild <>
Co-authored-by: OpenSauce04 <opensauce04@gmail.com>
2026-06-17 16:15:42 +01:00

123 lines
4.2 KiB
CMake

add_executable(citra_meta
citra.rc
main.cpp
precompiled_headers.h
)
set_target_properties(citra_meta PROPERTIES OUTPUT_NAME "azahar")
if (BSD STREQUAL "NetBSD")
include(DisablePaxMprotect)
disable_pax_mprotect(citra_meta)
endif()
if (APPLE)
set(DIST_DIR "../../dist/apple")
set(APPLE_RESOURCES
"${DIST_DIR}/azahar.icns"
"${DIST_DIR}/launch_logo.png"
)
if (IOS)
list(APPEND APPLE_RESOURCES "${DIST_DIR}/LaunchScreen.storyboard")
endif()
target_sources(citra_meta PRIVATE ${APPLE_RESOURCES})
# Define app bundle metadata.
include(GenerateBuildInfo)
set(SRC_DIR "${PROJECT_SOURCE_DIR}")
generate_build_info()
set_target_properties(citra_meta PROPERTIES
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_INFO_PLIST "${DIST_DIR}/Info.plist.in"
MACOSX_BUNDLE_BUNDLE_NAME "Azahar"
MACOSX_BUNDLE_GUI_IDENTIFIER "org.azahar-emu.azahar"
MACOSX_BUNDLE_BUNDLE_VERSION "${BUILD_VERSION}"
MACOSX_BUNDLE_SHORT_VERSION_STRING "${BUILD_FULLNAME}"
MACOSX_BUNDLE_LONG_VERSION_STRING "${BUILD_FULLNAME}"
MACOSX_BUNDLE_ICON_FILE "azahar.icns"
RESOURCE "${APPLE_RESOURCES}"
)
if (IOS)
set_target_properties(citra_meta PROPERTIES
# Have Xcode copy and sign MoltenVK into app bundle.
XCODE_EMBED_FRAMEWORKS "${MOLTENVK_LIBRARY}"
XCODE_EMBED_FRAMEWORKS_CODE_SIGN_ON_COPY YES
XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@executable_path/Frameworks"
# Support iPhone and iPad.
XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "1,2"
)
endif()
endif()
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux" AND MINGW)
# TODO: Do this for all executables, not just citra_meta
# TODO: Don't hardcode MXE directory to root?
set(dllwalker_command "${CMAKE_SOURCE_DIR}/externals/dllwalker/dllwalker.rb"
$<TARGET_FILE:citra_meta>
/mxe/usr/x86_64-w64-mingw32.shared/bin/
/mxe/usr/x86_64-w64-mingw32.shared/qt6/bin/)
set(dll_list_filename "${CMAKE_CURRENT_BINARY_DIR}/required_dlls_list.txt")
add_custom_command(TARGET citra_meta POST_BUILD
COMMAND ${dllwalker_command} > ${dll_list_filename}
)
add_custom_command(TARGET citra_meta POST_BUILD
COMMAND cat ${dll_list_filename} | xargs -I {} ${CMAKE_COMMAND} -E copy {} $<TARGET_FILE_DIR:citra_meta>
COMMAND ${CMAKE_COMMAND} -E make_directory "$<TARGET_FILE_DIR:citra_meta>/plugins/"
COMMAND ${CMAKE_COMMAND} -E copy_directory /mxe/usr/x86_64-w64-mingw32.shared/qt6/plugins/ "$<TARGET_FILE_DIR:citra_meta>/plugins/"
COMMAND_EXPAND_LISTS
DEPENDS ${dll_list_filename}
)
endif()
target_link_libraries(citra_meta PRIVATE citra_cli citra_common fmt)
if (ENABLE_QT)
target_link_libraries(citra_meta PRIVATE citra_qt)
target_link_libraries(citra_meta PRIVATE Boost::boost Qt6::Widgets)
endif()
if (ENABLE_ROOM)
target_link_libraries(citra_meta PRIVATE citra_room)
endif()
if (ENABLE_QT AND UNIX AND NOT APPLE)
target_link_libraries(citra_meta PRIVATE Qt6::DBus gamemode)
endif()
if (ENABLE_QT AND APPLE)
find_package(Qt6 REQUIRED COMPONENTS GuiPrivate)
target_link_libraries(citra_meta PRIVATE Qt6::GuiPrivate)
endif()
if (ENABLE_QT AND USE_DISCORD_PRESENCE)
target_link_libraries(citra_meta PRIVATE discord-rpc)
endif()
if(WIN32)
# compile as a win32 gui application instead of a console application
if(MSVC)
set_target_properties(citra_meta PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS")
elseif(MINGW)
set_target_properties(citra_meta PROPERTIES LINK_FLAGS_RELEASE "-mwindows")
endif()
endif()
if (CITRA_USE_PRECOMPILED_HEADERS)
target_precompile_headers(citra_meta PRIVATE precompiled_headers.h)
endif()
if (SSE42_COMPILE_OPTION)
target_compile_definitions(citra_meta PRIVATE CITRA_HAS_SSE42)
endif()
# Bundle in-place on MSVC so dependencies can be resolved by builds.
if (ENABLE_QT AND MSVC)
include(BundleTarget)
qt_bundle_target_in_place(citra_meta)
endif()
if(UNIX AND NOT APPLE)
install(TARGETS citra_meta RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
endif()