Android: Add options to control exceptions/rtti

With the NDK's `android.toolchain.cmake`, the user can control whether
exceptions/rtti is enabled using `ANDROID_CPP_FEATURES`:

  43b2de34ef/build/cmake/android.toolchain.cmake (548)

Add `CMAKE_ANDROID_RTTI` and `CMAKE_ANDROID_EXCEPTIONS` to support that.
This commit is contained in:
Haibo Huang
2020-10-29 20:22:32 -07:00
committed by Brad King
parent 622ac065d2
commit 738caa4d48
4 changed files with 22 additions and 0 deletions

View File

@@ -336,6 +336,7 @@ Variables that Control the Build
/variable/CMAKE_ANDROID_ARM_MODE
/variable/CMAKE_ANDROID_ARM_NEON
/variable/CMAKE_ANDROID_ASSETS_DIRECTORIES
/variable/CMAKE_ANDROID_EXCEPTIONS
/variable/CMAKE_ANDROID_GUI
/variable/CMAKE_ANDROID_JAR_DEPENDENCIES
/variable/CMAKE_ANDROID_JAR_DIRECTORIES
@@ -349,6 +350,7 @@ Variables that Control the Build
/variable/CMAKE_ANDROID_PROCESS_MAX
/variable/CMAKE_ANDROID_PROGUARD
/variable/CMAKE_ANDROID_PROGUARD_CONFIG_PATH
/variable/CMAKE_ANDROID_RTTI
/variable/CMAKE_ANDROID_SECURE_PROPS_PATH
/variable/CMAKE_ANDROID_SKIP_ANT_STEP
/variable/CMAKE_ANDROID_STANDALONE_TOOLCHAIN

View File

@@ -0,0 +1,7 @@
CMAKE_ANDROID_EXCEPTIONS
------------------------
.. versionadded:: 3.20
When :ref:`Cross Compiling for Android with the NDK`, this variable may be set
to specify whether exceptions are enabled.

View File

@@ -0,0 +1,7 @@
CMAKE_ANDROID_RTTI
------------------
.. versionadded:: 3.20
When :ref:`Cross Compiling for Android with the NDK`, this variable may be set
to specify whether RTTI is enabled.

View File

@@ -81,6 +81,12 @@ if(CMAKE_ANDROID_STL_TYPE)
"Android: STL '${CMAKE_ANDROID_STL_TYPE}' not supported by this NDK."
)
endif()
if(DEFINED CMAKE_ANDROID_RTTI)
set(_ANDROID_STL_RTTI ${CMAKE_ANDROID_RTTI})
endif()
if(DEFINED CMAKE_ANDROID_EXCEPTIONS)
set(_ANDROID_STL_EXCEPTIONS ${CMAKE_ANDROID_EXCEPTIONS})
endif()
elseif(CMAKE_ANDROID_NDK)
macro(__android_stl_inc lang dir req)