From 8829ce67d8d0eac90e9fd6fde088b41f157177a5 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 25 May 2015 14:55:38 +0200 Subject: Only add -fPIC flags for compilers known to require it. Commit 083c9269 (Try to ensure that -fPIC is used in CMake builds, 2015-05-11) added a raw -fPIC to the INTERFACE_COMPILE_OPTIONS of Qt5::Core, which affects all consuming compilers. Use the qmake variable $$QMAKE_CXXFLAGS_APP instead, which at least currently contains only the -fPIC variable or harmlessly expands to nothing. If the content of that qmake variable changes in the future, a $$QMAKE_CXXFLAGS_APP_PIC variable should be extracted in qmake and used here. Don't use the POSITION_INDEPENDENT_CODE feature of CMake. That adds the -fPIE flag for executables, which is explicitly what qglobal.h forbids since commit 3eca75de (Make qglobal.h complain if you use -fPIE, 2015-05-11). The current behavior of that CMake feature is tracked here: http://public.kitware.com/Bug/view.php?id=15570 Change-Id: I5c5bcc40fe4b310b55a681a3505f45c50adfa054 Reviewed-by: Oswald Buddenhagen Reviewed-by: Simon Hausmann --- src/corelib/Qt5CoreMacros.cmake | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/corelib/Qt5CoreMacros.cmake') diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake index 9c81754302..c10880f787 100644 --- a/src/corelib/Qt5CoreMacros.cmake +++ b/src/corelib/Qt5CoreMacros.cmake @@ -281,10 +281,6 @@ if (NOT CMAKE_VERSION VERSION_LESS 2.8.9) set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS_RELEASE QT_NO_DEBUG) set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS_RELWITHDEBINFO QT_NO_DEBUG) set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS_MINSIZEREL QT_NO_DEBUG) - - if (Qt5_POSITION_INDEPENDENT_CODE) - set_property(TARGET ${_target} PROPERTY POSITION_INDEPENDENT_CODE ${Qt5_POSITION_INDEPENDENT_CODE}) - endif() endforeach() endmacro() endif() -- cgit v1.2.3 From e3983c87280ade48b243d9c60bed639713851be9 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 28 May 2015 21:20:55 +0200 Subject: Revert some changes in light of GCC 4 -fPIE reversal The -fPIE option is now accepted when using GCC 4, which means it is available for backward compatibility for clients using CMake 2.8.11 or older which makes use of the POSITION_INDEPENDENT_CODE feature. Conditionally use that feature for old versions of cmake with GCC 4. Restore the tests for those versions, and clarify the situation in the ChangeLog. Change-Id: I5a06b155dda7db559d86841a2b34fd8ed95acbd0 Reviewed-by: Thiago Macieira --- src/corelib/Qt5CoreMacros.cmake | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/corelib/Qt5CoreMacros.cmake') diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake index c10880f787..cfbb381df5 100644 --- a/src/corelib/Qt5CoreMacros.cmake +++ b/src/corelib/Qt5CoreMacros.cmake @@ -281,6 +281,12 @@ if (NOT CMAKE_VERSION VERSION_LESS 2.8.9) set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS_RELEASE QT_NO_DEBUG) set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS_RELWITHDEBINFO QT_NO_DEBUG) set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS_MINSIZEREL QT_NO_DEBUG) + if (Qt5_POSITION_INDEPENDENT_CODE + AND (CMAKE_VERSION VERSION_LESS 2.8.12 + AND (NOT CMAKE_CXX_COMPILER_ID STREQUAL \"GNU\" + OR CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0))) + set_property(TARGET ${_target} PROPERTY POSITION_INDEPENDENT_CODE ${Qt5_POSITION_INDEPENDENT_CODE}) + endif() endforeach() endmacro() endif() -- cgit v1.2.3