diff --git a/.ci/license-header.sh b/.ci/license-header.sh index f5234584fa..565a4a6093 100755 --- a/.ci/license-header.sh +++ b/.ci/license-header.sh @@ -113,7 +113,7 @@ for file in $FILES; do [ "$excluded" = "true" ] && continue case "$file" in - *.cmake|*.sh|CMakeLists.txt) + *.cmake|*.sh|*CMakeLists.txt) begin="#" ;; *.kt*|*.cpp|*.h) @@ -186,7 +186,7 @@ if [ "$UPDATE" = "true" ]; then for file in $SRC_FILES $OTHER_FILES; do case $(basename -- "$file") in - *.cmake|CMakeLists.txt) + *.cmake|*CMakeLists.txt) begin="#" shell="false" ;; diff --git a/CMakeLists.txt b/CMakeLists.txt index fe73f558c9..147d175989 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +# SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project # SPDX-License-Identifier: GPL-3.0-or-later cmake_minimum_required(VERSION 3.22) @@ -41,14 +41,26 @@ if (PLATFORM_NETBSD) set(ENV{PKG_CONFIG_PATH} "${PKG_CONFIG_PATH}:${CMAKE_SYSROOT}/usr/pkg/lib/ffmpeg7/pkgconfig") endif() +# qt stuff +option(ENABLE_QT "Enable the Qt frontend" ON) +option(ENABLE_QT_TRANSLATION "Enable translations for the Qt frontend" OFF) +option(ENABLE_UPDATE_CHECKER "Enable update checker (for Qt and Android)" OFF) +option(YUZU_USE_QT_MULTIMEDIA "Use QtMultimedia for Camera" OFF) +cmake_dependent_option(YUZU_USE_QT_WEB_ENGINE "Use QtWebEngine for web applet implementation" OFF "NOT YUZU_USE_BUNDLED_QT" OFF) +set(YUZU_QT_MIRROR "" CACHE STRING "What mirror to use for downloading the bundled Qt libraries") +cmake_dependent_option(YUZU_USE_BUNDLED_QT "Download bundled Qt binaries" "${MSVC}" "ENABLE_QT" OFF) + +# non-linux bundled qt are static +if (YUZU_USE_BUNDLED_QT AND (APPLE OR NOT UNIX)) + set(YUZU_STATIC_BUILD ON) +endif() + # TODO: does mingw need any of this anymore # static stuff option(YUZU_STATIC_BUILD "Use static libraries and executables if available" OFF) # TODO: StaticBuild.cmake if (YUZU_STATIC_BUILD) - include(StaticQtLibs) - # lol set(Boost_USE_STATIC_LIBS ON) set(BUILD_SHARED_LIBS OFF) @@ -145,15 +157,6 @@ cmake_dependent_option(ENABLE_SDL2 "Enable the SDL2 frontend" ON "NOT ANDROID" O cmake_dependent_option(YUZU_USE_EXTERNAL_SDL2 "Build SDL2 from external source" OFF "ENABLE_SDL2;NOT MSVC" OFF) cmake_dependent_option(YUZU_USE_BUNDLED_SDL2 "Download bundled SDL2 build" "${MSVC}" "ENABLE_SDL2" OFF) -# qt stuff -option(ENABLE_QT "Enable the Qt frontend" ON) -option(ENABLE_QT_TRANSLATION "Enable translations for the Qt frontend" OFF) -option(ENABLE_UPDATE_CHECKER "Enable update checker (for Qt and Android)" OFF) -option(YUZU_USE_QT_MULTIMEDIA "Use QtMultimedia for Camera" OFF) -cmake_dependent_option(YUZU_USE_QT_WEB_ENGINE "Use QtWebEngine for web applet implementation" OFF "NOT YUZU_USE_BUNDLED_QT" OFF) -set(YUZU_QT_MIRROR "" CACHE STRING "What mirror to use for downloading the bundled Qt libraries") -cmake_dependent_option(YUZU_USE_BUNDLED_QT "Download bundled Qt binaries" "${MSVC}" "ENABLE_QT" OFF) - option(ENABLE_CUBEB "Enables the cubeb audio backend" ON) set(EXT_DEFAULT OFF) @@ -586,6 +589,7 @@ if (ENABLE_QT) else() AddQt(6.9.3) endif() + set(YUZU_STATIC_BUILD ON) else() message(STATUS "Using system Qt") @@ -595,7 +599,7 @@ if (ENABLE_QT) list(APPEND CMAKE_PREFIX_PATH "${Qt6_DIR}") endif() - find_package(Qt6 REQUIRED COMPONENTS Widgets Concurrent) + find_package(Qt6 CONFIG REQUIRED COMPONENTS Widgets Concurrent) if (YUZU_USE_QT_MULTIMEDIA) find_package(Qt6 REQUIRED COMPONENTS Multimedia) diff --git a/CMakeModules/CopyYuzuQt6Deps.cmake b/CMakeModules/CopyYuzuQt6Deps.cmake deleted file mode 100644 index 5ea8f74233..0000000000 --- a/CMakeModules/CopyYuzuQt6Deps.cmake +++ /dev/null @@ -1,66 +0,0 @@ -# SPDX-FileCopyrightText: 2024 kleidis - -function(copy_yuzu_Qt6_deps target_dir) - include(WindowsCopyFiles) - if (MSVC) - set(DLL_DEST "$/") - set(Qt6_DLL_DIR "${Qt6_DIR}/../../../bin") - else() - set(DLL_DEST "${CMAKE_BINARY_DIR}/bin/") - set(Qt6_DLL_DIR "${Qt6_DIR}/../../../lib/") - endif() - set(Qt6_PLATFORMS_DIR "${Qt6_DIR}/../../../plugins/platforms/") - set(Qt6_STYLES_DIR "${Qt6_DIR}/../../../plugins/styles/") - set(Qt6_IMAGEFORMATS_DIR "${Qt6_DIR}/../../../plugins/imageformats/") - set(Qt6_RESOURCES_DIR "${Qt6_DIR}/../../../resources/") - set(PLATFORMS ${DLL_DEST}plugins/platforms/) - set(STYLES ${DLL_DEST}plugins/styles/) - set(IMAGEFORMATS ${DLL_DEST}plugins/imageformats/) - set(RESOURCES ${DLL_DEST}resources/) - if (MSVC) - windows_copy_files(${target_dir} ${Qt6_DLL_DIR} ${DLL_DEST} - Qt6Core$<$:d>.* - Qt6Gui$<$:d>.* - Qt6Widgets$<$:d>.* - Qt6Network$<$:d>.* - ) - if (YUZU_USE_QT_MULTIMEDIA) - windows_copy_files(${target_dir} ${Qt6_DLL_DIR} ${DLL_DEST} - Qt6Multimedia$<$:d>.* - ) - endif() - if (YUZU_USE_QT_WEB_ENGINE) - windows_copy_files(${target_dir} ${Qt6_DLL_DIR} ${DLL_DEST} - Qt6OpenGL$<$:d>.* - Qt6Positioning$<$:d>.* - Qt6PrintSupport$<$:d>.* - Qt6Qml$<$:d>.* - Qt6QmlMeta$<$:d>.* - Qt6QmlModels$<$:d>.* - Qt6QmlWorkerScript$<$:d>.* - Qt6Quick$<$:d>.* - Qt6QuickWidgets$<$:d>.* - Qt6WebChannel$<$:d>.* - Qt6WebEngineCore$<$:d>.* - Qt6WebEngineWidgets$<$:d>.* - QtWebEngineProcess$<$:d>.* - ) - windows_copy_files(${target_dir} ${Qt6_RESOURCES_DIR} ${RESOURCES} - icudtl.dat - qtwebengine_devtools_resources.pak - qtwebengine_resources.pak - qtwebengine_resources_100p.pak - qtwebengine_resources_200p.pak - v8_context_snapshot.bin - ) - endif() - windows_copy_files(yuzu ${Qt6_PLATFORMS_DIR} ${PLATFORMS} qwindows$<$:d>.*) - windows_copy_files(yuzu ${Qt6_STYLES_DIR} ${STYLES} qmodernwindowsstyle$<$:d>.*) - windows_copy_files(yuzu ${Qt6_IMAGEFORMATS_DIR} ${IMAGEFORMATS} - qjpeg$<$:d>.* - qgif$<$:d>.* - ) - else() - # Update for non-MSVC platforms if needed - endif() -endfunction(copy_yuzu_Qt6_deps) diff --git a/CMakeModules/StaticQtLibs.cmake b/CMakeModules/StaticQtLibs.cmake deleted file mode 100644 index be2f060a25..0000000000 --- a/CMakeModules/StaticQtLibs.cmake +++ /dev/null @@ -1,31 +0,0 @@ -# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project -# SPDX-License-Identifier: GPL-3.0-or-later - -## When linking to a static Qt build on MinGW, certain additional libraries -## must be statically linked to as well. - -function(static_qt_link target) - macro(extra_libs) - foreach(lib ${ARGN}) - find_library(${lib}_LIBRARY ${lib} REQUIRED) - target_link_libraries(${target} 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) - - # sijfjkfnjkdfjsbjsbsdfhvbdf - if (ENABLE_OPENSSL) - target_link_libraries(${target} PRIVATE OpenSSL::SSL OpenSSL::Crypto) - endif() -endfunction() diff --git a/externals/cmake-modules/DetectPlatform.cmake b/externals/cmake-modules/DetectPlatform.cmake index 0ad695066b..6475884f1f 100644 --- a/externals/cmake-modules/DetectPlatform.cmake +++ b/externals/cmake-modules/DetectPlatform.cmake @@ -149,4 +149,4 @@ endif() if (PLATFORM_FREEBSD OR PLATFORM_DRAGONFLYBSD) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${CMAKE_SYSROOT}/usr/local/lib") -endif() \ No newline at end of file +endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d8d9e10c9f..6cafe4882a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +# SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project # SPDX-License-Identifier: GPL-3.0-or-later # SPDX-FileCopyrightText: 2018 yuzu Emulator Project # SPDX-License-Identifier: GPL-2.0-or-later @@ -175,11 +175,10 @@ else() if (YUZU_STATIC_BUILD AND NOT APPLE) add_compile_options(-static) - if (YUZU_STATIC_BUILD) - # yuzu-cmd requires us to explicitly link libpthread, libgcc, and libstdc++ as static - add_link_options(-static -lpthread) - add_link_options(-static-libgcc -static-libstdc++) - endif() + + # yuzu-cmd requires us to explicitly link libpthread, libgcc, and libstdc++ as static + add_link_options(-Wl,-Bstatic -static -lpthread) + add_link_options(-static-libgcc -static-libstdc++) endif() if (MINGW) diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt index 87d4652b07..35c6f80e40 100644 --- a/src/yuzu/CMakeLists.txt +++ b/src/yuzu/CMakeLists.txt @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +# SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project # SPDX-License-Identifier: GPL-3.0-or-later set(CMAKE_AUTOMOC ON) @@ -426,12 +426,6 @@ if (WIN32 AND NOT YUZU_USE_BUNDLED_QT AND QT_VERSION VERSION_GREATER_EQUAL 6) add_custom_command(TARGET yuzu POST_BUILD COMMAND ${WINDEPLOYQT_EXECUTABLE} "${YUZU_EXE_DIR}/eden.exe" --dir "${YUZU_EXE_DIR}" --libdir "${YUZU_EXE_DIR}" --plugindir "${YUZU_EXE_DIR}/plugins" --no-compiler-runtime --no-opengl-sw --no-system-d3d-compiler --no-translations --verbose 0) endif() -# TODO(crueter): this can be done with system qt in a better way -if (YUZU_USE_BUNDLED_QT) - include(CopyYuzuQt6Deps) - copy_yuzu_Qt6_deps(yuzu) -endif() - if (ENABLE_SDL2) target_link_libraries(yuzu PRIVATE SDL2::SDL2) target_compile_definitions(yuzu PRIVATE HAVE_SDL2) @@ -443,7 +437,6 @@ endif() if (YUZU_ROOM) target_link_libraries(yuzu PRIVATE yuzu-room) -target_link_libraries(yuzu PRIVATE Qt6::Widgets) endif() if (NOT MSVC AND (APPLE OR NOT YUZU_STATIC_BUILD)) @@ -455,8 +448,9 @@ if (NOT MSVC AND (APPLE OR NOT YUZU_STATIC_BUILD)) -Wno-missing-field-initializers) endif() -if (YUZU_STATIC_BUILD AND MINGW) - static_qt_link(yuzu) +# Remember that the linker is incredibly stupid. +if (YUZU_STATIC_BUILD AND MINGW AND ARCHITECTURE_x86_64 AND ENABLE_OPENSSL) + target_link_libraries(yuzu PRIVATE OpenSSL::SSL OpenSSL::Crypto) endif() create_target_directory_groups(yuzu)