summaryrefslogtreecommitdiffstats
path: root/Modules/Platform/Android-Common.cmake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-06-02 19:11:42 (GMT)
committerBrad King <brad.king@kitware.com>2016-08-23 16:51:58 (GMT)
commitb22294bc41c3ce62e561c7123c3f489a750dcb66 (patch)
treee4d69ae3c1d70330ca09ef9ea80fc0433cc8af2b /Modules/Platform/Android-Common.cmake
parentb6a3102a9f8da05b50d4f4e96dd9f42ace37aa9b (diff)
downloadCMake-b22294bc41c3ce62e561c7123c3f489a750dcb66.zip
CMake-b22294bc41c3ce62e561c7123c3f489a750dcb66.tar.gz
CMake-b22294bc41c3ce62e561c7123c3f489a750dcb66.tar.bz2
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.
Diffstat (limited to 'Modules/Platform/Android-Common.cmake')
-rw-r--r--Modules/Platform/Android-Common.cmake31
1 files changed, 31 insertions, 0 deletions
diff --git a/Modules/Platform/Android-Common.cmake b/Modules/Platform/Android-Common.cmake
index 0ef9512..e77d2d8 100644
--- a/Modules/Platform/Android-Common.cmake
+++ b/Modules/Platform/Android-Common.cmake
@@ -17,5 +17,36 @@ if(__ANDROID_COMPILER_COMMON)
endif()
set(__ANDROID_COMPILER_COMMON 1)
+# The NDK toolchain configuration files at:
+#
+# <ndk>/[build/core/]toolchains/*/setup.mk
+#
+# contain logic to set TARGET_CFLAGS and TARGET_LDFLAGS (and debug/release
+# variants) to tell their build system what flags to pass for each ABI.
+# We need to produce the same flags here to produce compatible binaries.
+# We initialize these variables here and set them in the compiler-specific
+# modules that include this one. Then we use them in the macro below when
+# it is called.
+set(_ANDROID_ABI_INIT_CFLAGS "")
+set(_ANDROID_ABI_INIT_CFLAGS_DEBUG "")
+set(_ANDROID_ABI_INIT_CFLAGS_RELEASE "")
+set(_ANDROID_ABI_INIT_LDFLAGS "")
+
macro(__android_compiler_common lang)
+ if(_ANDROID_ABI_INIT_CFLAGS)
+ string(APPEND CMAKE_${lang}_FLAGS_INIT " ${_ANDROID_ABI_INIT_CFLAGS}")
+ endif()
+ if(_ANDROID_ABI_INIT_CFLAGS_DEBUG)
+ string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " ${_ANDROID_ABI_INIT_CFLAGS_DEBUG}")
+ endif()
+ if(_ANDROID_ABI_INIT_CFLAGS_RELEASE)
+ string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " ${_ANDROID_ABI_INIT_CFLAGS_RELEASE}")
+ string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " ${_ANDROID_ABI_INIT_CFLAGS_RELEASE}")
+ string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " ${_ANDROID_ABI_INIT_CFLAGS_RELEASE}")
+ endif()
+ if(_ANDROID_ABI_INIT_LDFLAGS)
+ foreach(t EXE SHARED MODULE)
+ string(APPEND CMAKE_${t}_LINKER_FLAGS_INIT " ${_ANDROID_ABI_INIT_LDFLAGS}")
+ endforeach()
+ endif()
endmacro()