summaryrefslogtreecommitdiff
path: root/Modules/Platform
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-06-02 14:46:49 -0400
committerBrad King <brad.king@kitware.com>2016-08-12 10:40:52 -0400
commit328191f65f7fb58ece6f749fbfc3462539c7afc1 (patch)
tree52d27eea0503cc9c9cca6a48ca39dbbf98ee7151 /Modules/Platform
parent9e032304ea4133dd6c59b2c0f3b686d4a7aac2a5 (diff)
downloadcmake-328191f65f7fb58ece6f749fbfc3462539c7afc1.tar.gz
Android: Set CMAKE_SYSROOT automatically
Compute CMAKE_SYSROOT automatically for the current API and architecture selection. This causes the --sysroot option to be passed to GNU and Clang compilers.
Diffstat (limited to 'Modules/Platform')
-rw-r--r--Modules/Platform/Android-Initialize.cmake19
1 files changed, 19 insertions, 0 deletions
diff --git a/Modules/Platform/Android-Initialize.cmake b/Modules/Platform/Android-Initialize.cmake
index f12b796a1e..f05357cbb7 100644
--- a/Modules/Platform/Android-Initialize.cmake
+++ b/Modules/Platform/Android-Initialize.cmake
@@ -20,3 +20,22 @@
if(CMAKE_VS_PLATFORM_NAME STREQUAL "Tegra-Android")
return()
endif()
+
+if(NOT CMAKE_SYSROOT)
+ if(CMAKE_ANDROID_NDK)
+ set(CMAKE_SYSROOT "${CMAKE_ANDROID_NDK}/platforms/android-${CMAKE_SYSTEM_VERSION}/arch-${CMAKE_ANDROID_ARCH}")
+ endif()
+endif()
+
+if(CMAKE_SYSROOT)
+ if(NOT IS_DIRECTORY "${CMAKE_SYSROOT}")
+ message(FATAL_ERROR
+ "Android: The system root directory needed for the selected Android version and architecture does not exist:\n"
+ " ${CMAKE_SYSROOT}\n"
+ )
+ endif()
+else()
+ message(FATAL_ERROR
+ "Android: No CMAKE_SYSROOT was selected."
+ )
+endif()