From b1c9c13ca36e80f5109c9c5b30dfed5820a5daf9 Mon Sep 17 00:00:00 2001 From: Dentomologist Date: Sun, 4 Jan 2026 16:00:19 -0800 Subject: [PATCH 1/4] VolumeFileBlobReader: Define default destructor in source file Fix an error generated by Clang from the destructor of `std::unique_ptr m_file_info` when setting the standard version to c++23: `invalid application of 'sizeof' to an incomplete type 'DiscIO::FileInfo'` --- Source/Core/DiscIO/VolumeFileBlobReader.cpp | 5 +++++ Source/Core/DiscIO/VolumeFileBlobReader.h | 1 + 2 files changed, 6 insertions(+) diff --git a/Source/Core/DiscIO/VolumeFileBlobReader.cpp b/Source/Core/DiscIO/VolumeFileBlobReader.cpp index 7cbc06e589..92eb9b4ae2 100644 --- a/Source/Core/DiscIO/VolumeFileBlobReader.cpp +++ b/Source/Core/DiscIO/VolumeFileBlobReader.cpp @@ -33,6 +33,11 @@ VolumeFileBlobReader::VolumeFileBlobReader(const Volume& volume, const Partition { } +// This is defined here instead of the header so that the definition of FileInfo is visible when +// m_file_info is destroyed, preventing a compile error caused by calling unique_ptr's destructor +// with an incomplete type. +VolumeFileBlobReader::~VolumeFileBlobReader() = default; + std::unique_ptr VolumeFileBlobReader::CopyReader() const { ASSERT_MSG(DISCIO, false, "Unimplemented"); diff --git a/Source/Core/DiscIO/VolumeFileBlobReader.h b/Source/Core/DiscIO/VolumeFileBlobReader.h index 58d349a0d4..49fe4cd200 100644 --- a/Source/Core/DiscIO/VolumeFileBlobReader.h +++ b/Source/Core/DiscIO/VolumeFileBlobReader.h @@ -20,6 +20,7 @@ class VolumeFileBlobReader final : public BlobReader public: static std::unique_ptr Create(const Volume& volume, const Partition& partition, std::string_view file_path); + ~VolumeFileBlobReader(); BlobType GetBlobType() const override { return BlobType::PLAIN; } std::unique_ptr CopyReader() const override; From af585e0bd03f2d083fa1ee1620ebbfca9617f031 Mon Sep 17 00:00:00 2001 From: Dentomologist Date: Sun, 4 Jan 2026 15:47:20 -0800 Subject: [PATCH 2/4] Metal: Move ObjectCache constructor and destructor Move the constructor and destructor after the definition of the class `Internal`. This fixes an error generated by Clang from the destructor of `std::unique_ptr` when setting the standard version to c++23: `invalid application of 'sizeof' to an incomplete type 'Metal::ObjectCache::Internal'`. --- .../VideoBackends/Metal/MTLObjectCache.mm | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Source/Core/VideoBackends/Metal/MTLObjectCache.mm b/Source/Core/VideoBackends/Metal/MTLObjectCache.mm index c4ecfc0713..7dce7a0f34 100644 --- a/Source/Core/VideoBackends/Metal/MTLObjectCache.mm +++ b/Source/Core/VideoBackends/Metal/MTLObjectCache.mm @@ -27,16 +27,6 @@ std::unique_ptr Metal::g_object_cache; static void SetupDepthStencil( MRCOwned> (&dss)[Metal::DepthStencilSelector::N_VALUES]); -Metal::ObjectCache::ObjectCache() -{ - m_internal = std::make_unique(); - SetupDepthStencil(m_dss); -} - -Metal::ObjectCache::~ObjectCache() -{ -} - void Metal::ObjectCache::Initialize(MRCOwned> device) { g_device = std::move(device); @@ -554,6 +544,17 @@ public: } }; +Metal::ObjectCache::ObjectCache() +{ + m_internal = std::make_unique(); + SetupDepthStencil(m_dss); +} + +// This is defined here instead of the header so that the definition of Internal is visible when +// m_internal is destroyed, preventing a compile error caused by calling unique_ptr's destructor +// with an incomplete type. +Metal::ObjectCache::~ObjectCache() = default; + std::unique_ptr Metal::ObjectCache::CreatePipeline(const AbstractPipelineConfig& config) { From ba32260c29895861317f75336b54a6773ec50f5c Mon Sep 17 00:00:00 2001 From: Dentomologist Date: Sun, 4 Jan 2026 19:56:52 -0800 Subject: [PATCH 3/4] Set CMake version range to 3.20...4.2.1 CMake support for c++23 was added in 3.20. Remove statements explicitly setting the following policies to NEW. These policies were introduced in or before 3.20, and now that 3.20 is the minimum version they will automatically have the NEW behavior. Policy: Introduced in CMP0079: 3.13 CMP0084: 3.14 CMP0091: 3.15 CMP0092: 3.15 CMP0099: 3.17 CMP0117: 3.20 Disable scanning c++ source files for module imports (introduced as CMP0155 in 3.28) since we don't use modules and that policy triggers build errors with Clang if the clang-scan-deps tool isn't installed. --- CMakeLists.txt | 27 +++++++-------------------- Source/Core/DolphinQt/CMakeLists.txt | 5 ----- 2 files changed, 7 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e63c62c66..8f432b77bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,23 +1,10 @@ ######################################## # General setup # -cmake_minimum_required(VERSION 3.13) +cmake_minimum_required(VERSION 3.20...4.2.1) -cmake_policy(SET CMP0079 NEW) # let target_link_libraries() link to a target defined in a different directory cmake_policy(SET CMP0080 OLD) # allow using BundleUtilities at configure time -if (POLICY CMP0099) - cmake_policy(SET CMP0099 NEW) # Propagate INTERFACE_LINK_OPTIONS from private dependencies, used by MacOS framework builds of SDL -endif() - -# Weird chicken-and-egg problem: We can't check the compiler before the project() call, but we have to set the policies before it. -# So we do this in two steps: Set the policies if they exist, then error out afterwards if we end up being MSVC and they don't exist. -if (POLICY CMP0117) - cmake_policy(SET CMP0091 NEW) # MSVC runtime library flags are selected by an abstraction. - cmake_policy(SET CMP0092 NEW) # MSVC warning flags are not in CMAKE_{C,CXX}_FLAGS by default. - cmake_policy(SET CMP0117 NEW) # MSVC RTTI flag will not be added by default. -endif() - if (POLICY CMP0141) cmake_policy(SET CMP0141 NEW) # MSVC debug information format flags are selected by an abstraction. endif() @@ -28,6 +15,12 @@ set(CMAKE_OSX_DEPLOYMENT_TARGET "11.0.0" CACHE STRING "") set(CMAKE_USER_MAKE_RULES_OVERRIDE "${CMAKE_CURRENT_SOURCE_DIR}/CMake/FlagsOverride.cmake") +# CMake 3.28 and later scan c++ source files for module imports by default. Since we don't use +# modules scanning is pointless, so disable it. This also prevents Clang from generating an error +# if the clang-scan-deps tool isn't installed: +# "CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS-NOTFOUND: not found". +set(CMAKE_CXX_SCAN_FOR_MODULES OFF) + project(dolphin-emu) if (CMAKE_VERSION VERSION_LESS "3.25" AND CMAKE_SYSTEM_NAME MATCHES "Linux") @@ -35,12 +28,6 @@ if (CMAKE_VERSION VERSION_LESS "3.25" AND CMAKE_SYSTEM_NAME MATCHES "Linux") endif() if (MSVC) - if (POLICY CMP0117) - # cmake is a weird language. You can't do if(not POLICY) - else() - message(FATAL_ERROR "Please update to CMake 3.20 or higher.") - endif() - set(CMAKE_C_STANDARD 99) set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD_REQUIRED ON) diff --git a/Source/Core/DolphinQt/CMakeLists.txt b/Source/Core/DolphinQt/CMakeLists.txt index cd49f7f108..1960e944bd 100644 --- a/Source/Core/DolphinQt/CMakeLists.txt +++ b/Source/Core/DolphinQt/CMakeLists.txt @@ -1,8 +1,3 @@ -if(POLICY CMP0084) - # Disable trying to search for Qt3/4 if what we actually want is not found - cmake_policy(SET CMP0084 NEW) -endif() - if (MSVC) if(_M_ARM_64) list(APPEND CMAKE_PREFIX_PATH "${CMAKE_SOURCE_DIR}/Externals/Qt/Qt6.5.1/ARM64") From cc2db2ce15aad72729e8283066b71ba5c2eb0194 Mon Sep 17 00:00:00 2001 From: Dentomologist Date: Sat, 3 Jan 2026 13:03:27 -0800 Subject: [PATCH 4/4] Set standard to c++23 for non-MSVC compilers --- Source/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 8d74b60470..c98a9b3188 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -16,7 +16,7 @@ if(CMAKE_SYSTEM_NAME MATCHES "Windows") endif() if (NOT MSVC) - set(CMAKE_CXX_STANDARD 20) + set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) endif()