mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-04-14 13:28:56 +02:00
[cmake] allow static MinGW/macOS builds; fix clangarm64 (#2994)
Requires qt6-static, obviously... at least for eden. eden-cli also can be built fully static Notable challenges n such: 1. VkMemAlloc conflicts with Qt, since it embeds vk_mem_alloc.h in qrhivulkan; we can get around this by conditionally defining VMA_IMPLEMENTATION; that is, define it in the SDL2 frontend and undef it in the Qt frontend. It's not ideal, but I mean... it works, no? 2. find_library, pkgconfig, and some Config modules will always look for a .dll, so we have to tell CMake to look for .a 3. In spite of this, some will end up using .dll.a (implib) as their link targets; this is, well, bad, so we create a find_library hook that rejects dll.a 4. Some libraries have specific configs (boost lol) 5. Some libraries use _static targets (zstd, mbedtls) 6. Some extra libraries need to be linked, i.e. jbig, lzma, etc 7. QuaZip is sad Needs testing on all platforms, and for both frontends on desktop, to ensure Vulkan still works as expected. (also: CI). Resulting executables are: - 71MB for eden.exe - 39MB for eden-cli.exe Considering the entire libicudt is included (thanks Qt), that's a great size all things considered. No need to bundle all those plugins and translation files too. Theoretically, this lays the groundwork towards fully static executables for other platforms too; though Linux doesn't have a huge benefit since AppImages are needed regardless. eden-room though maybe? Fixes comp for clangarm64 because -msse4.1 Also allows macOS to build with qt6-static. macOS can't build static executables, but with these changes it ONLY relies on system libraries like libc and frameworks. So in theory we don't even need macdeployqt. Signed-off-by: crueter <crueter@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/2994
This commit is contained in:
parent
7764cdd57e
commit
7ca657d22f
25 changed files with 296 additions and 50 deletions
|
|
@ -176,16 +176,28 @@ 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)
|
||||
|
||||
# Only windows has this requirement, thanks windows
|
||||
if (WIN32)
|
||||
if (WIN32 AND ARCHITECTURE_x86_64)
|
||||
add_compile_options("-msse4.1")
|
||||
endif()
|
||||
if (MINGW_STATIC_BUILD)
|
||||
add_compile_definitions(QT_STATICPLUGIN)
|
||||
add_compile_options("-static")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR MINGW)
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#define VMA_IMPLEMENTATION
|
||||
#include "video_core/vulkan_common/vma.h"
|
||||
|
||||
#include <codecvt>
|
||||
#include <locale>
|
||||
|
|
|
|||
|
|
@ -252,7 +252,7 @@ if(CXX_CLANG)
|
|||
endif()
|
||||
|
||||
if (BOOST_NO_HEADERS)
|
||||
target_link_libraries(common PUBLIC Boost::algorithm Boost::icl Boost::pool Boost::filesystem)
|
||||
target_link_libraries(common PUBLIC Boost::algorithm Boost::icl Boost::pool)
|
||||
else()
|
||||
target_link_libraries(common PUBLIC Boost::headers)
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -1199,10 +1199,10 @@ else()
|
|||
target_link_libraries(core PUBLIC Boost::headers)
|
||||
endif()
|
||||
|
||||
target_link_libraries(core PRIVATE fmt::fmt nlohmann_json::nlohmann_json RenderDoc::API MbedTLS::mbedcrypto MbedTLS::mbedtls)
|
||||
if (MINGW)
|
||||
target_link_libraries(core PRIVATE ws2_32 mswsock wlanapi)
|
||||
endif()
|
||||
target_link_libraries(core PRIVATE fmt::fmt nlohmann_json::nlohmann_json RenderDoc::API MbedTLS::mbedcrypto${YUZU_STATIC_SUFFIX} MbedTLS::mbedtls${YUZU_STATIC_SUFFIX})
|
||||
# if (MINGW)
|
||||
# target_link_libraries(core PRIVATE ws2_32 mswsock wlanapi)
|
||||
# endif()
|
||||
|
||||
if (ENABLE_WEB_SERVICE)
|
||||
target_compile_definitions(core PUBLIC ENABLE_WEB_SERVICE)
|
||||
|
|
|
|||
|
|
@ -4,9 +4,6 @@
|
|||
# SPDX-FileCopyrightText: 2017 Citra Emulator Project
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
add_library(yuzu-room STATIC EXCLUDE_FROM_ALL
|
||||
yuzu_room.cpp
|
||||
yuzu_room.h
|
||||
|
|
@ -19,7 +16,7 @@ if (ENABLE_WEB_SERVICE)
|
|||
target_link_libraries(yuzu-room PRIVATE web_service)
|
||||
endif()
|
||||
|
||||
target_link_libraries(yuzu-room PRIVATE MbedTLS::mbedcrypto MbedTLS::mbedtls)
|
||||
target_link_libraries(yuzu-room PRIVATE MbedTLS::mbedcrypto${YUZU_STATIC_SUFFIX} MbedTLS::mbedtls${YUZU_STATIC_SUFFIX})
|
||||
if (MSVC)
|
||||
target_link_libraries(yuzu-room PRIVATE getopt)
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -27,3 +27,12 @@ target_link_libraries(tests PRIVATE common core input_common video_core)
|
|||
target_link_libraries(tests PRIVATE ${PLATFORM_LIBRARIES} Catch2::Catch2WithMain Threads::Threads)
|
||||
|
||||
add_test(NAME tests COMMAND tests)
|
||||
|
||||
# needed for vma
|
||||
if (NOT MSVC)
|
||||
target_compile_options(tests PRIVATE
|
||||
-Wno-conversion
|
||||
-Wno-unused-variable
|
||||
-Wno-unused-parameter
|
||||
-Wno-missing-field-initializers)
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,12 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// SPDX-FileCopyrightText: 2019 Citra Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#define VMA_IMPLEMENTATION
|
||||
#include "video_core/vulkan_common/vma.h"
|
||||
|
||||
#include <array>
|
||||
#include <cstring>
|
||||
#include <type_traits>
|
||||
|
|
|
|||
|
|
@ -312,7 +312,6 @@ add_library(video_core STATIC
|
|||
vulkan_common/vulkan_wrapper.h
|
||||
vulkan_common/nsight_aftermath_tracker.cpp
|
||||
vulkan_common/nsight_aftermath_tracker.h
|
||||
vulkan_common/vma.cpp
|
||||
vulkan_common/vma.h
|
||||
vulkan_common/vulkan.h
|
||||
)
|
||||
|
|
@ -369,9 +368,6 @@ else()
|
|||
# xbyak
|
||||
set_source_files_properties(macro/macro_jit_x64.cpp PROPERTIES COMPILE_OPTIONS "-Wno-conversion;-Wno-shadow")
|
||||
|
||||
# VMA
|
||||
set_source_files_properties(vulkan_common/vma.cpp PROPERTIES COMPILE_OPTIONS "-Wno-conversion;-Wno-unused-variable;-Wno-unused-parameter;-Wno-missing-field-initializers")
|
||||
|
||||
# Get around GCC failing with intrinsics in Debug
|
||||
if (CXX_GCC AND CMAKE_BUILD_TYPE MATCHES "Debug")
|
||||
set_source_files_properties(host1x/vic.cpp PROPERTIES COMPILE_OPTIONS "-O2")
|
||||
|
|
|
|||
|
|
@ -1,6 +0,0 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#define VMA_IMPLEMENTATION
|
||||
|
||||
#include "video_core/vulkan_common/vma.h"
|
||||
|
|
@ -370,15 +370,18 @@ if (APPLE)
|
|||
|
||||
if (YUZU_USE_BUNDLED_MOLTENVK)
|
||||
set(MOLTENVK_PLATFORM "macOS")
|
||||
set(MOLTENVK_VERSION "v1.3.0")
|
||||
set(MOLTENVK_VERSION "v1.4.0")
|
||||
download_moltenvk(${MOLTENVK_PLATFORM} ${MOLTENVK_VERSION})
|
||||
endif()
|
||||
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ".dylib")
|
||||
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})
|
||||
|
||||
set_source_files_properties(${MOLTENVK_LIBRARY} PROPERTIES
|
||||
MACOSX_PACKAGE_LOCATION Frameworks
|
||||
XCODE_FILE_ATTRIBUTES "CodeSignOnCopy")
|
||||
target_sources(yuzu PRIVATE ${MOLTENVK_LIBRARY})
|
||||
elseif(WIN32)
|
||||
# compile as a win32 gui application instead of a console application
|
||||
target_link_libraries(yuzu PRIVATE Qt6::EntryPointPrivate)
|
||||
|
|
@ -447,4 +450,39 @@ if (YUZU_ROOM)
|
|||
target_link_libraries(yuzu PRIVATE Qt6::Widgets)
|
||||
endif()
|
||||
|
||||
if (NOT MSVC AND (APPLE OR NOT YUZU_STATIC_BUILD))
|
||||
# needed for vma
|
||||
target_compile_options(yuzu PRIVATE
|
||||
-Wno-conversion
|
||||
-Wno-unused-variable
|
||||
-Wno-unused-parameter
|
||||
-Wno-missing-field-initializers)
|
||||
endif()
|
||||
|
||||
## certain libraries need extra static libs to be linked ##
|
||||
# I have no fucking clue why it ONLY has to be on yuzu
|
||||
# yuzu_cmd works totally fine but not this??????????
|
||||
if (YUZU_STATIC_BUILD AND MINGW)
|
||||
macro(extra_libs)
|
||||
foreach(lib ${ARGN})
|
||||
find_library(${lib}_LIBRARY ${lib} REQUIRED)
|
||||
target_link_libraries(yuzu PRIVATE ${${lib}_LIBRARY})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
# I am constantly impressed at how ridiculously stupid the linker is
|
||||
# NB: yes, we have to put them here twice. I have no idea why
|
||||
|
||||
# libtiff.a
|
||||
extra_libs(tiff jbig bz2 lzma deflate jpeg tiff)
|
||||
|
||||
# libfreetype.a
|
||||
extra_libs(freetype bz2 Lerc brotlidec brotlicommon freetype)
|
||||
|
||||
# libharfbuzz.a
|
||||
extra_libs(harfbuzz graphite2)
|
||||
|
||||
extra_libs(wsock32 ws2_32 crypt32 mswsock wlanapi)
|
||||
endif()
|
||||
|
||||
create_target_directory_groups(yuzu)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,11 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// Qt on macOS doesn't define VMA shit
|
||||
#if defined(QT_STATICPLUGIN) && !defined(__APPLE__)
|
||||
#undef VMA_IMPLEMENTATION
|
||||
#endif
|
||||
|
||||
#include "common/fs/ryujinx_compat.h"
|
||||
#include "main_window.h"
|
||||
#include "network/network.h"
|
||||
|
|
@ -44,6 +49,7 @@
|
|||
|
||||
// Qt Stuff //
|
||||
#define QT_NO_OPENGL
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
|
||||
#include <QStyleHints>
|
||||
#endif
|
||||
|
|
@ -263,7 +269,14 @@ using namespace Common::Literals;
|
|||
#endif
|
||||
|
||||
#ifdef QT_STATICPLUGIN
|
||||
#include <QtPlugin>
|
||||
|
||||
#if defined(_WIN32)
|
||||
Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin);
|
||||
#elif defined(__APPLE__)
|
||||
Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
|
|
@ -4897,3 +4910,8 @@ void VolumeButton::ResetMultiplier() {
|
|||
#ifdef main
|
||||
#undef main
|
||||
#endif
|
||||
|
||||
#if !defined(QT_STATICPLUGIN) || defined(__APPLE__)
|
||||
#define VMA_IMPLEMENTATION
|
||||
#include "video_core/vulkan_common/vma.h"
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -56,3 +56,12 @@ if(WIN32)
|
|||
endif()
|
||||
|
||||
create_target_directory_groups(yuzu-cmd)
|
||||
|
||||
# needed for vma
|
||||
if (NOT MSVC)
|
||||
target_compile_options(yuzu-cmd PRIVATE
|
||||
-Wno-conversion
|
||||
-Wno-unused-variable
|
||||
-Wno-unused-parameter
|
||||
-Wno-missing-field-initializers)
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -4,12 +4,10 @@
|
|||
// SPDX-FileCopyrightText: 2014 Citra Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <regex>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
|
||||
#include <fmt/ostream.h>
|
||||
|
||||
|
|
@ -17,7 +15,6 @@
|
|||
#include "common/logging/backend.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "common/scm_rev.h"
|
||||
#include "common/scope_exit.h"
|
||||
#include "common/settings.h"
|
||||
#include "common/string_util.h"
|
||||
#include "core/core.h"
|
||||
|
|
@ -453,3 +450,6 @@ int main(int argc, char** argv) {
|
|||
detached_tasks.WaitForAllTasks();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define VMA_IMPLEMENTATION
|
||||
#include "video_core/vulkan_common/vma.h"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
add_executable(yuzu_room_standalone
|
||||
yuzu_room_standalone.cpp
|
||||
)
|
||||
|
|
@ -9,3 +12,5 @@ target_link_libraries(yuzu_room_standalone PRIVATE yuzu-room)
|
|||
if(UNIX AND NOT APPLE)
|
||||
install(TARGETS yuzu_room_standalone RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
|
||||
endif()
|
||||
|
||||
create_target_directory_groups(yuzu_room_standalone)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue