Wrap the GNU/Clang compiler-dependent flags with genex conditions
If flags use CMake scopes that propagate them to user libraries, it may lead to an issue, if user projects are built using different compiler. We need to guard these flags to make sure that they only will apply to respective compilers. Pick-to: 6.5 6.6 Change-Id: I0fd5847447bd8373e8e07f64dae11f27f48c915d Reviewed-by: Alexandru Croitor (OOO) <alexandru.croitor@qt.io> Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
This commit is contained in:
parent
59a740e997
commit
a2b6c2f343
@ -121,6 +121,16 @@ function(qt_internal_apply_gc_binaries target visibility)
|
||||
message(FATAL_ERROR "Visibitily setting must be one of PRIVATE, INTERFACE or PUBLIC.")
|
||||
endif()
|
||||
|
||||
string(JOIN "" clang_or_gcc_begin
|
||||
"$<$<OR:"
|
||||
"$<CXX_COMPILER_ID:GNU>,"
|
||||
"$<CXX_COMPILER_ID:Clang>,"
|
||||
"$<CXX_COMPILER_ID:AppleClang>,"
|
||||
"$<CXX_COMPILER_ID:IntelLLVM>"
|
||||
">:"
|
||||
)
|
||||
set(clang_or_gcc_end ">")
|
||||
|
||||
if ((GCC OR CLANG) AND NOT WASM AND NOT UIKIT AND NOT MSVC)
|
||||
if(APPLE)
|
||||
set(gc_sections_flag "-Wl,-dead_strip")
|
||||
@ -129,16 +139,19 @@ function(qt_internal_apply_gc_binaries target visibility)
|
||||
elseif(LINUX OR BSD OR WIN32 OR ANDROID)
|
||||
set(gc_sections_flag "-Wl,--gc-sections")
|
||||
endif()
|
||||
set(gc_sections_flag
|
||||
"${clang_or_gcc_begin}${gc_sections_flag}${clang_or_gcc_end}")
|
||||
endif()
|
||||
if(gc_sections_flag)
|
||||
target_link_options("${target}" ${visibility} "${gc_sections_flag}")
|
||||
endif()
|
||||
|
||||
if((GCC OR CLANG) AND NOT WASM AND NOT UIKIT AND NOT MSVC)
|
||||
set(split_sections_flags "-ffunction-sections" "-fdata-sections")
|
||||
set(split_sections_flags
|
||||
"${clang_or_gcc_begin}-ffunction-sections;-fdata-sections${clang_or_gcc_end}")
|
||||
endif()
|
||||
if(split_sections_flags)
|
||||
target_compile_options("${target}" ${visibility} ${split_sections_flags})
|
||||
target_compile_options("${target}" ${visibility} "${split_sections_flags}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
@ -153,7 +166,12 @@ function(qt_internal_apply_intel_cet target visibility)
|
||||
endif()
|
||||
|
||||
if(GCC)
|
||||
set(flags "-mshstk")
|
||||
string(JOIN "" flags
|
||||
"$<$<OR:"
|
||||
"$<CXX_COMPILER_ID:GNU>,"
|
||||
"$<CXX_COMPILER_ID:Clang>,"
|
||||
"$<CXX_COMPILER_ID:AppleClang>"
|
||||
">:-mshstk>")
|
||||
endif()
|
||||
if(flags)
|
||||
target_compile_options("${target}" ${visibility} "${flags}")
|
||||
|
Loading…
Reference in New Issue
Block a user