Add Launcher_ENABLE_GAMEMODE CMake flag

Signed-off-by: cat <cat@plan9.rocks>
This commit is contained in:
cat 2026-04-07 16:47:45 +00:00
parent 194b72f180
commit 072d5419eb
No known key found for this signature in database
GPG key ID: 3D35A815A616B3CB
4 changed files with 11 additions and 4 deletions

View file

@ -303,7 +303,9 @@ endif()
find_package(cmark REQUIRED)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
option(Launcher_ENABLE_GAMEMODE "Enable Feral Gamemode support" ON)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND Launcher_ENABLE_GAMEMODE)
find_package(PkgConfig REQUIRED)
pkg_check_modules(gamemode REQUIRED IMPORTED_TARGET gamemode)
endif()

View file

@ -131,8 +131,10 @@
#ifdef Q_OS_LINUX
#include <dlfcn.h>
#include "LibraryUtils.h"
#ifdef ENABLE_GAMEMODE
#include "gamemode_client.h"
#endif
#endif
#if defined(Q_OS_LINUX)
#include <sys/statvfs.h>
@ -1837,8 +1839,10 @@ void Application::updateCapabilities()
m_capabilities |= SupportsFlame;
#ifdef Q_OS_LINUX
#ifdef ENABLE_GAMEMODE
if (gamemode_query_status() >= 0)
m_capabilities |= SupportsGameMode;
#endif
if (!LibraryUtils::findMangoHud().isEmpty())
m_capabilities |= SupportsMangoHud;

View file

@ -1356,10 +1356,11 @@ else()
target_link_libraries(Launcher_logic LibArchive::LibArchive)
endif()
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND Launcher_ENABLE_GAMEMODE)
target_link_libraries(Launcher_logic
gamemode
)
add_compile_definitions(ENABLE_GAMEMODE)
endif()
target_link_libraries(Launcher_logic

View file

@ -44,7 +44,7 @@
#include "launch/LaunchTask.h"
#include "minecraft/MinecraftInstance.h"
#ifdef Q_OS_LINUX
#if defined(Q_OS_LINUX) && ENABLE_GAMEMODE
#include "gamemode_client.h"
#endif
@ -149,7 +149,7 @@ void LauncherPartLaunch::executeTask()
m_process.start(javaPath, args);
}
#ifdef Q_OS_LINUX
#if defined(Q_OS_LINUX) && ENABLE_GAMEMODE
if (instance->settings()->get("EnableFeralGamemode").toBool() && APPLICATION->capabilities() & Application::SupportsGameMode) {
auto pid = m_process.processId();
if (pid) {