Commit Graph

5 Commits

Author SHA1 Message Date
Brad King 4c272adbe1 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
2016-10-24 11:45:18 -04:00
Brad King 6205f1797e Android: Set CMAKE_POSITION_INDEPENDENT_CODE automatically
If the toolchain file or cache does not set this, enable it
automatically based on the Android API version.  Versions 16
and above expect position independent code.

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.
2016-10-24 11:40:53 -04:00
Brad King 295c8efa35 Android: Add missing link flags for device executables
See `${ndk}/build/core/default-build-commands.mk` for link flags the NDK
uses for executables.  Add them to our default executable link flags.
Suppress `nocopyreloc` on `arm64-v8a` because it does not work with
some STL types.

Closes: #16380
2016-10-21 10:43:45 -04:00
Brad King b22294bc41 Android: Populate compiler flags for current ABI
Initialize the CMAKE_{C,CXX}_FLAGS{,_<CONFIG>} cache entries with
flags for each ABI as specified by NDK toolchain `setup.mk` files.
2016-08-23 12:51:58 -04:00
Brad King 504db72d99 Android: Add placeholders for compiler/abi-specific settings
The Android NDK source repository at

  https://android.googlesource.com/platform/ndk.git

has `<ndk>/build/core/toolchains/*/setup.mk` files that store tables of
information for their build system.  Add an equivalent file for each
compiler/abi combination.
2016-08-12 10:40:54 -04:00