Attempt checking the CMAKE_GENERATOR when passing hardening flags
Use the _qt_internal_cmake_generator of the PlatformCommonInternal to store the current CMake generator is used. The property allows checking the CMake generator as part of transitively propagated properties, like those we use in PlatformCommonInternal. Wrap the compile definisions belonging to libcpp_hardening feature with CMake generator check, since Xcode sets own definitions which lead to the macro 'redefinition' compilation warning. Change-Id: I5f6131245746afbe413efc831a9447ba40142a4e Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
938df79081
commit
b23f915fe4
@ -33,6 +33,19 @@ else()
|
||||
QT_VERSION_PATCH @PROJECT_VERSION_PATCH@)
|
||||
endif()
|
||||
|
||||
if(TARGET @INSTALL_CMAKE_NAMESPACE@::PlatformCommonInternal)
|
||||
get_target_property(_qt_platform_internal_common_target
|
||||
@INSTALL_CMAKE_NAMESPACE@::PlatformCommonInternal ALIASED_TARGET)
|
||||
if(NOT _qt_platform_internal_common_target)
|
||||
set(_qt_platform_internal_common_target @INSTALL_CMAKE_NAMESPACE@::PlatformCommonInternal)
|
||||
endif()
|
||||
set_target_properties(${_qt_platform_internal_common_target}
|
||||
PROPERTIES
|
||||
_qt_internal_cmake_generator "${CMAKE_GENERATOR}"
|
||||
)
|
||||
unset(_qt_platform_internal_common_target)
|
||||
endif()
|
||||
|
||||
get_filename_component(_qt_import_prefix "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||
get_filename_component(_qt_import_prefix "${_qt_import_prefix}" REALPATH)
|
||||
list(APPEND CMAKE_MODULE_PATH "${_qt_import_prefix}")
|
||||
|
@ -347,7 +347,25 @@ if(QT_FEATURE_libstdcpp_assertions)
|
||||
endif()
|
||||
|
||||
if(QT_FEATURE_libcpp_hardening)
|
||||
target_compile_definitions(PlatformCommonInternal INTERFACE -D_LIBCPP_HARDENING_MODE=$<IF:$<CONFIG:Debug>,_LIBCPP_HARDENING_MODE_EXTENSIVE,_LIBCPP_HARDENING_MODE_FAST>)
|
||||
string(JOIN "" hardening_flags
|
||||
"$<$<NOT:$<STREQUAL:"
|
||||
"$<TARGET_PROPERTY:"
|
||||
"${QT_CMAKE_EXPORT_NAMESPACE}::PlatformCommonInternal,"
|
||||
"_qt_internal_cmake_generator"
|
||||
">,"
|
||||
"Xcode"
|
||||
">>:"
|
||||
"_LIBCPP_HARDENING_MODE=$<IF:$<CONFIG:Debug>,"
|
||||
"_LIBCPP_HARDENING_MODE_EXTENSIVE,"
|
||||
"_LIBCPP_HARDENING_MODE_FAST"
|
||||
">"
|
||||
">"
|
||||
)
|
||||
set_target_properties(PlatformCommonInternal
|
||||
PROPERTIES
|
||||
_qt_internal_cmake_generator "${CMAKE_GENERATOR}"
|
||||
)
|
||||
target_compile_definitions(PlatformCommonInternal INTERFACE "${hardening_flags}")
|
||||
endif()
|
||||
|
||||
if(QT_FEATURE_relro_now_linker)
|
||||
|
Loading…
x
Reference in New Issue
Block a user