Skip to content

Android: Fix generation of flags for position-independent code

Brad King requested to merge brad.king/cmake:android-pic into master

Use the main CMAKE_POSITION_INDEPENDENT_CODE setting in favor of hard-coding -fpic or -fPIC in the compiler flags for each ABI. This allows CMake to use -fpie or -fPIE as needed when sources are meant for executables, and -fpic or -fPIC for other sources.

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 (closed)

Merge request reports