cmake: Move APPEND_* variables logic to bitcoincore_enable_language

This change is required for the following commit.
This commit is contained in:
Hennadii Stepanov 2025-04-28 16:13:44 +01:00
parent 6d55894a02
commit 8287a7670b
No known key found for this signature in database
GPG key ID: 410108112E7EA81F
3 changed files with 14 additions and 11 deletions

View file

@ -183,16 +183,6 @@ option(BUILD_FOR_FUZZING "Build for fuzzing. Enabling this will disable all othe
option(INSTALL_MAN "Install man pages." ON) 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) set(configure_warnings)
include(CheckLinkerSupportsPIE) include(CheckLinkerSupportsPIE)

View file

@ -15,6 +15,20 @@ macro(bitcoincore_enable_language language)
set(CMAKE_PLATFORM_HAS_INSTALLNAME FALSE) set(CMAKE_PLATFORM_HAS_INSTALLNAME FALSE)
endif() endif()
enable_language(${language}) 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() endif()
unset(_enabled_languages) unset(_enabled_languages)
endmacro() endmacro()

View file

@ -8,7 +8,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(CMAKE_OBJCXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") set(CMAKE_OBJCXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
set(CMAKE_OBJCXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") set(CMAKE_OBJCXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
set(CMAKE_OBJCXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL}") set(CMAKE_OBJCXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL}")
string(APPEND CMAKE_OBJCXX_COMPILE_OBJECT " ${APPEND_CPPFLAGS} ${APPEND_CXXFLAGS}")
endif() endif()
get_target_property(qt_lib_type Qt6::Core TYPE) get_target_property(qt_lib_type Qt6::Core TYPE)