summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/Qt5CoreConfigExtras.cmake.in23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/corelib/Qt5CoreConfigExtras.cmake.in b/src/corelib/Qt5CoreConfigExtras.cmake.in
index 65fd1f9383..91a4eb619a 100644
--- a/src/corelib/Qt5CoreConfigExtras.cmake.in
+++ b/src/corelib/Qt5CoreConfigExtras.cmake.in
@@ -70,7 +70,14 @@ set(_qt5_corelib_extra_includes)
# 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 \"-fPIC\")
+
+# On x86 and x86-64 systems with ELF binaries (especially Linux), due to
+# a new optimization in GCC 5.x in combination with a recent version of
+# GNU binutils, compiling Qt applications with -fPIE is no longer
+# enough.
+# Applications now need to be compiled with the -fPIC option if the Qt option
+# \"reduce relocations\" is active. For backward compatibility only, Qt accepts
+# the use of -fPIE for GCC 4.x versions.
if (CMAKE_VERSION VERSION_LESS 2.8.12
AND (NOT CMAKE_CXX_COMPILER_ID STREQUAL \"GNU\"
OR CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0))
@@ -79,6 +86,20 @@ else()
set_property(TARGET Qt5::Core APPEND PROPERTY INTERFACE_COMPILE_OPTIONS $$QMAKE_CXXFLAGS_APP)
endif()
+# Applications using qmake or cmake >= 2.8.12 as their build system will
+# adapt automatically. Applications using an older release of cmake in
+# combination with GCC 5.x need to change their CMakeLists.txt to add
+# Qt5Core_EXECUTABLE_COMPILE_FLAGS to CMAKE_CXX_FLAGS. In particular,
+# applications using cmake >= 2.8.9 and < 2.8.11 will continue to build
+# with the -fPIE option and invoke the special compatibility mode if using
+# GCC 4.x.
+set(Qt5Core_EXECUTABLE_COMPILE_FLAGS \"\")
+if (CMAKE_VERSION VERSION_LESS 2.8.12
+ AND (CMAKE_CXX_COMPILER_ID STREQUAL \"GNU\"
+ AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0))
+ set(Qt5Core_EXECUTABLE_COMPILE_FLAGS \"-fPIC\")
+endif()
+
!!IF !isEmpty(QT_NAMESPACE)
list(APPEND Qt5Core_DEFINITIONS -DQT_NAMESPACE=$$QT_NAMESPACE)
list(APPEND Qt5Core_COMPILE_DEFINITIONS QT_NAMESPACE=$$QT_NAMESPACE)