From 8287a7670becda8078ef669c3e309a40bb4bf630 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Mon, 28 Apr 2025 16:13:44 +0100 Subject: [PATCH] cmake: Move `APPEND_*` variables logic to `bitcoincore_enable_language` This change is required for the following commit. --- CMakeLists.txt | 10 ---------- cmake/module/EnableLanguage.cmake | 14 ++++++++++++++ src/qt/CMakeLists.txt | 1 - 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3cd1895bd00..f43ff702fd1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -183,16 +183,6 @@ option(BUILD_FOR_FUZZING "Build for fuzzing. Enabling this will disable all othe option(INSTALL_MAN "Install man pages." ON) -set(APPEND_CPPFLAGS "" CACHE STRING "Preprocessor flags that are appended to the command line after all other flags added by the build system. This variable is intended for debugging and special builds.") -set(APPEND_CFLAGS "" CACHE STRING "C compiler flags that are appended to the command line after all other flags added by the build system. This variable is intended for debugging and special builds.") -set(APPEND_CXXFLAGS "" CACHE STRING "(Objective) C++ compiler flags that are appended to the command line after all other flags added by the build system. This variable is intended for debugging and special builds.") -set(APPEND_LDFLAGS "" CACHE STRING "Linker flags that are appended to the command line after all other flags added by the build system. This variable is intended for debugging and special builds.") -# Appending to this low-level rule variables is the only way to -# guarantee that the flags appear at the end of the command line. -string(APPEND CMAKE_CXX_COMPILE_OBJECT " ${APPEND_CPPFLAGS} ${APPEND_CXXFLAGS}") -string(APPEND CMAKE_CXX_CREATE_SHARED_LIBRARY " ${APPEND_LDFLAGS}") -string(APPEND CMAKE_CXX_LINK_EXECUTABLE " ${APPEND_LDFLAGS}") - set(configure_warnings) include(CheckLinkerSupportsPIE) diff --git a/cmake/module/EnableLanguage.cmake b/cmake/module/EnableLanguage.cmake index a68510fc0b1..6ba52d6492f 100644 --- a/cmake/module/EnableLanguage.cmake +++ b/cmake/module/EnableLanguage.cmake @@ -15,6 +15,20 @@ macro(bitcoincore_enable_language language) set(CMAKE_PLATFORM_HAS_INSTALLNAME FALSE) endif() enable_language(${language}) + + set(_description "flags that are appended to the command line after all other flags added by the build system. This variable is intended for debugging and special builds.") + set(APPEND_CPPFLAGS "" CACHE STRING "Preprocessor ${_description}") + set(APPEND_LDFLAGS "" CACHE STRING "Linker ${_description}") + if("${language}" MATCHES "^C$") + set(APPEND_CFLAGS "" CACHE STRING "C compiler ${_description}") + endif() + if("${language}" MATCHES "^(CXX|OBJCXX)$") + set(APPEND_CXXFLAGS "" CACHE STRING "(Objective) C++ compiler ${_description}") + string(APPEND CMAKE_${language}_COMPILE_OBJECT " ${APPEND_CPPFLAGS} ${APPEND_CXXFLAGS}") + string(APPEND CMAKE_${language}_CREATE_SHARED_LIBRARY " ${APPEND_LDFLAGS}") + string(APPEND CMAKE_${language}_LINK_EXECUTABLE " ${APPEND_LDFLAGS}") + endif() + unset(_description) endif() unset(_enabled_languages) endmacro() diff --git a/src/qt/CMakeLists.txt b/src/qt/CMakeLists.txt index 48bcf342bd2..6407bc672f9 100644 --- a/src/qt/CMakeLists.txt +++ b/src/qt/CMakeLists.txt @@ -8,7 +8,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") set(CMAKE_OBJCXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") set(CMAKE_OBJCXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") set(CMAKE_OBJCXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL}") - string(APPEND CMAKE_OBJCXX_COMPILE_OBJECT " ${APPEND_CPPFLAGS} ${APPEND_CXXFLAGS}") endif() get_target_property(qt_lib_type Qt6::Core TYPE)