Add macos moltenvk bundle, Add copy moltevk dylib script
This commit is contained in:
parent
a8c4f01f6c
commit
87022a4833
|
@ -49,7 +49,7 @@ option(YUZU_TESTS "Compile tests" "${BUILD_TESTING}")
|
||||||
|
|
||||||
option(YUZU_USE_PRECOMPILED_HEADERS "Use precompiled headers" ON)
|
option(YUZU_USE_PRECOMPILED_HEADERS "Use precompiled headers" ON)
|
||||||
|
|
||||||
cmake_dependent_option(YUZU_ROOM "Compile LDN room server" ON "NOT ANDROID" OFF)
|
CMAKE_DEPENDENT_OPTION(YUZU_ROOM "Compile LDN room server" ON "NOT ANDROID" OFF)
|
||||||
|
|
||||||
CMAKE_DEPENDENT_OPTION(YUZU_CRASH_DUMPS "Compile Windows crash dump (Minidump) support" OFF "WIN32" OFF)
|
CMAKE_DEPENDENT_OPTION(YUZU_CRASH_DUMPS "Compile Windows crash dump (Minidump) support" OFF "WIN32" OFF)
|
||||||
|
|
||||||
|
@ -63,6 +63,8 @@ option(YUZU_DOWNLOAD_TIME_ZONE_DATA "Always download time zone binaries" OFF)
|
||||||
|
|
||||||
CMAKE_DEPENDENT_OPTION(YUZU_USE_FASTER_LD "Check if a faster linker is available" ON "NOT WIN32" OFF)
|
CMAKE_DEPENDENT_OPTION(YUZU_USE_FASTER_LD "Check if a faster linker is available" ON "NOT WIN32" OFF)
|
||||||
|
|
||||||
|
CMAKE_DEPENDENT_OPTION(USE_SYSTEM_MOLTENVK "Use the system MoltenVK lib (instead of the bundled one)" OFF "APPLE" OFF)
|
||||||
|
|
||||||
set(DEFAULT_ENABLE_OPENSSL ON)
|
set(DEFAULT_ENABLE_OPENSSL ON)
|
||||||
if (ANDROID OR WIN32 OR APPLE)
|
if (ANDROID OR WIN32 OR APPLE)
|
||||||
# - Windows defaults to the Schannel backend.
|
# - Windows defaults to the Schannel backend.
|
||||||
|
|
|
@ -36,3 +36,21 @@ endif()
|
||||||
message(STATUS "Using bundled binaries at ${prefix}")
|
message(STATUS "Using bundled binaries at ${prefix}")
|
||||||
set(${prefix_var} "${prefix}" PARENT_SCOPE)
|
set(${prefix_var} "${prefix}" PARENT_SCOPE)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
function(download_moltenvk_external platform version)
|
||||||
|
set(MOLTENVK_DIR "${CMAKE_BINARY_DIR}/externals/MoltenVK")
|
||||||
|
set(MOLTENVK_TAR "${CMAKE_BINARY_DIR}/externals/MoltenVK.tar")
|
||||||
|
if (NOT EXISTS ${MOLTENVK_DIR})
|
||||||
|
if (NOT EXISTS ${MOLTENVK_TAR})
|
||||||
|
file(DOWNLOAD https://github.com/KhronosGroup/MoltenVK/releases/download/${version}/MoltenVK-${platform}.tar
|
||||||
|
${MOLTENVK_TAR} SHOW_PROGRESS)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xf "${MOLTENVK_TAR}"
|
||||||
|
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/externals")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Add the MoltenVK library path to the prefix so find_library can locate it.
|
||||||
|
list(APPEND CMAKE_PREFIX_PATH "${MOLTENVK_DIR}/MoltenVK/dylib/${platform}")
|
||||||
|
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
|
@ -41,9 +41,6 @@ namespace {
|
||||||
bool enable_validation) {
|
bool enable_validation) {
|
||||||
std::vector<const char*> extensions;
|
std::vector<const char*> extensions;
|
||||||
extensions.reserve(6);
|
extensions.reserve(6);
|
||||||
#ifdef __APPLE__
|
|
||||||
extensions.push_back(VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME);
|
|
||||||
#endif
|
|
||||||
switch (window_type) {
|
switch (window_type) {
|
||||||
case Core::Frontend::WindowSystemType::Headless:
|
case Core::Frontend::WindowSystemType::Headless:
|
||||||
break;
|
break;
|
||||||
|
@ -74,6 +71,11 @@ namespace {
|
||||||
if (window_type != Core::Frontend::WindowSystemType::Headless) {
|
if (window_type != Core::Frontend::WindowSystemType::Headless) {
|
||||||
extensions.push_back(VK_KHR_SURFACE_EXTENSION_NAME);
|
extensions.push_back(VK_KHR_SURFACE_EXTENSION_NAME);
|
||||||
}
|
}
|
||||||
|
#ifdef __APPLE__
|
||||||
|
if (AreExtensionsSupported(dld, std::array{VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME})) {
|
||||||
|
extensions.push_back(VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (enable_validation) {
|
if (enable_validation) {
|
||||||
const bool debug_utils =
|
const bool debug_utils =
|
||||||
AreExtensionsSupported(dld, std::array{VK_EXT_DEBUG_UTILS_EXTENSION_NAME});
|
AreExtensionsSupported(dld, std::array{VK_EXT_DEBUG_UTILS_EXTENSION_NAME});
|
||||||
|
|
|
@ -19,13 +19,17 @@ std::shared_ptr<Common::DynamicLibrary> OpenLibrary(
|
||||||
#else
|
#else
|
||||||
auto library = std::make_shared<Common::DynamicLibrary>();
|
auto library = std::make_shared<Common::DynamicLibrary>();
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
const auto libvulkan_filename =
|
||||||
|
Common::FS::GetBundleDirectory() / "Contents/Frameworks/libvulkan.1.dylib";
|
||||||
|
const auto libmoltenvk_filename =
|
||||||
|
Common::FS::GetBundleDirectory() / "Contents/Frameworks/libMoltenVK.dylib";
|
||||||
|
const char* library_paths[] = {std::getenv("LIBVULKAN_PATH"), libvulkan_filename.c_str(),
|
||||||
|
libmoltenvk_filename.c_str()};
|
||||||
// Check if a path to a specific Vulkan library has been specified.
|
// Check if a path to a specific Vulkan library has been specified.
|
||||||
char* const libvulkan_env = std::getenv("LIBVULKAN_PATH");
|
for (const auto& library_path : library_paths) {
|
||||||
if (!libvulkan_env || !library->Open(libvulkan_env)) {
|
if (library_path && library->Open(library_path)) {
|
||||||
// Use the libvulkan.dylib from the application bundle.
|
break;
|
||||||
const auto filename =
|
}
|
||||||
Common::FS::GetBundleDirectory() / "Contents/Frameworks/libvulkan.dylib";
|
|
||||||
void(library->Open(Common::FS::PathToUTF8String(filename).c_str()));
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
std::string filename = Common::DynamicLibrary::GetVersionedFilename("vulkan", 1);
|
std::string filename = Common::DynamicLibrary::GetVersionedFilename("vulkan", 1);
|
||||||
|
|
|
@ -313,6 +313,18 @@ if (APPLE)
|
||||||
target_sources(yuzu PRIVATE ${MACOSX_ICON})
|
target_sources(yuzu PRIVATE ${MACOSX_ICON})
|
||||||
set_target_properties(yuzu PROPERTIES MACOSX_BUNDLE TRUE)
|
set_target_properties(yuzu PROPERTIES MACOSX_BUNDLE TRUE)
|
||||||
set_target_properties(yuzu PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist)
|
set_target_properties(yuzu PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist)
|
||||||
|
|
||||||
|
if (NOT USE_SYSTEM_MOLTENVK)
|
||||||
|
set(MOLTENVK_PLATFORM "macOS")
|
||||||
|
set(MOLTENVK_VERSION "v1.2.5")
|
||||||
|
download_moltenvk_external(${MOLTENVK_PLATFORM} ${MOLTENVK_VERSION})
|
||||||
|
endif()
|
||||||
|
find_library(MOLTENVK_LIBRARY MoltenVK REQUIRED)
|
||||||
|
message(STATUS "Using MoltenVK at ${MOLTENVK_LIBRARY}.")
|
||||||
|
set_source_files_properties(${MOLTENVK_LIBRARY} PROPERTIES MACOSX_PACKAGE_LOCATION Frameworks
|
||||||
|
XCODE_FILE_ATTRIBUTES "CodeSignOnCopy")
|
||||||
|
target_sources(yuzu PRIVATE ${MOLTENVK_LIBRARY})
|
||||||
|
|
||||||
elseif(WIN32)
|
elseif(WIN32)
|
||||||
# compile as a win32 gui application instead of a console application
|
# compile as a win32 gui application instead of a console application
|
||||||
if (QT_VERSION VERSION_GREATER_EQUAL 6)
|
if (QT_VERSION VERSION_GREATER_EQUAL 6)
|
||||||
|
|
Loading…
Reference in New Issue