summaryrefslogtreecommitdiffstats
path: root/Modules/Platform
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-10-24 15:45:18 (GMT)
committerBrad King <brad.king@kitware.com>2016-10-24 15:45:18 (GMT)
commit4c272adbe1d67af4779f4e72d9562457ed851dac (patch)
tree544ebe3ddba9707957aca298c07821db6ce2ab6c /Modules/Platform
parent6205f1797e33c22ab1f9cda8598d02b24497b806 (diff)
downloadCMake-4c272adbe1d67af4779f4e72d9562457ed851dac.zip
CMake-4c272adbe1d67af4779f4e72d9562457ed851dac.tar.gz
CMake-4c272adbe1d67af4779f4e72d9562457ed851dac.tar.bz2
Android: Link position-independent executables with proper flags
Add `-fPIE -pie` to the default executable link flags when `CMAKE_POSITION_INDEPENDENT_CODE` is enabled. This is required by Android 16 and above for executables to run on the device. Closes: #16382
Diffstat (limited to 'Modules/Platform')
-rw-r--r--Modules/Platform/Android/abi-common.cmake4
1 files changed, 4 insertions, 0 deletions
diff --git a/Modules/Platform/Android/abi-common.cmake b/Modules/Platform/Android/abi-common.cmake
index 533bd90..3b0eb01 100644
--- a/Modules/Platform/Android/abi-common.cmake
+++ b/Modules/Platform/Android/abi-common.cmake
@@ -8,6 +8,10 @@ if(NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
+if(CMAKE_POSITION_INDEPENDENT_CODE)
+ string(APPEND _ANDROID_ABI_INIT_EXE_LDFLAGS " -fPIE -pie")
+endif()
+
string(APPEND _ANDROID_ABI_INIT_EXE_LDFLAGS " -Wl,--gc-sections")
if(NOT _ANDROID_ABI_INIT_EXE_LDFLAGS_NO_nocopyreloc)