CMake: Drop Flatpak workarounds

No longer needed since it is using self-contained.
This commit is contained in:
Stenzek 2025-07-26 16:30:23 +10:00
parent 3943e38d06
commit 9e8b48f682
No known key found for this signature in database
10 changed files with 29 additions and 49 deletions

View File

@ -91,16 +91,10 @@ endif()
# Write binaries to a seperate directory. # Write binaries to a seperate directory.
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
# Installation directories. If INSTALL_SELF_CONTAINED is set, everything goes # Installation directories. Everything goes into one directory.
# into one directory, otherwise CMAKE_INSTALL_PREFIX/bin is used (for Flatpak).
if(ALLOW_INSTALL) if(ALLOW_INSTALL)
if(INSTALL_SELF_CONTAINED) set(CMAKE_INSTALL_BINDIR "${CMAKE_INSTALL_PREFIX}")
set(CMAKE_INSTALL_BINDIR "${CMAKE_INSTALL_PREFIX}") set(CMAKE_INSTALL_LIBDIR "${CMAKE_INSTALL_PREFIX}")
set(CMAKE_INSTALL_LIBDIR "${CMAKE_INSTALL_PREFIX}")
else()
# Let GNUInstallDirs set the destinations.
include(GNUInstallDirs)
endif()
endif() endif()
# Enable large file support on Linux 32-bit platforms. # Enable large file support on Linux 32-bit platforms.

View File

@ -11,7 +11,6 @@ if(LINUX OR BSD)
option(ENABLE_X11 "Support X11 window system" ON) option(ENABLE_X11 "Support X11 window system" ON)
option(ENABLE_WAYLAND "Support Wayland window system" ON) option(ENABLE_WAYLAND "Support Wayland window system" ON)
option(ALLOW_INSTALL "Allow installation to CMAKE_INSTALL_PREFIX" OFF) 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() endif()
if(APPLE) if(APPLE)
option(SKIP_POSTPROCESS_BUNDLE "Disable bundle post-processing, including Qt additions" OFF) option(SKIP_POSTPROCESS_BUNDLE "Disable bundle post-processing, including Qt additions" OFF)

View File

