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:
committed by
GitHub
parent
d3a99235aa
commit
f09055af42
@@ -471,7 +471,8 @@ class AndroidProjectGenerator(object):
|
||||
|
||||
def __init__(self, engine_root, build_dir, android_sdk_path, build_tool, android_sdk_platform, android_native_api_level, android_ndk,
|
||||
project_path, third_party_path, cmake_version, override_cmake_path, override_gradle_path, gradle_version, gradle_plugin_version,
|
||||
override_ninja_path, include_assets_in_apk, asset_mode, asset_type, signing_config, native_build_path, vulkan_validation_path, is_test_project=False,
|
||||
override_ninja_path, include_assets_in_apk, asset_mode, asset_type, signing_config, native_build_path, vulkan_validation_path,
|
||||
extra_cmake_configure_args, is_test_project=False,
|
||||
overwrite_existing=True, unity_build_enabled=False):
|
||||
"""
|
||||
Initialize the object with all the required parameters needed to create an Android Project. The parameters should be verified before initializing this object
|
||||
@@ -497,6 +498,7 @@ class AndroidProjectGenerator(object):
|
||||
:param signing_config: Optional signing configuration arguments
|
||||
:param native_build_path: Override the native build staging path in gradle
|
||||
:param vulkan_validation_path: Override the path to where the Vulkan Validation Layers libraries are (required when using NDK r23+)
|
||||
:param extra_cmake_configure_args Additional arguments to supply cmake when configuring a project
|
||||
:param is_test_project: Flag to indicate if this is a unit test runner project. (If true, project_path, asset_mode, asset_type, and include_assets_in_apk are ignored)
|
||||
:param overwrite_existing: Flag to overwrite existing project files when being generated, or skip if they already exist.
|
||||
"""
|
||||
@@ -539,6 +541,8 @@ class AndroidProjectGenerator(object):
|
||||
|
||||
self.vulkan_validation_path = vulkan_validation_path
|
||||
|
||||
self.extra_cmake_configure_args = extra_cmake_configure_args
|
||||
|
||||
self.asset_mode = asset_mode
|
||||
|
||||
self.asset_type = asset_type
|
||||
@@ -844,6 +848,9 @@ class AndroidProjectGenerator(object):
|
||||
if self.override_ninja_path:
|
||||
cmake_argument_list.append(f'"-DCMAKE_MAKE_PROGRAM={common.normalize_path_for_settings(self.override_ninja_path)}"')
|
||||
|
||||
if self.extra_cmake_configure_args:
|
||||
cmake_argument_list.extend(map(json.dumps, self.extra_cmake_configure_args))
|
||||
|
||||
# Query the project_path from the project.json file
|
||||
project_name = common.read_project_name_from_project_json(self.project_path)
|
||||
# Prepare the config-specific section to place the cmake argument list in the build.gradle for the app
|
||||
|
||||
Reference in New Issue
Block a user