summaryrefslogtreecommitdiffstats
path: root/Modules/Platform/Android-Common.cmake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-01-20 20:45:09 (GMT)
committerBrad King <brad.king@kitware.com>2017-01-20 20:45:09 (GMT)
commit1ee0ffab819d632d7570bee23a83807facbb45a2 (patch)
treed3171b3b6838c2d8f303957fe2c3a2d811da2c92 /Modules/Platform/Android-Common.cmake
parent1806e011cb2608c7ef62f345661dd35a899eb81c (diff)
downloadCMake-1ee0ffab819d632d7570bee23a83807facbb45a2.zip
CMake-1ee0ffab819d632d7570bee23a83807facbb45a2.tar.gz
CMake-1ee0ffab819d632d7570bee23a83807facbb45a2.tar.bz2
Android: Pass sysroot include directory explicitly
The NDK's `build/core/definitions.mk` file adds compiler flags: -isystem $$(call host-path,$$(SYSROOT_INC)/usr/include) This passes the system include directory explicitly even though it is implied by `--sysroot=`. The explicit flag places the directory earlier in the include path than the sysroot-default one would be. Teach CMake to add this include directory at the end of the standard include path for Android. Otherwise the toolchain's `include-fixed/` directory may replace system headers with "fixed" copies that are not from the same API version. Closes: #16536
Diffstat (limited to 'Modules/Platform/Android-Common.cmake')
-rw-r--r--Modules/Platform/Android-Common.cmake9
1 files changed, 9 insertions, 0 deletions
diff --git a/Modules/Platform/Android-Common.cmake b/Modules/Platform/Android-Common.cmake
index 8755d4f..cf2785a 100644
--- a/Modules/Platform/Android-Common.cmake
+++ b/Modules/Platform/Android-Common.cmake
@@ -149,4 +149,13 @@ macro(__android_compiler_common lang)
if("x${lang}" STREQUAL "xCXX")
__android_stl(CXX)
endif()
+
+ # <ndk>/build/core/definitions.mk appends the sysroot's include directory
+ # explicitly at the end of the command-line include path so that it
+ # precedes the toolchain's builtin include directories. This is
+ # necessary so that Android API-version-specific headers are preferred
+ # over those in the toolchain's `include-fixed` directory (which cannot
+ # possibly match all versions).
+ list(APPEND CMAKE_${lang}_STANDARD_INCLUDE_DIRECTORIES "${CMAKE_SYSROOT}/usr/include")
+ list(REMOVE_ITEM CMAKE_${lang}_IMPLICIT_INCLUDE_DIRECTORIES "/usr/include")
endmacro()