summaryrefslogtreecommitdiffstats
path: root/Modules/Platform
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-11-09 12:58:39 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-11-09 12:58:49 (GMT)
commitd0391599a85b41cb94b6785bfcd29db8021a2052 (patch)
treec14b0a688da09adf4e9e1075aa6c0ffc18ca4ee6 /Modules/Platform
parenteb488595940f382d8b776c147604ea7cd1690590 (diff)
parent94d87afece666aeb0b062de7d50490495a533980 (diff)
downloadCMake-d0391599a85b41cb94b6785bfcd29db8021a2052.zip
CMake-d0391599a85b41cb94b6785bfcd29db8021a2052.tar.gz
CMake-d0391599a85b41cb94b6785bfcd29db8021a2052.tar.bz2
Merge topic 'android-flags'
94d87afece Android: allow NDK to control cflags / ldflags 85e5139aba Android: Move *_LLVM_TRIPLE to the centralized table Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !5461
Diffstat (limited to 'Modules/Platform')
-rw-r--r--Modules/Platform/Android-Clang.cmake36
-rw-r--r--Modules/Platform/Android-Determine.cmake59
-rw-r--r--Modules/Platform/Android/abi-arm64-v8a-Clang.cmake3
-rw-r--r--Modules/Platform/Android/abi-armeabi-Clang.cmake3
-rw-r--r--Modules/Platform/Android/abi-armeabi-v6-Clang.cmake3
-rw-r--r--Modules/Platform/Android/abi-armeabi-v7a-Clang.cmake3
-rw-r--r--Modules/Platform/Android/abi-mips-Clang.cmake3
-rw-r--r--Modules/Platform/Android/abi-mips64-Clang.cmake3
-rw-r--r--Modules/Platform/Android/abi-x86-Clang.cmake3
-rw-r--r--Modules/Platform/Android/abi-x86_64-Clang.cmake3
10 files changed, 63 insertions, 56 deletions
diff --git a/Modules/Platform/Android-Clang.cmake b/Modules/Platform/Android-Clang.cmake
index 44d48cd..3a279ca 100644
--- a/Modules/Platform/Android-Clang.cmake
+++ b/Modules/Platform/Android-Clang.cmake
@@ -13,6 +13,17 @@ if(CMAKE_ANDROID_NDK)
include(${CMAKE_ANDROID_NDK}/build/cmake/hooks/pre/Android-Clang.cmake OPTIONAL)
endif()
+# Load flags from NDK. This file may provides the following variables:
+# _ANDROID_NDK_INIT_CFLAGS
+# _ANDROID_NDK_INIT_CFLAGS_DEBUG
+# _ANDROID_NDK_INIT_CFLAGS_RELEASE
+# _ANDROID_NDK_INIT_LDFLAGS
+# _ANDROID_NDK_INIT_LDFLAGS_EXE
+if(CMAKE_ANDROID_NDK)
+ include(${CMAKE_ANDROID_NDK}/build/cmake/flags.cmake OPTIONAL
+ RESULT_VARIABLE _INCLUDED_FLAGS)
+endif()
+
# Support for NVIDIA Nsight Tegra Visual Studio Edition was previously
# implemented in the CMake VS IDE generators. Avoid interfering with
# that functionality for now. Later we may try to integrate this.
@@ -40,20 +51,29 @@ endif()
include(Platform/Android-Common)
-# The NDK toolchain configuration files at:
-#
-# <ndk>/[build/core/]toolchains/*-clang*/setup.mk
-#
-# contain logic to set LLVM_TRIPLE for Clang-based toolchains for each target.
-# We need to produce the same target here to produce compatible binaries.
-include(Platform/Android/abi-${CMAKE_ANDROID_ARCH_ABI}-Clang)
+if(_INCLUDED_FLAGS)
+ # NDK provides the flags.
+ set(_ANDROID_ABI_INIT_CFLAGS "${_ANDROID_NDK_INIT_CFLAGS}")
+ set(_ANDROID_ABI_INIT_CFLAGS_DEBUG "${_ANDROID_NDK_INIT_CFLAGS_DEBUG}")
+ set(_ANDROID_ABI_INIT_CFLAGS_RELEASE "${_ANDROID_NDK_INIT_CFLAGS_RELEASE}")
+ set(_ANDROID_ABI_INIT_LDFLAGS "${_ANDROID_NDK_INIT_LDFLAGS}")
+ set(_ANDROID_ABI_INIT_EXE_LDFLAGS "${_ANDROID_NDK_INIT_LDFLAGS_EXE}")
+else()
+ # The NDK toolchain configuration files at:
+ #
+ # <ndk>/[build/core/]toolchains/*-clang*/setup.mk
+ #
+ # contain logic to set LLVM_TRIPLE for Clang-based toolchains for each target.
+ # We need to produce the same target here to produce compatible binaries.
+ include(Platform/Android/abi-${CMAKE_ANDROID_ARCH_ABI}-Clang)
+endif()
macro(__android_compiler_clang lang)
if(NOT "x${lang}" STREQUAL "xASM")
__android_compiler_common(${lang})
endif()
if(NOT CMAKE_${lang}_COMPILER_TARGET)
- set(CMAKE_${lang}_COMPILER_TARGET "${_ANDROID_ABI_CLANG_TARGET}")
+ set(CMAKE_${lang}_COMPILER_TARGET "${CMAKE_ANDROID_ARCH_LLVM_TRIPLE}")
if(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED)
string(APPEND CMAKE_${lang}_COMPILER_TARGET "${CMAKE_SYSTEM_VERSION}")
endif()
diff --git a/Modules/Platform/Android-Determine.cmake b/Modules/Platform/Android-Determine.cmake
index 3206c83..2c906ae 100644
--- a/Modules/Platform/Android-Determine.cmake
+++ b/Modules/Platform/Android-Determine.cmake
@@ -249,30 +249,38 @@ endif()
# https://developer.android.com/ndk/guides/abis.html
-set(_ANDROID_ABI_arm64-v8a_PROC "aarch64")
-set(_ANDROID_ABI_arm64-v8a_ARCH "arm64")
-set(_ANDROID_ABI_arm64-v8a_TRIPLE "aarch64-linux-android")
-set(_ANDROID_ABI_armeabi-v7a_PROC "armv7-a")
-set(_ANDROID_ABI_armeabi-v7a_ARCH "arm")
-set(_ANDROID_ABI_armeabi-v7a_TRIPLE "arm-linux-androideabi")
-set(_ANDROID_ABI_armeabi-v6_PROC "armv6")
-set(_ANDROID_ABI_armeabi-v6_ARCH "arm")
-set(_ANDROID_ABI_armeabi-v6_TRIPLE "arm-linux-androideabi")
-set(_ANDROID_ABI_armeabi_PROC "armv5te")
-set(_ANDROID_ABI_armeabi_ARCH "arm")
-set(_ANDROID_ABI_armeabi_TRIPLE "arm-linux-androideabi")
-set(_ANDROID_ABI_mips_PROC "mips")
-set(_ANDROID_ABI_mips_ARCH "mips")
-set(_ANDROID_ABI_mips_TRIPLE "mipsel-linux-android")
-set(_ANDROID_ABI_mips64_PROC "mips64")
-set(_ANDROID_ABI_mips64_ARCH "mips64")
-set(_ANDROID_ABI_mips64_TRIPLE "mips64el-linux-android")
-set(_ANDROID_ABI_x86_PROC "i686")
-set(_ANDROID_ABI_x86_ARCH "x86")
-set(_ANDROID_ABI_x86_TRIPLE "i686-linux-android")
-set(_ANDROID_ABI_x86_64_PROC "x86_64")
-set(_ANDROID_ABI_x86_64_ARCH "x86_64")
-set(_ANDROID_ABI_x86_64_TRIPLE "x86_64-linux-android")
+set(_ANDROID_ABI_arm64-v8a_PROC "aarch64")
+set(_ANDROID_ABI_arm64-v8a_ARCH "arm64")
+set(_ANDROID_ABI_arm64-v8a_TRIPLE "aarch64-linux-android")
+set(_ANDROID_ABI_arm64-v8a_LLVM_TRIPLE "aarch64-none-linux-android")
+set(_ANDROID_ABI_armeabi-v7a_PROC "armv7-a")
+set(_ANDROID_ABI_armeabi-v7a_ARCH "arm")
+set(_ANDROID_ABI_armeabi-v7a_TRIPLE "arm-linux-androideabi")
+set(_ANDROID_ABI_armeabi-v7a_LLVM_TRIPLE "armv7-none-linux-androideabi")
+set(_ANDROID_ABI_armeabi-v6_PROC "armv6")
+set(_ANDROID_ABI_armeabi-v6_ARCH "arm")
+set(_ANDROID_ABI_armeabi-v6_TRIPLE "arm-linux-androideabi")
+set(_ANDROID_ABI_armeabi-v6_LLVM_TRIPLE "armv6-none-linux-androideabi")
+set(_ANDROID_ABI_armeabi_PROC "armv5te")
+set(_ANDROID_ABI_armeabi_ARCH "arm")
+set(_ANDROID_ABI_armeabi_TRIPLE "arm-linux-androideabi")
+set(_ANDROID_ABI_armeabi_LLVM_TRIPLE "armv5te-none-linux-androideabi")
+set(_ANDROID_ABI_mips_PROC "mips")
+set(_ANDROID_ABI_mips_ARCH "mips")
+set(_ANDROID_ABI_mips_TRIPLE "mipsel-linux-android")
+set(_ANDROID_ABI_mips_LLVM_TRIPLE "mipsel-none-linux-android")
+set(_ANDROID_ABI_mips64_PROC "mips64")
+set(_ANDROID_ABI_mips64_ARCH "mips64")
+set(_ANDROID_ABI_mips64_TRIPLE "mips64el-linux-android")
+set(_ANDROID_ABI_mips64_LLVM_TRIPLE "mips64el-none-linux-android")
+set(_ANDROID_ABI_x86_PROC "i686")
+set(_ANDROID_ABI_x86_ARCH "x86")
+set(_ANDROID_ABI_x86_TRIPLE "i686-linux-android")
+set(_ANDROID_ABI_x86_LLVM_TRIPLE "i686-none-linux-android")
+set(_ANDROID_ABI_x86_64_PROC "x86_64")
+set(_ANDROID_ABI_x86_64_ARCH "x86_64")
+set(_ANDROID_ABI_x86_64_TRIPLE "x86_64-linux-android")
+set(_ANDROID_ABI_x86_64_LLVM_TRIPLE "x86_64-none-linux-android")
set(_ANDROID_PROC_aarch64_ARCH_ABI "arm64-v8a")
set(_ANDROID_PROC_armv7-a_ARCH_ABI "armeabi-v7a")
@@ -374,6 +382,8 @@ if(_ANDROID_SYSROOT_ARCH AND NOT "x${_ANDROID_SYSROOT_ARCH}" STREQUAL "x${CMAKE_
)
endif()
set(CMAKE_ANDROID_ARCH_TRIPLE "${_ANDROID_ABI_${CMAKE_ANDROID_ARCH_ABI}_TRIPLE}")
+set(CMAKE_ANDROID_ARCH_LLVM_TRIPLE
+ "${_ANDROID_ABI_${CMAKE_ANDROID_ARCH_ABI}_LLVM_TRIPLE}")
# Select a processor.
if(NOT CMAKE_SYSTEM_PROCESSOR)
@@ -488,6 +498,7 @@ set(CMAKE_ANDROID_ARCH_ABI \"${CMAKE_ANDROID_ARCH_ABI}\")
if(CMAKE_ANDROID_NDK)
string(APPEND CMAKE_SYSTEM_CUSTOM_CODE
"set(CMAKE_ANDROID_ARCH_TRIPLE \"${CMAKE_ANDROID_ARCH_TRIPLE}\")\n"
+ "set(CMAKE_ANDROID_ARCH_LLVM_TRIPLE \"${CMAKE_ANDROID_ARCH_LLVM_TRIPLE}\")\n"
"set(CMAKE_ANDROID_NDK_DEPRECATED_HEADERS \"${CMAKE_ANDROID_NDK_DEPRECATED_HEADERS}\")\n"
"set(CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG \"${CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG}\")\n"
"set(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED \"${CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED}\")\n"
diff --git a/Modules/Platform/Android/abi-arm64-v8a-Clang.cmake b/Modules/Platform/Android/abi-arm64-v8a-Clang.cmake
index f4717d5..c18c0a2 100644
--- a/Modules/Platform/Android/abi-arm64-v8a-Clang.cmake
+++ b/Modules/Platform/Android/abi-arm64-v8a-Clang.cmake
@@ -1,6 +1,3 @@
-# <ndk>/build/core/toolchains/aarch64-linux-android-clang/setup.mk
-set(_ANDROID_ABI_CLANG_TARGET "aarch64-none-linux-android")
-
# Suppress -Wl,-z,nocopyreloc flag on arm64-v8a
set(_ANDROID_ABI_INIT_EXE_LDFLAGS_NO_nocopyreloc 1)
diff --git a/Modules/Platform/Android/abi-armeabi-Clang.cmake b/Modules/Platform/Android/abi-armeabi-Clang.cmake
index b857bd3..2b1de03 100644
--- a/Modules/Platform/Android/abi-armeabi-Clang.cmake
+++ b/Modules/Platform/Android/abi-armeabi-Clang.cmake
@@ -1,6 +1,3 @@
-# <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"
)
diff --git a/Modules/Platform/Android/abi-armeabi-v6-Clang.cmake b/Modules/Platform/Android/abi-armeabi-v6-Clang.cmake
index a7412f5..bb176ae 100644
--- a/Modules/Platform/Android/abi-armeabi-v6-Clang.cmake
+++ b/Modules/Platform/Android/abi-armeabi-v6-Clang.cmake
@@ -1,6 +1,3 @@
-# <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"
)
diff --git a/Modules/Platform/Android/abi-armeabi-v7a-Clang.cmake b/Modules/Platform/Android/abi-armeabi-v7a-Clang.cmake
index e2ab58b..6feeef6 100644
--- a/Modules/Platform/Android/abi-armeabi-v7a-Clang.cmake
+++ b/Modules/Platform/Android/abi-armeabi-v7a-Clang.cmake
@@ -1,6 +1,3 @@
-# <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"
)
diff --git a/Modules/Platform/Android/abi-mips-Clang.cmake b/Modules/Platform/Android/abi-mips-Clang.cmake
index 73addde..7df6a36 100644
--- a/Modules/Platform/Android/abi-mips-Clang.cmake
+++ b/Modules/Platform/Android/abi-mips-Clang.cmake
@@ -1,4 +1 @@
-# <ndk>/build/core/toolchains/mipsel-linux-android-clang/setup.mk
-set(_ANDROID_ABI_CLANG_TARGET "mipsel-none-linux-android")
-
include(Platform/Android/abi-common-Clang)
diff --git a/Modules/Platform/Android/abi-mips64-Clang.cmake b/Modules/Platform/Android/abi-mips64-Clang.cmake
index 603f1b2..7df6a36 100644
--- a/Modules/Platform/Android/abi-mips64-Clang.cmake
+++ b/Modules/Platform/Android/abi-mips64-Clang.cmake
@@ -1,4 +1 @@
-# <ndk>/build/core/toolchains/mips64el-linux-android-clang/setup.mk
-set(_ANDROID_ABI_CLANG_TARGET "mips64el-none-linux-android")
-
include(Platform/Android/abi-common-Clang)
diff --git a/Modules/Platform/Android/abi-x86-Clang.cmake b/Modules/Platform/Android/abi-x86-Clang.cmake
index fe7eace..7df6a36 100644
--- a/Modules/Platform/Android/abi-x86-Clang.cmake
+++ b/Modules/Platform/Android/abi-x86-Clang.cmake
@@ -1,4 +1 @@
-# <ndk>/build/core/toolchains/x86-clang/setup.mk
-set(_ANDROID_ABI_CLANG_TARGET "i686-none-linux-android")
-
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 3cbcd49..7df6a36 100644
--- a/Modules/Platform/Android/abi-x86_64-Clang.cmake
+++ b/Modules/Platform/Android/abi-x86_64-Clang.cmake
@@ -1,4 +1 @@
-# <ndk>/build/core/toolchains/x86_64-clang/setup.mk
-set(_ANDROID_ABI_CLANG_TARGET "x86_64-none-linux-android")
-
include(Platform/Android/abi-common-Clang)