diff --git a/CMakeLists.txt b/CMakeLists.txt index 24abe57455..d4f530d269 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -128,26 +128,9 @@ if (YUZU_STATIC_BUILD) set(YUZU_STATIC_SUFFIX _static) ## some libraries use CMAKE_IMPORT_LIBRARY_SUFFIX e.g. Harfbuzz ## - set(CMAKE_IMPORT_LIBRARY_SUFFIX ".a") + set(CMAKE_IMPORT_LIBRARY_SUFFIX ".a;.tbd;.dylib") - # simple hook to reject ".dll.a" libraries - function(find_library var) - # also skip previously-found libraries cuz... yaknow - if (${var}) - return() - endif() - - _find_library(${var} ${ARGN}) - if (${var}) - get_filename_component(lib_name "${${var}}" NAME) - if (lib_name MATCHES "dll\\.a$") - unset(${var} CACHE) - set(${var} "${var}-NOTFOUND" CACHE INTERNAL "" FORCE) - endif() - endif() - endfunction() - - ## other hooks needed ## + ## certain libraries need extra static libs to be linked ## macro(extra_libs) foreach(lib ${ARGN}) find_library(${lib}_LIBRARY ${lib} REQUIRED) @@ -155,20 +138,51 @@ if (YUZU_STATIC_BUILD) endforeach() endmacro() - # libtiff.a - extra_libs(jbig lzma deflate) + if (MINGW) + set(SKIP_LIBRARY_SUFFIX "dll\\.a$") + # simple hook to reject dynamic libs + function(find_library var) + # also skip previously-found libraries cuz... yaknow + if (${var}) + return() + endif() - # libfreetype.a - extra_libs(bz2 Lerc) + _find_library(${var} ${ARGN}) + if (${var}) + get_filename_component(lib_name "${${var}}" NAME) + if (lib_name MATCHES "${SKIP_LIBRARY_SUFFIX}") + unset(${var} CACHE) + set(${var} "${var}-NOTFOUND" CACHE INTERNAL "" FORCE) + endif() + endif() + endfunction() + + # libtiff.a + extra_libs(jbig lzma deflate) + + # libfreetype.a + extra_libs(bz2 Lerc) - # libharfbuzz.a - extra_libs(graphite2) + # libharfbuzz.a + extra_libs(graphite2) - # libbrotlienc.a - extra_libs(brotlienc brotlidec brotlicommon) + # libbrotlienc.a + extra_libs(brotlienc brotlidec brotlicommon brotlienc brotlidec) - # msys2 quazip does not build a static lib - set(QuaZip-Qt6_FORCE_BUNDLED ON) + # msys2 quazip does not build a static lib + set(QuaZip-Qt6_FORCE_BUNDLED ON) + elseif(APPLE) + # foreach(prefix zlib vdpau) + # list(APPEND CMAKE_LIBRARY_PATH "/opt/homebrew/opt/${prefix}/lib") + # endforeach() + + # these libs do not properly provide static libs/let you do it with cmake + set(YUZU_USE_CPM ON) + set(YUZU_USE_BUNDLED_FFMPEG ON) + set(fmt_FORCE_BUNDLED ON) + set(SPIRV-Tools_FORCE_BUNDLED ON) + set(SPIRV-Headers_FORCE_BUNDLED ON) + endif() endif() # Detect current compilation architecture and create standard definitions @@ -721,8 +735,8 @@ if (APPLE) # Umbrella framework for everything GUI-related find_library(COCOA_LIBRARY Cocoa) set(PLATFORM_LIBRARIES ${COCOA_LIBRARY} ${IOKIT_LIBRARY} ${COREVIDEO_LIBRARY}) - find_library(ICONV_LIBRARY iconv REQUIRED) - list(APPEND PLATFORM_LIBRARIES ${ICONV_LIBRARY}) + # find_library(ICONV_LIBRARY iconv REQUIRED) + # list(APPEND PLATFORM_LIBRARIES ${ICONV_LIBRARY}) elseif (WIN32) # Target Windows 10 add_compile_definitions(_WIN32_WINNT=0x0A00 WINVER=0x0A00) @@ -1071,4 +1085,4 @@ if(ENABLE_QT AND UNIX AND NOT APPLE) DESTINATION "share/mime/packages") install(FILES "dist/dev.eden_emu.eden.metainfo.xml" DESTINATION "share/metainfo") -endif() +endif() \ No newline at end of file diff --git a/CMakeModules/CPMUtil.cmake b/CMakeModules/CPMUtil.cmake index 1c4a4874c6..78bab05030 100644 --- a/CMakeModules/CPMUtil.cmake +++ b/CMakeModules/CPMUtil.cmake @@ -542,10 +542,11 @@ function(AddCIPackage) PACKAGE EXTENSION MIN_VERSION - DISABLED_PLATFORMS ) - cmake_parse_arguments(PKG_ARGS "" "${oneValueArgs}" "" ${ARGN}) + set(multiValueArgs DISABLED_PLATFORMS) + + cmake_parse_arguments(PKG_ARGS "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) if(NOT DEFINED PKG_ARGS_VERSION) message(FATAL_ERROR "[CPMUtil] VERSION is required") diff --git a/externals/ffmpeg/CMakeLists.txt b/externals/ffmpeg/CMakeLists.txt index 995b25a2c7..1289c53c99 100644 --- a/externals/ffmpeg/CMakeLists.txt +++ b/externals/ffmpeg/CMakeLists.txt @@ -89,7 +89,7 @@ if (UNIX AND NOT ANDROID) endif(CUDA_FOUND) endif() - if (VDPAU_FOUND) + if (VDPAU_FOUND AND NOT APPLE) list(APPEND FFmpeg_HWACCEL_FLAGS --enable-vdpau --enable-hwaccel=h264_vdpau diff --git a/externals/ffmpeg/cpmfile.json b/externals/ffmpeg/cpmfile.json index 6337e083a9..9f7f0bea68 100644 --- a/externals/ffmpeg/cpmfile.json +++ b/externals/ffmpeg/cpmfile.json @@ -15,8 +15,7 @@ "disabled_platforms": [ "freebsd-amd64", "solaris-amd64", - "openbsd-amd64", - "macos-universal" + "openbsd-amd64" ] } } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0aa959673c..5f2d076899 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -176,6 +176,21 @@ else() add_compile_definitions(_FILE_OFFSET_BITS=64) endif() + if (YUZU_STATIC_BUILD) + add_compile_definitions(QT_STATICPLUGIN) + + # macos doesn't even let you make static executables... wtf? + if (NOT APPLE) + add_compile_options(-static) + if (YUZU_STATIC_BUILD) + # yuzu-cmd requires us to explicitly link libpthread, libgcc, and libstdc++ as static + # At a guess, it's probably because Qt handles the Qt executable for us, whereas this does not + add_link_options(-static -lpthread) + add_link_options(-static-libgcc -static-libstdc++) + endif() + endif() + endif() + if (MINGW) add_compile_definitions(MINGW_HAS_SECURE_API) @@ -183,11 +198,6 @@ else() if (WIN32 AND ARCHITECTURE_x86_64) add_compile_options("-msse4.1") endif() - - if (YUZU_STATIC_BUILD) - add_compile_definitions(QT_STATICPLUGIN) - add_compile_options(-static) - endif() endif() if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR MINGW) diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt index dba49be0ec..2e1f8cf0f1 100644 --- a/src/yuzu/CMakeLists.txt +++ b/src/yuzu/CMakeLists.txt @@ -447,7 +447,7 @@ if (YUZU_ROOM) target_link_libraries(yuzu PRIVATE Qt6::Widgets) endif() -if (NOT MSVC AND NOT YUZU_STATIC_BUILD) +if (NOT MSVC AND (APPLE OR NOT YUZU_STATIC_BUILD)) # needed for vma target_compile_options(yuzu PRIVATE -Wno-conversion diff --git a/src/yuzu/main_window.cpp b/src/yuzu/main_window.cpp index a5e692c8d1..1547c96dd7 100644 --- a/src/yuzu/main_window.cpp +++ b/src/yuzu/main_window.cpp @@ -1,7 +1,8 @@ // SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later -#ifdef QT_STATICPLUGIN +// Qt on macOS doesn't define VMA shit +#if defined(QT_STATICPLUGIN) && !defined(__APPLE__) #undef VMA_IMPLEMENTATION #endif @@ -269,7 +270,13 @@ using namespace Common::Literals; #ifdef QT_STATICPLUGIN #include + +#if defined(_WIN32) Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin); +#elif defined(__APPLE__) +Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin) +#endif + #endif #ifdef _WIN32 @@ -4904,7 +4911,7 @@ void VolumeButton::ResetMultiplier() { #undef main #endif -#ifndef QT_STATICPLUGIN +#if !defined(QT_STATICPLUGIN) || defined(__APPLE__) #define VMA_IMPLEMENTATION #include "video_core/vulkan_common/vma.h" #endif diff --git a/src/yuzu_cmd/CMakeLists.txt b/src/yuzu_cmd/CMakeLists.txt index df6902c5c0..458eaafc4c 100644 --- a/src/yuzu_cmd/CMakeLists.txt +++ b/src/yuzu_cmd/CMakeLists.txt @@ -57,13 +57,6 @@ endif() create_target_directory_groups(yuzu-cmd) -if (YUZU_STATIC_BUILD) - # yuzu-cmd requires us to explicitly link libpthread, libgcc, and libstdc++ as static - # At a guess, it's probably because Qt handles the Qt executable for us, whereas this does not - target_link_options(yuzu-cmd PRIVATE -static -lpthread) - target_link_options(yuzu-cmd PRIVATE -static-libgcc -static-libstdc++) -endif() - # needed for vma if (NOT MSVC) target_compile_options(yuzu-cmd PRIVATE diff --git a/src/yuzu_room_standalone/CMakeLists.txt b/src/yuzu_room_standalone/CMakeLists.txt index c498cff6bc..f1db470495 100644 --- a/src/yuzu_room_standalone/CMakeLists.txt +++ b/src/yuzu_room_standalone/CMakeLists.txt @@ -13,11 +13,4 @@ if(UNIX AND NOT APPLE) install(TARGETS yuzu_room_standalone RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin") endif() -if (YUZU_STATIC_BUILD) - # yuzu_room_standalone requires us to explicitly link libpthread, libgcc, and libstdc++ as static - # At a guess, it's probably because Qt handles the Qt executable for us, whereas this does not - target_link_options(yuzu_room_standalone PRIVATE -static -lpthread) - target_link_options(yuzu_room_standalone PRIVATE -static-libgcc -static-libstdc++) -endif() - create_target_directory_groups(yuzu_room_standalone)