Browse Source

[cmake] initial support for static Linux builds

A LOT of things are still missing, notably:

- most distros don't package static libs, like at all
- ci target
  * qt6ct :(

Tbh this probably isn't worth it at all for the AppImage, but it's an
option I guess

Signed-off-by: crueter <crueter@eden-emu.dev>
static-linux
crueter 1 month ago
parent
commit
8c1cf35080
No known key found for this signature in database GPG Key ID: 425ACD2D4830EBC6
  1. 21
      CMakeLists.txt
  2. 2
      CMakeModules/StaticQtLibs.cmake
  3. 2
      src/CMakeLists.txt

21
CMakeLists.txt

@ -125,6 +125,7 @@ if (YUZU_STATIC_BUILD)
set(Boost_USE_STATIC_LIBS ON) set(Boost_USE_STATIC_LIBS ON)
set(BUILD_SHARED_LIBS OFF) set(BUILD_SHARED_LIBS OFF)
if (NOT PLATFORM_LINUX)
## find .a libs first (static, usually) ## find .a libs first (static, usually)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
@ -133,6 +134,7 @@ if (YUZU_STATIC_BUILD)
## some libraries use CMAKE_IMPORT_LIBRARY_SUFFIX e.g. Harfbuzz ## ## some libraries use CMAKE_IMPORT_LIBRARY_SUFFIX e.g. Harfbuzz ##
set(CMAKE_IMPORT_LIBRARY_SUFFIX ".a") set(CMAKE_IMPORT_LIBRARY_SUFFIX ".a")
endif()
if (MINGW) if (MINGW)
# simple hook to reject dynamic libs # simple hook to reject dynamic libs
@ -175,6 +177,15 @@ if (YUZU_STATIC_BUILD)
set(SPIRV-Tools_FORCE_BUNDLED ON) set(SPIRV-Tools_FORCE_BUNDLED ON)
set(SPIRV-Headers_FORCE_BUNDLED ON) set(SPIRV-Headers_FORCE_BUNDLED ON)
set(zstd_FORCE_BUNDLED ON) set(zstd_FORCE_BUNDLED ON)
elseif(PLATFORM_LINUX)
# Most distros don't package static libs :(
set(YUZU_USE_CPM ON)
set(CPMUTIL_FORCE_BUNDLED ON)
set(YUZU_USE_BUNDLED_FFMPEG ON)
set(YUZU_USE_BUNDLED_SDL2 ON)
set(YUZU_USE_BUNDLED_OPENSSL ON)
set(YUZU_USE_BUNDLED_SIRIT ON)
endif() endif()
endif() endif()
@ -802,6 +813,16 @@ if (YUZU_TESTS OR DYNARMIC_TESTS)
find_package(Catch2) find_package(Catch2)
endif() endif()
# Qt expects this target
if (YUZU_STATIC_BUILD AND PLATFORM_LINUX)
get_target_property(RDOC_TARGET RenderDoc::API ALIASED_TARGET)
if (RDOC_TARGET)
add_library(RenderDoc::RenderDoc ALIAS ${RDOC_TARGET})
else()
add_library(RenderDoc::RenderDoc ALIAS RenderDoc::API)
endif()
endif()
if (ENABLE_QT) if (ENABLE_QT)
if (YUZU_USE_BUNDLED_QT) if (YUZU_USE_BUNDLED_QT)
download_qt(6.8.3) download_qt(6.8.3)

2
CMakeModules/StaticQtLibs.cmake

@ -16,6 +16,7 @@ function(static_qt_link target)
# NB: yes, we have to put them here twice. I have no idea why # NB: yes, we have to put them here twice. I have no idea why
# libtiff.a # libtiff.a
if (MINGW)
extra_libs(tiff jbig bz2 lzma deflate jpeg tiff) extra_libs(tiff jbig bz2 lzma deflate jpeg tiff)
# libfreetype.a # libfreetype.a
@ -23,6 +24,7 @@ function(static_qt_link target)
# libharfbuzz.a # libharfbuzz.a
extra_libs(harfbuzz graphite2) extra_libs(harfbuzz graphite2)
endif()
# sijfjkfnjkdfjsbjsbsdfhvbdf # sijfjkfnjkdfjsbjsbsdfhvbdf
if (ENABLE_OPENSSL) if (ENABLE_OPENSSL)

2
src/CMakeLists.txt

@ -174,7 +174,7 @@ else()
add_compile_definitions(QT_STATICPLUGIN) add_compile_definitions(QT_STATICPLUGIN)
# macos doesn't even let you make static executables... wtf? # macos doesn't even let you make static executables... wtf?
if (NOT APPLE)
if (NOT APPLE AND NOT PLATFORM_LINUX)
add_compile_options(-static) add_compile_options(-static)
if (YUZU_STATIC_BUILD) if (YUZU_STATIC_BUILD)
# yuzu-cmd requires us to explicitly link libpthread, libgcc, and libstdc++ as static # yuzu-cmd requires us to explicitly link libpthread, libgcc, and libstdc++ as static

Loading…
Cancel
Save