summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Kelly <stephen.kelly@kdab.com>2012-06-13 22:26:30 +0200
committerQt by Nokia <qt-info@nokia.com>2012-06-20 10:26:59 +0200
commitf9817dda5576db8709750cea7d799b1e5ea40ca0 (patch)
tree403ee1280d48896706ef57223c4b2baf94019f6b
parent79b14f42ba2062252bad5e5ad7c7986b967f6f6a (diff)
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 <brad.king@kitware.com> Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
-rw-r--r--src/corelib/Qt5CoreConfigExtras.cmake.in4
-rw-r--r--src/corelib/Qt5CoreMacros.cmake25
2 files changed, 19 insertions, 10 deletions
diff --git a/src/corelib/Qt5CoreConfigExtras.cmake.in b/src/corelib/Qt5CoreConfigExtras.cmake.in
index cd330f5d34..246aa8376e 100644
--- a/src/corelib/Qt5CoreConfigExtras.cmake.in
+++ b/src/corelib/Qt5CoreConfigExtras.cmake.in
@@ -18,6 +18,10 @@ list(APPEND Qt5Core_INCLUDE_DIRS \"$${CMAKE_DATA_DIR}mkspecs/default\")
!!ENDIF
!!IF !isEmpty(CMAKE_ADD_FPIE_FLAGS)
+# Targets using Qt need to use the POSITION_INDEPENDENT_CODE property. The
+# Qt5_POSITION_INDEPENDENT_CODE variable is used in the # qt5_use_module
+# macro to add it.
+set(Qt5_POSITION_INDEPENDENT_CODE True)
set(Qt5Core_EXECUTABLE_COMPILE_FLAGS \"-fPIE\")
!!ENDIF
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()