From 83d521f3d8fbd7430d8d30c035b55df9a28d9825 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sat, 26 Jul 2025 16:30:23 +1000 Subject: [PATCH] CMake: Drop Flatpak workarounds No longer needed since it is using self-contained. --- CMakeLists.txt | 12 +++--------- CMakeModules/DuckStationBuildOptions.cmake | 1 - CMakeModules/DuckStationBuildSummary.cmake | 12 ++++-------- CMakeModules/DuckStationDependencies.cmake | 2 +- CMakeModules/DuckStationUtils.cmake | 3 +-- scripts/packaging/arch/PKGBUILD | 5 ++--- scripts/packaging/fedora/duckstation.spec | 4 ++-- .../flatpak/org.duckstation.DuckStation.yaml | 13 +++++-------- src/core/CMakeLists.txt | 7 +++---- src/util/CMakeLists.txt | 19 ++++++++----------- 10 files changed, 29 insertions(+), 49 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e835c90a2..545d12001 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,16 +91,10 @@ endif() # Write binaries to a seperate directory. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin") -# Installation directories. If INSTALL_SELF_CONTAINED is set, everything goes -# into one directory, otherwise CMAKE_INSTALL_PREFIX/bin is used (for Flatpak). +# Installation directories. Everything goes into one directory. if(ALLOW_INSTALL) - if(INSTALL_SELF_CONTAINED) - set(CMAKE_INSTALL_BINDIR "${CMAKE_INSTALL_PREFIX}") - set(CMAKE_INSTALL_LIBDIR "${CMAKE_INSTALL_PREFIX}") - else() - # Let GNUInstallDirs set the destinations. - include(GNUInstallDirs) - endif() + set(CMAKE_INSTALL_BINDIR "${CMAKE_INSTALL_PREFIX}") + set(CMAKE_INSTALL_LIBDIR "${CMAKE_INSTALL_PREFIX}") endif() # Enable large file support on Linux 32-bit platforms. diff --git a/CMakeModules/DuckStationBuildOptions.cmake b/CMakeModules/DuckStationBuildOptions.cmake index c1b7478c6..f9dcedd60 100644 --- a/CMakeModules/DuckStationBuildOptions.cmake +++ b/CMakeModules/DuckStationBuildOptions.cmake @@ -11,7 +11,6 @@ if(LINUX OR BSD) option(ENABLE_X11 "Support X11 window system" ON) option(ENABLE_WAYLAND "Support Wayland window system" ON) option(ALLOW_INSTALL "Allow installation to CMAKE_INSTALL_PREFIX" OFF) - option(INSTALL_SELF_CONTAINED "Make self-contained install, i.e. everything in one directory" ON) endif() if(APPLE) option(SKIP_POSTPROCESS_BUNDLE "Disable bundle post-processing, including Qt additions" OFF) diff --git a/CMakeModules/DuckStationBuildSummary.cmake b/CMakeModules/DuckStationBuildSummary.cmake index 6874b919a..33036a647 100644 --- a/CMakeModules/DuckStationBuildSummary.cmake +++ b/CMakeModules/DuckStationBuildSummary.cmake @@ -27,15 +27,11 @@ if(BUILD_TESTS) endif() if(ALLOW_INSTALL) - message(WARNING "Install target is enabled. This will install all DuckStation files into: - ${CMAKE_INSTALL_PREFIX} -It does **not** use the LSB subdirectories of bin, share, etc, so you should disable this option if it is set to /usr or /usr/local.") + message(STATUS "Creating self-contained install at ${CMAKE_INSTALL_PREFIX}") - if(INSTALL_SELF_CONTAINED) - message(STATUS "Creating self-contained install at ${CMAKE_INSTALL_PREFIX}") - else() - message(STATUS "Creating relative install at ${CMAKE_INSTALL_PREFIX}") - message(STATUS " CMAKE_INSTALL_BINDIR: ${CMAKE_INSTALL_BINDIR}") + # Stop users being silly. + if("${CMAKE_INSTALL_PREFIX}" MATCHES "^/usr") + message(FATAL_ERROR "You are trying to install DuckStation into a system directory, this is not supported. Please use a different CMAKE_INSTALL_PREFIX.") endif() endif() diff --git a/CMakeModules/DuckStationDependencies.cmake b/CMakeModules/DuckStationDependencies.cmake index c9b2f57f5..4d771913d 100644 --- a/CMakeModules/DuckStationDependencies.cmake +++ b/CMakeModules/DuckStationDependencies.cmake @@ -46,7 +46,7 @@ endif() find_package(Shaderc REQUIRED) find_package(spirv_cross_c_shared REQUIRED) -if(LINUX AND NOT (ALLOW_INSTALL AND INSTALL_SELF_CONTAINED)) +if(LINUX AND NOT ALLOW_INSTALL) # We need to add the rpath for shaderc to the executable. get_target_property(SHADERC_LIBRARY Shaderc::shaderc_shared IMPORTED_LOCATION) get_filename_component(SHADERC_LIBRARY_DIRECTORY ${SHADERC_LIBRARY} DIRECTORY) diff --git a/CMakeModules/DuckStationUtils.cmake b/CMakeModules/DuckStationUtils.cmake index f6357b93c..d83992b28 100644 --- a/CMakeModules/DuckStationUtils.cmake +++ b/CMakeModules/DuckStationUtils.cmake @@ -252,8 +252,7 @@ function(install_imported_dep_library name) # Only install if it's not a system library. foreach(path ${CMAKE_PREFIX_PATH}) - string(FIND "${LOCATION}" "${path}" out) - if (NOT "${out}" EQUAL 0) + if (NOT "${LOCATION}" MATCHES "^${path}") message(STATUS "Not installing imported system library ${name}") return() endif() diff --git a/scripts/packaging/arch/PKGBUILD b/scripts/packaging/arch/PKGBUILD index a11510605..6dc09cb72 100644 --- a/scripts/packaging/arch/PKGBUILD +++ b/scripts/packaging/arch/PKGBUILD @@ -123,9 +123,8 @@ build() { -DCMAKE_PREFIX_PATH="${_depsdir}" \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON \ - -DALLOW_INSTALL=ON \ - -DINSTALL_SELF_CONTAINED=ON \ - -DCMAKE_INSTALL_PREFIX="${pkgdir}${_destdir}" + -DCMAKE_INSTALL_PREFIX="${pkgdir}${_destdir}" \ + -DALLOW_INSTALL=ON ninja -C build-arch } diff --git a/scripts/packaging/fedora/duckstation.spec b/scripts/packaging/fedora/duckstation.spec index dd1a35ccd..2902985e2 100644 --- a/scripts/packaging/fedora/duckstation.spec +++ b/scripts/packaging/fedora/duckstation.spec @@ -70,8 +70,8 @@ cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_MODULE_LINKER_FLAGS_INIT="-fuse-ld=lld" \ -DCMAKE_SHARED_LINKER_FLAGS_INIT="-fuse-ld=lld" \ -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON \ - -DALLOW_INSTALL=ON -DINSTALL_SELF_CONTAINED=ON \ - -DCMAKE_INSTALL_PREFIX=%{buildroot}/opt/%{name} + -DCMAKE_INSTALL_PREFIX=%{buildroot}/opt/%{name} \ + -DALLOW_INSTALL=ON ninja -C build %{?_smp_mflags} %install diff --git a/scripts/packaging/flatpak/org.duckstation.DuckStation.yaml b/scripts/packaging/flatpak/org.duckstation.DuckStation.yaml index 9e4835734..cd8bc79ef 100644 --- a/scripts/packaging/flatpak/org.duckstation.DuckStation.yaml +++ b/scripts/packaging/flatpak/org.duckstation.DuckStation.yaml @@ -65,20 +65,17 @@ modules: # Flatpak build does not appear to default to Release. - "-DCMAKE_BUILD_TYPE=Release" - # Self-contained install, need to change the directory. - # Typical flatpak garbage makes it a pain to change the path from /app/bin... - - "-DCMAKE_INSTALL_PREFIX=/app/bin" - # Dependencies path. - "-DCMAKE_PREFIX_PATH=/app/deps" + # Self-contained install, need to change the directory. + # Typical flatpak garbage makes it a pain to change the path from /app/bin... + - "-DCMAKE_INSTALL_PREFIX=/app/bin" + - "-DALLOW_INSTALL=ON" + # We're not running tests as part of the flatpak build. - "-DBUILD_TESTS=OFF" - # Install to /app. - - "-DALLOW_INSTALL=ON" - - "-DINSTALL_SELF_CONTAINED=ON" - # Set the page range to 4K-16K. This has no effect on X86, but is required for # ARM builds, as some devices are now shipping with 16K kernels. - "-DHOST_MIN_PAGE_SIZE=4096" diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 86a75026b..1ab2717f0 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -222,10 +222,9 @@ function(add_core_resources target) add_resources(${target} ${path} ${CMAKE_SOURCE_DIR}/data/resources/) endforeach() if(ALLOW_INSTALL) - if(INSTALL_SELF_CONTAINED) - install_imported_dep_library(cpuinfo::cpuinfo) - install_imported_dep_library(DiscordRPC::discord-rpc) - endif() + install_imported_dep_library(cpuinfo::cpuinfo) + install_imported_dep_library(DiscordRPC::discord-rpc) + install_imported_dep_library(libzip::zip) install(DIRECTORY "$/resources" DESTINATION "${CMAKE_INSTALL_BINDIR}") endif() diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index cb5043cf8..78ddb7abf 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -322,17 +322,14 @@ function(add_util_resources target) set_source_files_properties(${target} PRIVATE ${version_lib} PROPERTIES MACOSX_PACKAGE_LOCATION Frameworks) endforeach() elseif(ALLOW_INSTALL) - if(INSTALL_SELF_CONTAINED) - # Ensure we look for dependency libraries in the installation directory. - set_target_properties(${target} PROPERTIES INSTALL_RPATH "$ORIGIN") + # Ensure we look for dependency libraries in the installation directory. + set_target_properties(${target} PROPERTIES INSTALL_RPATH "$ORIGIN") - # Copy dependency libraries to installation directory. - install_imported_dep_library(SDL3::SDL3) - install_imported_dep_library(Shaderc::shaderc_shared) - install_imported_dep_library(spirv-cross-c-shared) - install_imported_dep_library(SoundTouch::SoundTouchDLL) - install_imported_dep_library(plutosvg::plutosvg) - install_imported_dep_library(libzip::zip) - endif() + # Copy dependency libraries to installation directory. + install_imported_dep_library(SDL3::SDL3) + install_imported_dep_library(Shaderc::shaderc_shared) + install_imported_dep_library(spirv-cross-c-shared) + install_imported_dep_library(SoundTouch::SoundTouchDLL) + install_imported_dep_library(plutosvg::plutosvg) endif() endfunction()