summaryrefslogtreecommitdiffstats
path: root/Modules
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
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')
-rw-r--r--Modules/Platform/Android-Common.cmake31
-rw-r--r--Modules/Platform/Android/abi-arm64-v8a-Clang.cmake5
-rw-r--r--Modules/Platform/Android/abi-arm64-v8a-GNU.cmake4
-rw-r--r--Modules/Platform/Android/abi-armeabi-Clang.cmake17
-rw-r--r--Modules/Platform/Android/abi-armeabi-GNU.cmake16
-rw-r--r--Modules/Platform/Android/abi-armeabi-v6-Clang.cmake16
-rw-r--r--Modules/Platform/Android/abi-armeabi-v6-GNU.cmake15
-rw-r--r--Modules/Platform/Android/abi-armeabi-v7a-Clang.cmake26
-rw-r--r--Modules/Platform/Android/abi-armeabi-v7a-GNU.cmake25
-rw-r--r--Modules/Platform/Android/abi-common-Clang.cmake5
-rw-r--r--Modules/Platform/Android/abi-common.cmake4
-rw-r--r--Modules/Platform/Android/abi-mips-Clang.cmake5
-rw-r--r--Modules/Platform/Android/abi-mips-GNU.cmake4
-rw-r--r--Modules/Platform/Android/abi-mips64-Clang.cmake5
-rw-r--r--Modules/Platform/Android/abi-mips64-GNU.cmake4
-rw-r--r--Modules/Platform/Android/abi-x86-Clang.cmake5
-rw-r--r--Modules/Platform/Android/abi-x86_64-Clang.cmake5
17 files changed, 192 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()
diff --git a/Modules/Platform/Android/abi-arm64-v8a-Clang.cmake b/Modules/Platform/Android/abi-arm64-v8a-Clang.cmake
index 60fe3e5..3ff1fe5 100644
--- a/Modules/Platform/Android/abi-arm64-v8a-Clang.cmake
+++ b/Modules/Platform/Android/abi-arm64-v8a-Clang.cmake
@@ -1,3 +1,8 @@
# <ndk>/build/core/toolchains/aarch64-linux-android-clang/setup.mk
set(_ANDROID_ABI_CLANG_TARGET "aarch64-none-linux-android")
+
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -fpic"
+ )
+
include(Platform/Android/abi-common-Clang)
diff --git a/Modules/Platform/Android/abi-arm64-v8a-GNU.cmake b/Modules/Platform/Android/abi-arm64-v8a-GNU.cmake
index a25a0dd..538ec2f 100644
--- a/Modules/Platform/Android/abi-arm64-v8a-GNU.cmake
+++ b/Modules/Platform/Android/abi-arm64-v8a-GNU.cmake
@@ -1,2 +1,6 @@
# <ndk>/build/core/toolchains/aarch64-linux-android-4.9/setup.mk
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -fpic"
+ )
+
include(Platform/Android/abi-common-GNU)
diff --git a/Modules/Platform/Android/abi-armeabi-Clang.cmake b/Modules/Platform/Android/abi-armeabi-Clang.cmake
index eb703f5..4fc3009 100644
--- a/Modules/Platform/Android/abi-armeabi-Clang.cmake
+++ b/Modules/Platform/Android/abi-armeabi-Clang.cmake
@@ -1,3 +1,20 @@
# <ndk>/build/core/toolchains/arm-linux-androideabi-clang/setup.mk
set(_ANDROID_ABI_CLANG_TARGET "armv5te-none-linux-androideabi")
+
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -march=armv5te"
+ )
+
+if(CMAKE_ANDROID_ARM_MODE)
+ string(APPEND _ANDROID_ABI_INIT_CFLAGS " -marm")
+else()
+ string(APPEND _ANDROID_ABI_INIT_CFLAGS " -mthumb")
+endif()
+
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -msoft-float"
+ " -mtune=xscale"
+ " -fpic"
+ )
+
include(Platform/Android/abi-common-Clang)
diff --git a/Modules/Platform/Android/abi-armeabi-GNU.cmake b/Modules/Platform/Android/abi-armeabi-GNU.cmake
index d621e72..10cac00 100644
--- a/Modules/Platform/Android/abi-armeabi-GNU.cmake
+++ b/Modules/Platform/Android/abi-armeabi-GNU.cmake
@@ -1,2 +1,18 @@
# <ndk>/build/core/toolchains/arm-linux-androideabi-4.9/setup.mk
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -march=armv5te"
+ )
+
+if(CMAKE_ANDROID_ARM_MODE)
+ string(APPEND _ANDROID_ABI_INIT_CFLAGS " -marm")
+else()
+ string(APPEND _ANDROID_ABI_INIT_CFLAGS " -mthumb")
+endif()
+
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -msoft-float"
+ " -mtune=xscale"
+ " -fpic"
+ )
+
include(Platform/Android/abi-common-GNU)
diff --git a/Modules/Platform/Android/abi-armeabi-v6-Clang.cmake b/Modules/Platform/Android/abi-armeabi-v6-Clang.cmake
index b58b558..15f1d4a 100644
--- a/Modules/Platform/Android/abi-armeabi-v6-Clang.cmake
+++ b/Modules/Platform/Android/abi-armeabi-v6-Clang.cmake
@@ -1,3 +1,19 @@
# <ndk>/build/core/toolchains/arm-linux-androideabi-clang/setup.mk
set(_ANDROID_ABI_CLANG_TARGET "armv6-none-linux-androideabi")
+
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -march=armv6"
+ )
+
+if(CMAKE_ANDROID_ARM_MODE)
+ string(APPEND _ANDROID_ABI_INIT_CFLAGS " -marm")
+else()
+ string(APPEND _ANDROID_ABI_INIT_CFLAGS " -mthumb")
+endif()
+
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -mfloat-abi=softfp"
+ " -fpic"
+ )
+
include(Platform/Android/abi-common-Clang)
diff --git a/Modules/Platform/Android/abi-armeabi-v6-GNU.cmake b/Modules/Platform/Android/abi-armeabi-v6-GNU.cmake
index d621e72..7492de0 100644
--- a/Modules/Platform/Android/abi-armeabi-v6-GNU.cmake
+++ b/Modules/Platform/Android/abi-armeabi-v6-GNU.cmake
@@ -1,2 +1,17 @@
# <ndk>/build/core/toolchains/arm-linux-androideabi-4.9/setup.mk
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -march=armv6"
+ )
+
+if(CMAKE_ANDROID_ARM_MODE)
+ string(APPEND _ANDROID_ABI_INIT_CFLAGS " -marm")
+else()
+ string(APPEND _ANDROID_ABI_INIT_CFLAGS " -mthumb")
+endif()
+
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -mfloat-abi=softfp"
+ " -fpic"
+ )
+
include(Platform/Android/abi-common-GNU)
diff --git a/Modules/Platform/Android/abi-armeabi-v7a-Clang.cmake b/Modules/Platform/Android/abi-armeabi-v7a-Clang.cmake
index e7c311c..3a3efb3 100644
--- a/Modules/Platform/Android/abi-armeabi-v7a-Clang.cmake
+++ b/Modules/Platform/Android/abi-armeabi-v7a-Clang.cmake
@@ -1,3 +1,29 @@
# <ndk>/build/core/toolchains/arm-linux-androideabi-clang/setup.mk
set(_ANDROID_ABI_CLANG_TARGET "armv7-none-linux-androideabi")
+
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -march=armv7-a"
+ )
+
+if(CMAKE_ANDROID_ARM_MODE)
+ string(APPEND _ANDROID_ABI_INIT_CFLAGS " -marm")
+else()
+ string(APPEND _ANDROID_ABI_INIT_CFLAGS " -mthumb")
+endif()
+
+if(CMAKE_ANDROID_ARM_NEON)
+ string(APPEND _ANDROID_ABI_INIT_CFLAGS " -mfpu=neon")
+else()
+ string(APPEND _ANDROID_ABI_INIT_CFLAGS " -mfpu=vfpv3-d16")
+endif()
+
+string(APPEND _ANDROID_ABI_INIT_LDFLAGS
+ " -Wl,--fix-cortex-a8"
+ )
+
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -mfloat-abi=softfp"
+ " -fpic"
+ )
+
include(Platform/Android/abi-common-Clang)
diff --git a/Modules/Platform/Android/abi-armeabi-v7a-GNU.cmake b/Modules/Platform/Android/abi-armeabi-v7a-GNU.cmake
index d621e72..d27e37e 100644
--- a/Modules/Platform/Android/abi-armeabi-v7a-GNU.cmake
+++ b/Modules/Platform/Android/abi-armeabi-v7a-GNU.cmake
@@ -1,2 +1,27 @@
# <ndk>/build/core/toolchains/arm-linux-androideabi-4.9/setup.mk
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -march=armv7-a"
+ )
+
+if(CMAKE_ANDROID_ARM_MODE)
+ string(APPEND _ANDROID_ABI_INIT_CFLAGS " -marm")
+else()
+ string(APPEND _ANDROID_ABI_INIT_CFLAGS " -mthumb")
+endif()
+
+if(CMAKE_ANDROID_ARM_NEON)
+ string(APPEND _ANDROID_ABI_INIT_CFLAGS " -mfpu=neon")
+else()
+ string(APPEND _ANDROID_ABI_INIT_CFLAGS " -mfpu=vfpv3-d16")
+endif()
+
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -mfloat-abi=softfp"
+ " -fpic"
+ )
+
+string(APPEND _ANDROID_ABI_INIT_LDFLAGS
+ " -Wl,--fix-cortex-a8"
+ )
+
include(Platform/Android/abi-common-GNU)
diff --git a/Modules/Platform/Android/abi-common-Clang.cmake b/Modules/Platform/Android/abi-common-Clang.cmake
index 40d829f..6025170 100644
--- a/Modules/Platform/Android/abi-common-Clang.cmake
+++ b/Modules/Platform/Android/abi-common-Clang.cmake
@@ -1 +1,6 @@
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ #" -Wno-invalid-command-line-argument"
+ #" -Wno-unused-command-line-argument"
+ )
+
include(Platform/Android/abi-common)
diff --git a/Modules/Platform/Android/abi-common.cmake b/Modules/Platform/Android/abi-common.cmake
index e69de29..12d8e5c 100644
--- a/Modules/Platform/Android/abi-common.cmake
+++ b/Modules/Platform/Android/abi-common.cmake
@@ -0,0 +1,4 @@
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -funwind-tables"
+ " -no-canonical-prefixes"
+ )
diff --git a/Modules/Platform/Android/abi-mips-Clang.cmake b/Modules/Platform/Android/abi-mips-Clang.cmake
index 2991a93..bf6b9fc 100644
--- a/Modules/Platform/Android/abi-mips-Clang.cmake
+++ b/Modules/Platform/Android/abi-mips-Clang.cmake
@@ -1,3 +1,8 @@
# <ndk>/build/core/toolchains/mipsel-linux-android-clang/setup.mk
set(_ANDROID_ABI_CLANG_TARGET "mipsel-none-linux-android")
+
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -fpic"
+ )
+
include(Platform/Android/abi-common-Clang)
diff --git a/Modules/Platform/Android/abi-mips-GNU.cmake b/Modules/Platform/Android/abi-mips-GNU.cmake
index 675f9ca..d380440 100644
--- a/Modules/Platform/Android/abi-mips-GNU.cmake
+++ b/Modules/Platform/Android/abi-mips-GNU.cmake
@@ -1,2 +1,6 @@
# <ndk>/build/core/toolchains/mipsel-linux-android-4.9/setup.mk
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -fpic"
+ )
+
include(Platform/Android/abi-common-GNU)
diff --git a/Modules/Platform/Android/abi-mips64-Clang.cmake b/Modules/Platform/Android/abi-mips64-Clang.cmake
index 24b8db5..1a94107 100644
--- a/Modules/Platform/Android/abi-mips64-Clang.cmake
+++ b/Modules/Platform/Android/abi-mips64-Clang.cmake
@@ -1,3 +1,8 @@
# <ndk>/build/core/toolchains/mips64el-linux-android-clang/setup.mk
set(_ANDROID_ABI_CLANG_TARGET "mips64el-none-linux-android")
+
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -fpic"
+ )
+
include(Platform/Android/abi-common-Clang)
diff --git a/Modules/Platform/Android/abi-mips64-GNU.cmake b/Modules/Platform/Android/abi-mips64-GNU.cmake
index 3f9fbc3..4525d40 100644
--- a/Modules/Platform/Android/abi-mips64-GNU.cmake
+++ b/Modules/Platform/Android/abi-mips64-GNU.cmake
@@ -1,2 +1,6 @@
# <ndk>/build/core/toolchains/mips64el-linux-android-4.9/setup.mk
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -fpic"
+ )
+
include(Platform/Android/abi-common-GNU)
diff --git a/Modules/Platform/Android/abi-x86-Clang.cmake b/Modules/Platform/Android/abi-x86-Clang.cmake
index ec79790..f63ed36 100644
--- a/Modules/Platform/Android/abi-x86-Clang.cmake
+++ b/Modules/Platform/Android/abi-x86-Clang.cmake
@@ -1,3 +1,8 @@
# <ndk>/build/core/toolchains/x86-clang/setup.mk
set(_ANDROID_ABI_CLANG_TARGET "i686-none-linux-android")
+
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -fPIC"
+ )
+
include(Platform/Android/abi-common-Clang)
diff --git a/Modules/Platform/Android/abi-x86_64-Clang.cmake b/Modules/Platform/Android/abi-x86_64-Clang.cmake
index dd386bf..c15042b 100644
--- a/Modules/Platform/Android/abi-x86_64-Clang.cmake
+++ b/Modules/Platform/Android/abi-x86_64-Clang.cmake
@@ -1,3 +1,8 @@
# <ndk>/build/core/toolchains/x86_64-clang/setup.mk
set(_ANDROID_ABI_CLANG_TARGET "x86_64-none-linux-android")
+
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -fPIC"
+ )
+
include(Platform/Android/abi-common-Clang)