From f9817dda5576db8709750cea7d799b1e5ea40ca0 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 13 Jun 2012 22:26:30 +0200 Subject: Use the POSITION_INDEPENDENT_CODE property on targets using Qt. This property is only set if Qt is configured with -reduce-relocations (which is the default). Change-Id: If2f0ab92448f03bbc3f7c828d3bca60107229072 Reviewed-by: Brad King Reviewed-by: Stephen Kelly --- src/corelib/Qt5CoreMacros.cmake | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'src/corelib/Qt5CoreMacros.cmake') diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake index bc4c020826..cbd141aeb3 100644 --- a/src/corelib/Qt5CoreMacros.cmake +++ b/src/corelib/Qt5CoreMacros.cmake @@ -223,16 +223,21 @@ if (NOT CMAKE_VERSION VERSION_LESS 2.8.8) set_property(TARGET ${_target} APPEND PROPERTY INCLUDE_DIRECTORIES ${Qt5${_module}_INCLUDE_DIRS}) set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS ${Qt5${_module}_COMPILE_DEFINITIONS}) - # We can't just append to the COMPILE_FLAGS property. That creats a ';' separated list - # which breaks the compile commmand line. - # Ensure non-duplication here manually instead. - get_property(_target_type TARGET ${_target} PROPERTY TYPE) - if ("${_target_type}" STREQUAL "EXECUTABLE" AND Qt5${_module}_EXECUTABLE_COMPILE_FLAGS) - get_target_property(_flags ${_target} COMPILE_FLAGS) - string(FIND "${_flags}" "${Qt5${_module}_EXECUTABLE_COMPILE_FLAGS}" _find_result) - if (NOT _find_result) - set_target_properties(${_target} PROPERTIES COMPILE_FLAGS "${_flags} ${Qt5${_module}_EXECUTABLE_COMPILE_FLAGS}") - endif() + if (Qt5_POSITION_INDEPENDENT_CODE) + set_property(TARGET ${_target} PROPERTY POSITION_INDEPENDENT_CODE ${Qt5_POSITION_INDEPENDENT_CODE}) + if (CMAKE_VERSION VERSION_LESS 2.8.9) + # We can't just append to the COMPILE_FLAGS property. That creats a ';' separated list + # which breaks the compile commmand line. + # Ensure non-duplication here manually instead. + get_property(_target_type TARGET ${_target} PROPERTY TYPE) + if ("${_target_type}" STREQUAL "EXECUTABLE" AND Qt5${_module}_EXECUTABLE_COMPILE_FLAGS) + get_target_property(_flags ${_target} COMPILE_FLAGS) + string(FIND "${_flags}" "${Qt5${_module}_EXECUTABLE_COMPILE_FLAGS}" _find_result) + if (NOT _find_result) + set_target_properties(${_target} PROPERTIES COMPILE_FLAGS "${_flags} ${Qt5${_module}_EXECUTABLE_COMPILE_FLAGS}") + endif() + endif() + endif() endif() endforeach() endfunction() -- cgit v1.2.3