Browse Source

Enable macOS static builds

Signed-off-by: crueter <crueter@eden-emu.dev>
pull/2994/head
crueter 4 months ago
parent
commit
487d0aa3a4
No known key found for this signature in database GPG Key ID: 425ACD2D4830EBC6
  1. 78
      CMakeLists.txt
  2. 5
      CMakeModules/CPMUtil.cmake
  3. 2
      externals/ffmpeg/CMakeLists.txt
  4. 3
      externals/ffmpeg/cpmfile.json
  5. 20
      src/CMakeLists.txt
  6. 2
      src/yuzu/CMakeLists.txt
  7. 11
      src/yuzu/main_window.cpp
  8. 7
      src/yuzu_cmd/CMakeLists.txt
  9. 7
      src/yuzu_room_standalone/CMakeLists.txt

78
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()

5
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")

2
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

3
externals/ffmpeg/cpmfile.json

@ -15,8 +15,7 @@
"disabled_platforms": [
"freebsd-amd64",
"solaris-amd64",
"openbsd-amd64",
"macos-universal"
"openbsd-amd64"
]
}
}

20
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)

2
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

11
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 <QtPlugin>
#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

7
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

7
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)
Loading…
Cancel
Save