@ -27,15 +27,11 @@ if(BUILD_TESTS)
endif() endif()
if(ALLOW_INSTALL) if(ALLOW_INSTALL)
message(WARNING "Install target is enabled. This will install all DuckStation files into: message(STATUS "Creating self-contained install at ${CMAKE_INSTALL_PREFIX}")
${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.")
if(INSTALL_SELF_CONTAINED) # Stop users being silly.
message(STATUS "Creating self-contained install at ${CMAKE_INSTALL_PREFIX}") if("${CMAKE_INSTALL_PREFIX}" MATCHES "^/usr")
else() message(FATAL_ERROR "You are trying to install DuckStation into a system directory, this is not supported. Please use a different CMAKE_INSTALL_PREFIX.")
message(STATUS "Creating relative install at ${CMAKE_INSTALL_PREFIX}")
message(STATUS " CMAKE_INSTALL_BINDIR: ${CMAKE_INSTALL_BINDIR}")
endif() endif()
endif() endif()

View File

@ -46,7 +46,7 @@ endif()
find_package(Shaderc REQUIRED) find_package(Shaderc REQUIRED)
find_package(spirv_cross_c_shared 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. # We need to add the rpath for shaderc to the executable.
get_target_property(SHADERC_LIBRARY Shaderc::shaderc_shared IMPORTED_LOCATION) get_target_property(SHADERC_LIBRARY Shaderc::shaderc_shared IMPORTED_LOCATION)
get_filename_component(SHADERC_LIBRARY_DIRECTORY ${SHADERC_LIBRARY} DIRECTORY) get_filename_component(SHADERC_LIBRARY_DIRECTORY ${SHADERC_LIBRARY} DIRECTORY)

View File

@ -252,8 +252,7 @@ function(install_imported_dep_library name)
# Only install if it's not a system library. # Only install if it's not a system library.
foreach(path ${CMAKE_PREFIX_PATH}) foreach(path ${CMAKE_PREFIX_PATH})
string(FIND "${LOCATION}" "${path}" out) if (NOT "${LOCATION}" MATCHES "^${path}")
if (NOT "${out}" EQUAL 0)
message(STATUS "Not installing imported system library ${name}") message(STATUS "Not installing imported system library ${name}")
return() return()
endif() endif()

View File

@ -123,9 +123,8 @@ build() {
-DCMAKE_PREFIX_PATH="${_depsdir}" \ -DCMAKE_PREFIX_PATH="${_depsdir}" \
-DCMAKE_BUILD_TYPE=Release \ -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON \ -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON \
-DALLOW_INSTALL=ON \ -DCMAKE_INSTALL_PREFIX="${pkgdir}${_destdir}" \
-DINSTALL_SELF_CONTAINED=ON \ -DALLOW_INSTALL=ON
-DCMAKE_INSTALL_PREFIX="${pkgdir}${_destdir}"
ninja -C build-arch ninja -C build-arch
} }

View File

@ -70,8 +70,8 @@ cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_MODULE_LINKER_FLAGS_INIT="-fuse-ld=lld" \ -DCMAKE_MODULE_LINKER_FLAGS_INIT="-fuse-ld=lld" \
-DCMAKE_SHARED_LINKER_FLAGS_INIT="-fuse-ld=lld" \ -DCMAKE_SHARED_LINKER_FLAGS_INIT="-fuse-ld=lld" \
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON \ -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} ninja -C build %{?_smp_mflags}
%install %install

View File

@ -65,20 +65,17 @@ modules:
# Flatpak build does not appear to default to Release. # Flatpak build does not appear to default to Release.
- "-DCMAKE_BUILD_TYPE=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. # Dependencies path.
- "-DCMAKE_PREFIX_PATH=/app/deps" - "-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. # We're not running tests as part of the flatpak build.
- "-DBUILD_TESTS=OFF" - "-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 # 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. # ARM builds, as some devices are now shipping with 16K kernels.
- "-DHOST_MIN_PAGE_SIZE=4096" - "-DHOST_MIN_PAGE_SIZE=4096"

View File

@ -222,10 +222,9 @@ function(add_core_resources target)
add_resources(${target} ${path} ${CMAKE_SOURCE_DIR}/data/resources/) add_resources(${target} ${path} ${CMAKE_SOURCE_DIR}/data/resources/)
endforeach() endforeach()
if(ALLOW_INSTALL) if(ALLOW_INSTALL)
if(INSTALL_SELF_CONTAINED) install_imported_dep_library(cpuinfo::cpuinfo)
install_imported_dep_library(cpuinfo::cpuinfo) install_imported_dep_library(DiscordRPC::discord-rpc)
install_imported_dep_library(DiscordRPC::discord-rpc) install_imported_dep_library(libzip::zip)
endif()
install(DIRECTORY "$<TARGET_FILE_DIR:${target}>/resources" DESTINATION "${CMAKE_INSTALL_BINDIR}") install(DIRECTORY "$<TARGET_FILE_DIR:${target}>/resources" DESTINATION "${CMAKE_INSTALL_BINDIR}")
endif() endif()

View File

@ -322,17 +322,14 @@ function(add_util_resources target)
set_source_files_properties(${target} PRIVATE ${version_lib} PROPERTIES MACOSX_PACKAGE_LOCATION Frameworks) set_source_files_properties(${target} PRIVATE ${version_lib} PROPERTIES MACOSX_PACKAGE_LOCATION Frameworks)
endforeach() endforeach()
elseif(ALLOW_INSTALL) elseif(ALLOW_INSTALL)
if(INSTALL_SELF_CONTAINED) # Ensure we look for dependency libraries in the installation directory.
# Ensure we look for dependency libraries in the installation directory. set_target_properties(${target} PROPERTIES INSTALL_RPATH "$ORIGIN")
set_target_properties(${target} PROPERTIES INSTALL_RPATH "$ORIGIN")
# Copy dependency libraries to installation directory. # Copy dependency libraries to installation directory.
install_imported_dep_library(SDL3::SDL3) install_imported_dep_library(SDL3::SDL3)
install_imported_dep_library(Shaderc::shaderc_shared) install_imported_dep_library(Shaderc::shaderc_shared)
install_imported_dep_library(spirv-cross-c-shared) install_imported_dep_library(spirv-cross-c-shared)
install_imported_dep_library(SoundTouch::SoundTouchDLL) install_imported_dep_library(SoundTouch::SoundTouchDLL)
install_imported_dep_library(plutosvg::plutosvg) install_imported_dep_library(plutosvg::plutosvg)
install_imported_dep_library(libzip::zip)
endif()
endif() endif()
endfunction() endfunction()