forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIXUP] cmake: Rework compile/link flags summary
- Loading branch information
Showing
4 changed files
with
87 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# Copyright (c) 2024-present The Bitcoin Core developers | ||
# Distributed under the MIT software license, see the accompanying | ||
# file COPYING or https://opensource.org/license/mit/. | ||
|
||
include_guard(GLOBAL) | ||
|
||
function(normalize_preprocessor_definitions definitions) | ||
if(MSVC) | ||
set(flag "/D") | ||
else() | ||
set(flag "-D") | ||
endif() | ||
separate_arguments(${definitions}) | ||
set(result "") | ||
foreach(d IN LISTS ${definitions}) | ||
if(NOT d) | ||
continue() | ||
endif() | ||
if(NOT d MATCHES "${flag}.*") | ||
string(PREPEND d "${flag}") | ||
endif() | ||
string(STRIP "${result} ${d}" result) | ||
endforeach() | ||
set(${definitions} "${result}" PARENT_SCOPE) | ||
endfunction() | ||
|
||
function(flags_summary) | ||
include(GetTargetInterface) | ||
get_target_interface(definitions core_interface COMPILE_DEFINITIONS) | ||
include(ProcessConfigurations) | ||
separate_by_configs(definitions) | ||
|
||
if(CMAKE_CROSSCOMPILING) | ||
set(cross_status "TRUE, for ${CMAKE_SYSTEM_NAME}, ${CMAKE_SYSTEM_PROCESSOR}") | ||
else() | ||
set(cross_status "FALSE") | ||
endif() | ||
message("Cross compiling ....................... ${cross_status}") | ||
|
||
get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) | ||
if(is_multi_config) | ||
list(JOIN CMAKE_CONFIGURATION_TYPES ", " configs) | ||
message("Available build configurations ........ ${configs}") | ||
if(CMAKE_GENERATOR MATCHES "Visual Studio") | ||
set(default_config "Debug") | ||
else() | ||
list(GET CMAKE_CONFIGURATION_TYPES 0 default_config) | ||
endif() | ||
message("Default build configuration ........... ${default_config}") | ||
string(TOUPPER "${default_config}" config_uppercase) | ||
if(DEFINED CMAKE_BUILD_TYPE) | ||
message("Flags for configuration \"${CMAKE_BUILD_TYPE}\":") | ||
string(TOUPPER "${CMAKE_BUILD_TYPE}" config_uppercase) | ||
endif() | ||
else() | ||
message("Build configuration ................... ${CMAKE_BUILD_TYPE}") | ||
string(TOUPPER "${CMAKE_BUILD_TYPE}" config_uppercase) | ||
endif() | ||
|
||
string(STRIP "${definitions_ALL} ${definitions_${config_uppercase}}" combined_cpp_flags) | ||
normalize_preprocessor_definitions(combined_cpp_flags) | ||
message("Preprocessor defined macros ........... ${combined_cpp_flags}") | ||
|
||
message("C compiler ............................ ${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION}, ${CMAKE_C_COMPILER}") | ||
string(STRIP "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${config_uppercase}}" combined_c_flags) | ||
list(JOIN DEPENDS_C_COMPILER_FLAGS " " depends_c_flags) | ||
string(STRIP "${combined_c_flags} ${depends_c_flags}" combined_c_flags) | ||
get_target_interface(common_compile_options core_interface COMPILE_OPTIONS) | ||
string(STRIP "${combined_c_flags} ${common_compile_options}" combined_c_flags) | ||
message("C compiler flags ...................... ${combined_c_flags}") | ||
|
||
message("C++ compiler .......................... ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}, ${CMAKE_CXX_COMPILER}") | ||
string(STRIP "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${config_uppercase}}" combined_cxx_flags) | ||
list(JOIN DEPENDS_CXX_COMPILER_FLAGS " " depends_cxx_flags) | ||
string(STRIP "${combined_cxx_flags} ${depends_cxx_flags}" combined_cxx_flags) | ||
string(STRIP "${combined_cxx_flags} ${common_compile_options}" combined_cxx_flags) | ||
message("C++ compiler flags .................... ${combined_cxx_flags}") | ||
|
||
get_target_interface(common_link_options core_interface LINK_OPTIONS) | ||
string(STRIP "${CMAKE_EXE_LINKER_FLAGS} ${common_link_options}" combined_linker_flags) | ||
message("Linker flags .......................... ${combined_linker_flags}") | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters