Updates will be applied April 15th at 12pm EDT (UTC-0400). GitLab could be a little slow between 12 - 12:45pm EDT.

Commit 1ee0ffab authored by Brad King's avatar Brad King

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
parent 1806e011
Pipeline #43759 passed with stage
......@@ -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()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment