Fixed CMake use with Android NDK 23 (#6460)

* Fixed CMake use with Android NDK 23

This was done by only setting the `ANDROID_ARM_MODE` if the ANDROID_ABI
starts with `armeabi`.

The Android arm mode setting can't be used using non-`armeabi` ABIs.
In O3DE we default to `arm64-v8a` `ANDROID_ABI`
So `ANDROID_ARM_MODE` must not be set.

The CMake [Android-Determine.cmake](https://gitlab.kitware.com/cmake/cmake/-/blob/master/Modules/Platform/Android-Determine.cmake#L573-585) which is used to detect platform-wide information when the CMAKE_SYSTEM_NAME is set to android, enforces that if the `CMAKE_ANDROID_ARCH_ABI` doesn't start with `armeabi`, then it will fatal error if the CMAKE_ANDROID_ARM_MODE option is set.

In Android NDK 21 the `ANDROID_ARM_MODE` variable is used to set the CMAKE_ANDROID_ARM_MODE variable if the [ANDROID_ABI](https://android.googlesource.com/platform/ndk/+/refs/tags/ndk-r21e/build/cmake/android.toolchain.cmake#700) starts with `armeabi`.

This meant when using Android NDK 21, the CMake Android-Determine.cmake module would succeed, due
to the CMAKE_ANDROID_ARM_MODE not being set.

In Android NDK 23 the `ANDROID_ARM_MODE` now will set the
`CMAKE_ANDROID_ARM_MODE` variable to `TRUE` if it isn't defined.

Added an `--extra-cmake-configure-args` option to the `generate_android_project.py` script which can be used to append user specified CMake arguments to the cmake configure step (`cmake -B <build-dir> -S <source-dir> -DCMAKE_TOOLCHAIN_FILE=<android-toolchain-file> <extra-args>`)

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Updated the O3DE Android toolchain wrapper to fatal error if the 64-bit
arm ABI isn't used.

Also removed the unneccessary setting of the ANDROID_ARM_MODE and
ANDROID_ARM_NEON option option now that the armeabi cannot be specified
as an ABI.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
This commit is contained in:
lumberyard-employee-dm
2022-01-10 19:11:00 -06:00
committed by GitHub
parent d3a99235aa
commit f09055af42
4 changed files with 22 additions and 12 deletions
@@ -227,6 +227,9 @@ def main(args):
help='Override path to where the Vulkan Validation Layers libraries are. Required for use with NDK r23+',
default=None,
required=False)
parser.add_argument('--extra-cmake-configure-args',
help='Extra arguments to supply to the cmake configure step',
nargs='*')
# Asset Options
parser.add_argument(INCLUDE_APK_ASSETS_ARGUMENT_NAME,
@@ -415,7 +418,8 @@ def main(args):
overwrite_existing=parsed_args.overwrite_existing,
unity_build_enabled=parsed_args.enable_unity_build,
native_build_path=parsed_args.native_build_path,
vulkan_validation_path=parsed_args.vulkan_validation_path)
vulkan_validation_path=parsed_args.vulkan_validation_path,
extra_cmake_configure_args=parsed_args.extra_cmake_configure_args)
generator.execute()