From b7ae19f59f5dcdec2ddd693ae06a2aaebbb1ccbd Mon Sep 17 00:00:00 2001 From: VZ Date: Fri, 4 Sep 2026 16:40:22 +0200 Subject: [PATCH] Don't show spdlog message and build type when rerunning CMake (#3649) These messages are useful, but only once, showing them again and again and again as CMake reruns in the same build tree is more annoying than anything else. Skip doing this by defining a helper spdlog_message_once() function and use it instead of message(). Co-authored-by: Gabi Melman --- CMakeLists.txt | 4 ++-- cmake/utils.cmake | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f056faa7..df5a9441 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ include(cmake/ide.cmake) spdlog_extract_version() project(spdlog VERSION ${SPDLOG_VERSION} LANGUAGES CXX) -message(STATUS "Build spdlog: ${SPDLOG_VERSION}") +spdlog_message_once(VERSION "Build spdlog: ${SPDLOG_VERSION}") include(GNUInstallDirs) @@ -172,7 +172,7 @@ if(SPDLOG_BUILD_PIC) endif() find_package(Threads REQUIRED) -message(STATUS "Build type: " ${CMAKE_BUILD_TYPE}) +spdlog_message_once(BUILD_TYPE "Build type: ${CMAKE_BUILD_TYPE}") # --------------------------------------------------------------------------------------- # Static/Shared library # --------------------------------------------------------------------------------------- diff --git a/cmake/utils.cmake b/cmake/utils.cmake index 8926657c..6bf36666 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -71,3 +71,14 @@ function(spdlog_enable_thread_sanitizer target_name) target_compile_options(${target_name} PRIVATE -fno-omit-frame-pointer) target_link_libraries(${target_name} PRIVATE -fsanitize=thread) endfunction() + +# Show a status message during the first CMake run only, as repeating it during +# the automatic reconfigurations of a parent project including us is just noise. +# The key identifies the message and has to be unique, the text is shown again +# if it changes, e.g. when the build type is different from the previous run. +function(spdlog_message_once key text) + if(NOT "${text}" STREQUAL "$CACHE{SPDLOG_MESSAGE_${key}}") + set(SPDLOG_MESSAGE_${key} "${text}" CACHE INTERNAL "") + message(STATUS "${text}") + endif() +endfunction()