mirror of
https://github.com/86Box/86Box.git
synced 2025-01-22 09:11:50 -05:00
macOS: Add Vulkan support via MoltenVK (#2650)
* macOS: Add the ability to build with and bundle MoltenVK for Vulkan support * macOS: Add cmake variable for RPATH as needed by macports moltenvk lib * macOS: Change minimum macOS target for vulkan builds Co-authored-by: cold-brewed <cold-brewed@users.noreply.github.com>
This commit is contained in:
parent
eb185a43c2
commit
aeee37490a
3 changed files with 36 additions and 2 deletions
|
@ -165,6 +165,9 @@ cmake_dependent_option(XL24 "ATI VGA Wonder XL24 (ATI-28800-6)"
|
|||
# Ditto but for Qt
|
||||
if(QT)
|
||||
option(USE_QT6 "Use Qt6 instead of Qt5" OFF)
|
||||
if(APPLE)
|
||||
option(MOLTENVK "Use MoltenVK libraries for Vulkan support on macOS. Requires a Vulkan-enabled QT." OFF)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Determine the build type
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
# Copyright 2020-2022 David Hrdlička.
|
||||
# Copyright 2021 dob205.
|
||||
#
|
||||
if(APPLE)
|
||||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||
endif()
|
||||
|
||||
add_executable(86Box 86box.c config.c log.c random.c timer.c io.c acpi.c apm.c
|
||||
dma.c ddma.c discord.c nmi.c pic.c pit.c pit_fast.c port_6x.c port_92.c ppi.c pci.c
|
||||
|
@ -83,11 +86,16 @@ if(APPLE)
|
|||
# Force using the newest library if it's installed by homebrew
|
||||
set(CMAKE_FIND_FRAMEWORK LAST)
|
||||
|
||||
# setting our compilation target to macOS 10.15 Catalina if targetting Qt6, macOS 10.13 High Sierra otherwise
|
||||
# setting our compilation target to macOS 10.15 Catalina if targeting Qt6,
|
||||
# macOS 10.14 Mojave for vulkan support, 10.13 High Sierra otherwise
|
||||
if (USE_QT6)
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15")
|
||||
else()
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13")
|
||||
if(MOLTENVK)
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14")
|
||||
else()
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
|
@ -209,6 +209,18 @@ endif()
|
|||
|
||||
if (APPLE)
|
||||
target_sources(ui PRIVATE macos_event_filter.mm)
|
||||
if(MOLTENVK)
|
||||
find_path(MOLTENVK_INCLUDE "vulkan/vulkan.h" PATHS "/opt/homebrew/opt/molten-vk/libexec/include" "/usr/local/opt/molten-vk/libexec/include" ${MOLTENVK_INCLUDE_DIR})
|
||||
if (NOT MOLTENVK_INCLUDE)
|
||||
message(FATAL_ERROR "Could not find vulkan/vulkan.h. If the headers are installed please use -DMOLTENVK_INCLUDE_DIR=/path/to/headers")
|
||||
endif()
|
||||
target_include_directories(ui PRIVATE ${MOLTENVK_INCLUDE})
|
||||
find_library(MOLTENVK_LIB MoltenVK)
|
||||
if (NOT MOLTENVK_LIB)
|
||||
message(FATAL_ERROR "Could not find MoltenVK library")
|
||||
endif()
|
||||
target_link_libraries(ui PRIVATE "${MOLTENVK_LIB}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
|
@ -285,6 +297,7 @@ if (APPLE AND CMAKE_MACOSX_BUNDLE)
|
|||
set(prefix "86Box.app/Contents")
|
||||
set(INSTALL_RUNTIME_DIR "${prefix}/MacOS")
|
||||
set(INSTALL_CMAKE_DIR "${prefix}/Resources")
|
||||
set(INSTALL_LIB_DIR "${prefix}/Frameworks")
|
||||
|
||||
# using the install_qt5_plugin to add Qt plugins into the macOS app bundle
|
||||
install_qt5_plugin("Qt${QT_MAJOR}::QCocoaIntegrationPlugin" QT_PLUGINS ${prefix})
|
||||
|
@ -317,6 +330,16 @@ if (APPLE AND CMAKE_MACOSX_BUNDLE)
|
|||
COMMAND ${CMAKE_INSTALL_NAME_TOOL} -add_rpath \"@executable_path/../Frameworks/\"
|
||||
\"\${CMAKE_INSTALL_PREFIX_ABSOLUTE}/${INSTALL_RUNTIME_DIR}/86Box\")
|
||||
")
|
||||
if(MOLTENVK)
|
||||
install(CODE "
|
||||
execute_process(
|
||||
COMMAND bash -c \"set -e
|
||||
echo \\\"-- Creating vulkan dylib symlink for QT (libVulkan.dylib -> libMoltenVK.dylib)\\\"
|
||||
cd \${CMAKE_INSTALL_PREFIX_ABSOLUTE}/${INSTALL_LIB_DIR}
|
||||
ln -sf libMoltenVK.dylib libVulkan.dylib
|
||||
\")
|
||||
")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (UNIX AND NOT APPLE AND NOT HAIKU)
|
||||
|
|
Loading…
Reference in a new issue