From 4735e8feea27028752d5ec59f9f3c5070e57a752 Mon Sep 17 00:00:00 2001 From: David Helkowski Date: Fri, 23 Jan 2026 01:00:24 +0900 Subject: [PATCH] Add CMake options to suppress C++17 deprecation warnings for RapidJSON on Apple Clang This commit introduces a new compile option in the discord-rpc CMake configuration to suppress C++17 deprecation warnings triggered by RapidJSON when compiled with AppleClang. Additionally, it treats Boost headers as system headers in the Strawberry library to reduce warning noise during builds with strict flags. These changes aim to improve the build experience and maintain cleaner output logs. --- 3rdparty/discord-rpc/CMakeLists.txt | 7 +++++++ CMakeLists.txt | 15 +++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/3rdparty/discord-rpc/CMakeLists.txt b/3rdparty/discord-rpc/CMakeLists.txt index 1877bb61d..cf6c2f0d6 100644 --- a/3rdparty/discord-rpc/CMakeLists.txt +++ b/3rdparty/discord-rpc/CMakeLists.txt @@ -33,6 +33,13 @@ if(APPLE) target_link_libraries(discord-rpc PRIVATE "-framework AppKit") endif() +# RapidJSON (as packaged by Homebrew and others) can trigger C++17 deprecation +# warnings (e.g. std::iterator) when compiled with AppleClang/libc++. +# Keep the suppression narrowly scoped to this 3rdparty target. +if(APPLE AND CMAKE_CXX_COMPILER_ID MATCHES "Clang") + target_compile_options(discord-rpc PRIVATE -Wno-deprecated-declarations) +endif() + if(WIN32) target_link_libraries(discord-rpc PRIVATE psapi advapi32) endif() diff --git a/CMakeLists.txt b/CMakeLists.txt index bc594050e..7275b4469 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1517,6 +1517,21 @@ qt_add_resources(SOURCES data/data.qrc data/icons.qrc) add_library(strawberry_lib STATIC ${SOURCES}) +# Treat Boost headers as system headers to avoid noisy warnings from 3rdparty +# Boost code (e.g. -Wold-style-cast) when building Strawberry with strict flags. +set(_strawberry_boost_system_includes "") +if(TARGET Boost::headers) + get_target_property(_strawberry_boost_system_includes Boost::headers INTERFACE_INCLUDE_DIRECTORIES) +elseif(TARGET Boost::boost) + get_target_property(_strawberry_boost_system_includes Boost::boost INTERFACE_INCLUDE_DIRECTORIES) +elseif(DEFINED Boost_INCLUDE_DIRS) + set(_strawberry_boost_system_includes "${Boost_INCLUDE_DIRS}") +endif() +if(_strawberry_boost_system_includes) + target_include_directories(strawberry_lib SYSTEM PRIVATE ${_strawberry_boost_system_includes}) +endif() +unset(_strawberry_boost_system_includes) + target_sources(strawberry PRIVATE src/main.cpp) if(WIN32)