aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorcrueter <crueter@eden-emu.dev>2025-11-11 06:22:33 +0100
committercrueter <crueter@eden-emu.dev>2025-11-11 06:22:33 +0100
commit7ca657d22f59a66879e7fe8fea710949c38f4d0a (patch)
treed67583b074aadc896ef97696a79c59cf44280c48 /src
parent7764cdd57ec8a6d97eed904e6e125c0c5fda2f79 (diff)
[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
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt22
-rw-r--r--src/android/app/src/main/jni/native.cpp2
-rw-r--r--src/common/CMakeLists.txt2
-rw-r--r--src/core/CMakeLists.txt8
-rw-r--r--src/dedicated_room/CMakeLists.txt5
-rw-r--r--src/tests/CMakeLists.txt9
-rw-r--r--src/tests/common/bit_field.cpp6
-rw-r--r--src/video_core/CMakeLists.txt4
-rw-r--r--src/video_core/vulkan_common/vma.cpp6
-rw-r--r--src/yuzu/CMakeLists.txt46
-rw-r--r--src/yuzu/main_window.cpp18
-rw-r--r--src/yuzu_cmd/CMakeLists.txt9
-rw-r--r--src/yuzu_cmd/yuzu.cpp6
-rw-r--r--src/yuzu_room_standalone/CMakeLists.txt5
14 files changed, 117 insertions, 31 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 81c2f81292..5f2d076899 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -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)
diff --git a/src/android/app/src/main/jni/native.cpp b/src/android/app/src/main/jni/native.cpp
index eebc4d5841..1350bccf2e 100644
--- a/src/android/app/src/main/jni/native.cpp
+++ b/src/android/app/src/main/jni/native.cpp
@@ -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>
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index b07778be28..999b380595 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -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()
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 452e5f42e4..ad886b4300 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -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)
diff --git a/src/dedicated_room/CMakeLists.txt b/src/dedicated_room/CMakeLists.txt
index 3e0658a1fb..e74168a5d5 100644
--- a/src/dedicated_room/CMakeLists.txt
+++ b/src/dedicated_room/CMakeLists.txt
@@ -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()
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt
index b6af1fa750..236010ed38 100644
--- a/src/tests/CMakeLists.txt
+++ b/src/tests/CMakeLists.txt
@@ -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()
diff --git a/src/tests/common/bit_field.cpp b/src/tests/common/bit_field.cpp
index 75e990ecd9..2d23ade06e 100644
--- a/src/tests/common/bit_field.cpp
+++ b/src/tests/common/bit_field.cpp
@@ -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>
diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt
index f437663963..94599532b3 100644
--- a/src/video_core/CMakeLists.txt
+++ b/src/video_core/CMakeLists.txt
@@ -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")
diff --git a/src/video_core/vulkan_common/vma.cpp b/src/video_core/vulkan_common/vma.cpp
deleted file mode 100644
index addf107628..0000000000
--- a/src/video_core/vulkan_common/vma.cpp
+++ /dev/null
@@ -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"
diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt
index 79453e4570..d0f2121a65 100644
--- a/src/yuzu/CMakeLists.txt
+++ b/src/yuzu/CMakeLists.txt
@@ -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)
diff --git a/src/yuzu/main_window.cpp b/src/yuzu/main_window.cpp
index b26baf7202..1547c96dd7 100644
--- a/src/yuzu/main_window.cpp
+++ b/src/yuzu/main_window.cpp
@@ -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
diff --git a/src/yuzu_cmd/CMakeLists.txt b/src/yuzu_cmd/CMakeLists.txt
index b26628e074..458eaafc4c 100644
--- a/src/yuzu_cmd/CMakeLists.txt
+++ b/src/yuzu_cmd/CMakeLists.txt
@@ -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()
diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp
index de16ba7815..6ec6f973bb 100644
--- a/src/yuzu_cmd/yuzu.cpp
+++ b/src/yuzu_cmd/yuzu.cpp
@@ -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"
diff --git a/src/yuzu_room_standalone/CMakeLists.txt b/src/yuzu_room_standalone/CMakeLists.txt
index a0e688d4a8..f1db470495 100644
--- a/src/yuzu_room_standalone/CMakeLists.txt
+++ b/src/yuzu_room_standalone/CMakeLists.txt
@@ -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)