summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-06-19 12:20:25 (GMT)
committerBrad King <brad.king@kitware.com>2019-06-19 12:20:25 (GMT)
commitc54fc8213bfbd33b9584188b90cd494e2bf515db (patch)
tree07536d3e2c917ed35f39bfaa45ab1eff0e886b47
parentf3e9a6ff62f6f58cd661dd447c22a01c50f6f4ad (diff)
parent9e99a95c7db5be8c6b979b0170ab4cf78bb32307 (diff)
downloadCMake-c54fc8213bfbd33b9584188b90cd494e2bf515db.zip
CMake-c54fc8213bfbd33b9584188b90cd494e2bf515db.tar.gz
CMake-c54fc8213bfbd33b9584188b90cd494e2bf515db.tar.bz2
Merge branch 'android-pie-cmp0083' into release-3.14
Merge-request: !3459
-rw-r--r--Help/policy/CMP0083.rst6
-rw-r--r--Modules/Platform/Android/abi-common.cmake20
2 files changed, 26 insertions, 0 deletions
diff --git a/Help/policy/CMP0083.rst b/Help/policy/CMP0083.rst
index 32acf1f..e0b09cf 100644
--- a/Help/policy/CMP0083.rst
+++ b/Help/policy/CMP0083.rst
@@ -28,6 +28,12 @@ This policy was introduced in CMake version 3.14. Use the
Unlike most policies, CMake version |release| does not warn when this policy is
not set and simply uses ``OLD`` behavior.
+.. Note::
+
+ Android platform has a special handling of ``PIE`` so it is not required
+ to use the :module:`CheckPIESupported` module to ensure flags are passed to
+ the linker.
+
.. include:: DEPRECATED.txt
Examples
diff --git a/Modules/Platform/Android/abi-common.cmake b/Modules/Platform/Android/abi-common.cmake
index a0b47f4..6bce3c7 100644
--- a/Modules/Platform/Android/abi-common.cmake
+++ b/Modules/Platform/Android/abi-common.cmake
@@ -12,6 +12,26 @@ if(NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
+cmake_policy(GET CMP0083 _CMP0083)
+if(_CMP0083 STREQUAL NEW)
+ # PIE Flags are managed by compiler configuration files
+ if(CMAKE_SYSTEM_VERSION VERSION_GREATER_EQUAL 16)
+ # ensure PIE flags are passed to the linker
+ set(CMAKE_C_LINK_PIE_SUPPORTED YES CACHE INTERNAL "PIE (C)")
+ set(CMAKE_CXX_LINK_PIE_SUPPORTED YES CACHE INTERNAL "PIE (CXX)")
+ if(CMAKE_SYSTEM_VERSION VERSION_GREATER_EQUAL 21)
+ # no PIE executable are no longer supported
+ set(CMAKE_C_LINK_NO_PIE_SUPPORTED NO CACHE INTERNAL "NO_PIE (C)")
+ set(CMAKE_CXX_LINK_NO_PIE_SUPPORTED NO CACHE INTERNAL "NO_PIE (CXX)")
+ endif()
+ endif()
+else()
+ if(CMAKE_POSITION_INDEPENDENT_CODE)
+ string(APPEND _ANDROID_ABI_INIT_EXE_LDFLAGS " -fPIE -pie")
+ endif()
+endif()
+unset(_CMP0083)
+
string(APPEND _ANDROID_ABI_INIT_EXE_LDFLAGS " -Wl,--gc-sections")
if(NOT _ANDROID_ABI_INIT_EXE_LDFLAGS_NO_nocopyreloc)