From 68d67c827fceabc22bb0be76f084391659dc9a28 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 3 Aug 2017 12:03:59 -0400 Subject: Android: Fix support for CMAKE_SYSROOT without CMAKE_SYSROOT_COMPILE If `CMAKE_SYSROOT` is set by the user (e.g. via the toolchain file) then we do not set `CMAKE_SYSROOT_COMPILE` to our default. Fix our references to the sysroot's `/usr/include` directory to use `CMAKE_SYSROOT_COMPILE` only if it is set and else `CMAKE_SYSROOT`. Fixes: #17096 --- Modules/Platform/Android-Common.cmake | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Modules/Platform/Android-Common.cmake b/Modules/Platform/Android-Common.cmake index 5faada3..80a8f41 100644 --- a/Modules/Platform/Android-Common.cmake +++ b/Modules/Platform/Android-Common.cmake @@ -160,13 +160,19 @@ macro(__android_compiler_common lang) # Do not do this for a standalone toolchain because it is already # tied to a specific API version. if(CMAKE_ANDROID_NDK) + if(CMAKE_SYSROOT_COMPILE) + set(_cmake_sysroot_compile "${CMAKE_SYSROOT_COMPILE}") + else() + set(_cmake_sysroot_compile "${CMAKE_SYSROOT}") + endif() if(NOT CMAKE_ANDROID_NDK_DEPRECATED_HEADERS) list(APPEND CMAKE_${lang}_STANDARD_INCLUDE_DIRECTORIES - "${CMAKE_SYSROOT_COMPILE}/usr/include" - "${CMAKE_SYSROOT_COMPILE}/usr/include/${CMAKE_ANDROID_ARCH_HEADER_TRIPLE}" + "${_cmake_sysroot_compile}/usr/include" + "${_cmake_sysroot_compile}/usr/include/${CMAKE_ANDROID_ARCH_HEADER_TRIPLE}" ) else() - list(APPEND CMAKE_${lang}_STANDARD_INCLUDE_DIRECTORIES "${CMAKE_SYSROOT}/usr/include") + list(APPEND CMAKE_${lang}_STANDARD_INCLUDE_DIRECTORIES "${_cmake_sysroot_compile}/usr/include") endif() + unset(_cmake_sysroot_compile) endif() endmacro() -- cgit v0.12