summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2023-02-22 10:47:00 +0100
committerJoerg Bornemann <joerg.bornemann@qt.io>2023-02-23 08:50:39 +0100
commit4183768d9bc6f80ac7b86c3dbf93e6b251369ae4 (patch)
treec550b82a7b3abe649b67ff37110aecee5373b0be /cmake
parent78f7a8c418bc887ebb5bd75f63e35a2b8108f107 (diff)
CMake: Fix position independent code linker flags not being set
We set CMAKE_POSITION_INDEPENDENT_CODE to ON and require CMake 3.16. This sets CMP0083 to NEW and should pass -fPIE to linker calls as well. However, the PIE-enabling flag is not passed to the linker unless we call check_pie_supported(). This behavior is documented in CMake's CMP0083 documentation page. [ChangeLog][CMake] Qt tools are now built with position independent code even with Unix toolchains where this is not the default, for example clang. Pick-to: 6.5 6.4 6.2 Change-Id: I1d98e0ea7063a76e3fddc94d6555c6eaf14c7885 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtSetup.cmake4
1 files changed, 4 insertions, 0 deletions
diff --git a/cmake/QtSetup.cmake b/cmake/QtSetup.cmake
index 019a579a4a..262b60d171 100644
--- a/cmake/QtSetup.cmake
+++ b/cmake/QtSetup.cmake
@@ -119,6 +119,10 @@ endif()
## Position independent code:
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+# Does the linker support position independent code?
+include(CheckPIESupported)
+check_pie_supported()
+
# Do not relink dependent libraries when no header has changed:
set(CMAKE_LINK_DEPENDS_NO_SHARED ON)