From 30beb5d97271526248c37affbedf88e1c671ce53 Mon Sep 17 00:00:00 2001 From: Chase Harkcom Date: Wed, 18 Feb 2026 00:44:22 -0700 Subject: [PATCH] Create a CMake option for toggling RetroAchievements --- CMakeLists.txt | 2 ++ externals/CMakeLists.txt | 4 +++- src/CMakeLists.txt | 6 +++++- src/core/CMakeLists.txt | 6 +++++- src/core/core.cpp | 8 +++++++- src/core/core.h | 2 ++ 6 files changed, 24 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 54eb90e90..7712727a2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -136,6 +136,8 @@ option(ENABLE_SSE42 "Enable SSE4.2 optimizations on x86_64" ON) option(ENABLE_DEVELOPER_OPTIONS "Enable functionality targeted at emulator developers" OFF) +option(ENABLE_RETROACHIEVEMENTS "Build with RetroAchievements support" OFF) + # Compile options CMAKE_DEPENDENT_OPTION(COMPILE_WITH_DWARF "Add DWARF debugging information" ${IS_DEBUG_BUILD} "MINGW" OFF) option(ENABLE_LTO "Enable link time optimization" ${DEFAULT_ENABLE_LTO}) diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index 02372cc7b..e959ba238 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -516,4 +516,6 @@ else() endif() # rcheevos -add_subdirectory(rcheevos) +if (ENABLE_RETROACHIEVEMENTS) + add_subdirectory(rcheevos) +endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2a7c9d689..892495497 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -182,13 +182,17 @@ if(ENABLE_DEVELOPER_OPTIONS) add_compile_definitions(ENABLE_DEVELOPER_OPTIONS) endif() +if (ENABLE_RETROACHIEVEMENTS) + add_compile_definitions(ENABLE_RETROACHIEVEMENTS) + add_subdirectory(rcheevos_integration) +endif() + add_subdirectory(common) add_subdirectory(core) add_subdirectory(video_core) add_subdirectory(audio_core) add_subdirectory(network) add_subdirectory(input_common) -add_subdirectory(rcheevos_integration) if (ENABLE_TESTS) add_subdirectory(tests) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index ef785bc8e..a0d4d77e5 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -500,10 +500,14 @@ add_library(citra_core STATIC create_target_directory_groups(citra_core) -target_link_libraries(citra_core PUBLIC citra_common PRIVATE audio_core network video_core rcheevos_integration) +target_link_libraries(citra_core PUBLIC citra_common PRIVATE audio_core network video_core) target_link_libraries(citra_core PRIVATE Boost::boost Boost::serialization Boost::iostreams httplib) target_link_libraries(citra_core PUBLIC dds-ktx PRIVATE cryptopp fmt lodepng open_source_archives) +if (ENABLE_RETROACHIEVEMENTS) + target_link_libraries(citra_core PUBLIC rcheevos_integration) +endif() + if (ENABLE_WEB_SERVICE) target_link_libraries(citra_core PRIVATE web_service) endif() diff --git a/src/core/core.cpp b/src/core/core.cpp index f1a4c2724..64863d6ed 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -73,7 +73,11 @@ Core::Timing& Global() { return System::GetInstance().CoreTiming(); } -System::System() : movie{*this}, cheat_engine{*this}, rcheevos_client{*this} {} +System::System() : movie{*this}, cheat_engine{*this} +#ifdef ENABLE_RETROACHIEVEMENTS + , rcheevos_client{*this} +#endif +{} System::~System() = default; @@ -591,8 +595,10 @@ System::ResultStatus System::Init(Frontend::EmuWindow& emu_window, plg_ldr->SetAllowGameChangeState(Settings::values.allow_plugin_loader.GetValue()); } +#ifdef ENABLE_RETROACHIEVEMENTS rcheevos_client.InitializeClient(); rcheevos_client.LoginRetroachievementsUser("", ""); +#endif LOG_DEBUG(Core, "Initialized OK"); diff --git a/src/core/core.h b/src/core/core.h index 6325fc103..083256a2e 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -440,8 +440,10 @@ private: /// Cheats manager Cheats::CheatEngine cheat_engine; +#ifdef ENABLE_RETROACHIEVEMENTS /// RetroAchievements RcheevosClient rcheevos_client; +#endif /// Video dumper backend std::shared_ptr video_dumper;