diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ac1456ba1..7131f1a548 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -562,6 +562,8 @@ endif() if (ENABLE_QT) if (YUZU_USE_BUNDLED_QT) AddQt(6.9.3) + + set(YUZU_STATIC_BUILD ON) else() message(STATUS "Using system Qt") if (NOT Qt6_DIR) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c06ed56255..d8d9e10c9f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -16,6 +16,10 @@ endif() set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$:_DEBUG> $<$>:NDEBUG>) +if (YUZU_STATIC_BUILD) + add_compile_definitions(QT_STATICPLUGIN) +endif() + # Set compilation flags if (MSVC AND NOT CXX_CLANG) set(CMAKE_CONFIGURATION_TYPES Debug Release CACHE STRING "" FORCE) @@ -169,25 +173,19 @@ 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() + 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() endif() if (MINGW) add_compile_definitions(MINGW_HAS_SECURE_API) - # Only windows has this requirement, thanks windows + # Only windows has this requirement if (WIN32 AND ARCHITECTURE_x86_64) add_compile_options("-msse4.1") endif()