From 63fe09cf6c2b7fb5c6cf3281bdd6adebd5a4f4ea Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Wed, 29 Nov 2023 23:11:36 +0100 Subject: [PATCH] general: limit gamemode to Linux after 5eec980a2d71 FAILED: bin/yuzu ld: error: unable to find library -lgamemode FAILED: bin/yuzu-cmd ld: error: undefined symbol: Common::Linux::StartGamemode() >>> referenced by yuzu.cpp >>> src/yuzu_cmd/CMakeFiles/yuzu-cmd.dir/yuzu.cpp.o:(main) ld: error: undefined symbol: Common::Linux::StopGamemode() >>> referenced by yuzu.cpp >>> src/yuzu_cmd/CMakeFiles/yuzu-cmd.dir/yuzu.cpp.o:(main) --- src/yuzu/CMakeLists.txt | 5 ++++- src/yuzu/main.cpp | 16 ++++++++++------ src/yuzu_cmd/yuzu.cpp | 6 +++--- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt index f3ad2214b5..8895218ea5 100644 --- a/src/yuzu/CMakeLists.txt +++ b/src/yuzu/CMakeLists.txt @@ -386,7 +386,10 @@ if (NOT WIN32) target_include_directories(yuzu PRIVATE ${Qt${QT_MAJOR_VERSION}Gui_PRIVATE_INCLUDE_DIRS}) endif() if (UNIX AND NOT APPLE) - target_link_libraries(yuzu PRIVATE Qt${QT_MAJOR_VERSION}::DBus gamemode) + target_link_libraries(yuzu PRIVATE Qt${QT_MAJOR_VERSION}::DBus) +endif() +if (CMAKE_SYSTEM_NAME STREQUAL "Linux") + target_link_libraries(yuzu PRIVATE gamemode) endif() target_compile_definitions(yuzu PRIVATE diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 10c7882906..83b8169b32 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -17,6 +17,8 @@ #ifdef __unix__ #include #include +#endif +#ifdef __linux__ #include "common/linux/gamemode.h" #endif @@ -320,6 +322,8 @@ GMainWindow::GMainWindow(std::unique_ptr config_, bool has_broken_vulk provider{std::make_unique()} { #ifdef __unix__ SetupSigInterrupts(); +#endif +#ifdef __linux__ SetGamemodeEnabled(Settings::values.enable_gamemode.GetValue()); #endif system->Initialize(); @@ -2122,7 +2126,7 @@ void GMainWindow::OnEmulationStopped() { discord_rpc->Update(); -#ifdef __unix__ +#ifdef __linux__ Common::Linux::StopGamemode(); #endif @@ -3509,7 +3513,7 @@ void GMainWindow::OnStartGame() { discord_rpc->Update(); -#ifdef __unix__ +#ifdef __linux__ Common::Linux::StartGamemode(); #endif } @@ -3533,7 +3537,7 @@ void GMainWindow::OnPauseGame() { UpdateMenuState(); AllowOSSleep(); -#ifdef __unix__ +#ifdef __linux__ Common::Linux::StopGamemode(); #endif } @@ -3817,7 +3821,7 @@ void GMainWindow::OnConfigure() { const auto old_theme = UISettings::values.theme; const bool old_discord_presence = UISettings::values.enable_discord_presence.GetValue(); const auto old_language_index = Settings::values.language_index.GetValue(); -#ifdef __unix__ +#ifdef __linux__ const bool old_gamemode = Settings::values.enable_gamemode.GetValue(); #endif @@ -3881,7 +3885,7 @@ void GMainWindow::OnConfigure() { if (UISettings::values.enable_discord_presence.GetValue() != old_discord_presence) { SetDiscordEnabled(UISettings::values.enable_discord_presence.GetValue()); } -#ifdef __unix__ +#ifdef __linux__ if (Settings::values.enable_gamemode.GetValue() != old_gamemode) { SetGamemodeEnabled(Settings::values.enable_gamemode.GetValue()); } @@ -5194,7 +5198,7 @@ void GMainWindow::SetDiscordEnabled([[maybe_unused]] bool state) { discord_rpc->Update(); } -#ifdef __unix__ +#ifdef __linux__ void GMainWindow::SetGamemodeEnabled(bool state) { if (emulation_running) { Common::Linux::SetGamemodeState(state); diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index a81635fa47..bdde3c4a9b 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp @@ -63,7 +63,7 @@ __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; } #endif -#ifdef __unix__ +#ifdef __linux__ #include "common/linux/gamemode.h" #endif @@ -429,7 +429,7 @@ int main(int argc, char** argv) { exit(0); }); -#ifdef __unix__ +#ifdef __linux__ Common::Linux::StartGamemode(); #endif @@ -444,7 +444,7 @@ int main(int argc, char** argv) { void(system.Pause()); system.ShutdownMainProcess(); -#ifdef __unix__ +#ifdef __linux__ Common::Linux::StopGamemode(); #endif