Fix more regressions in legacy implicit include directories
Prefix only hard-coded implicit include directories with the sysroot
Since commit 7cd65c97 we have prefixed the value of
CMAKE_SYSROOTto implicit include directories. This was done because we hard-coded
/usr/includeas an implicit include directory by without accounting for the sysroot. Likely that original commit should have updated the hard-coded paths in the
UnixPathsmodule to use
Since !2716 (merged) the values of the
CMAKE_<LANG>_IMPLICIT_INCLUDE_DIRECTORIESvariables are computed from a real compiler invocation so they already account for the sysroot prefix. In !2957 (merged) we attempted to apply the prefix conditionally, but that is incorrect because the compiler's real implicit include directories are not all under the sysroot. Instead we will have to simply assume that all implicit include directories in
CMAKE_<LANG>_IMPLICIT_INCLUDE_DIRECTORIESalready have the sysroot prefix if needed. Code that constructs the value must be responsible for that because it is the only place that knows.
Update our current hard-coded addition of
/usr/includeto the implicit include directories to account for
CMAKE_SYSROOTas we argue above should have been done originally in
Restore unconditional use of "standard" include directories
CMAKE_<LANG>_STANDARD_INCLUDE_DIRECTORIESis meant to unconditionally add explicitly specified include directories to compile lines. In commit !2864 (merged) a condition was accidentally added to exclude implicit include directories. Drop that condition.
Do not explicitly report "standard" include directories as implicit
In !2716 (merged) we did not account for
CMAKE_<LANG>_STANDARD_INCLUDE_DIRECTORIES. This variable lets platform modules or toolchain files specify directories that are to be explicitly passed as standard include directories. These include directories are used by the test project from which we extract implicit include directories so they appear in the parsed results whether or not the compiler really considers them implicit. Exclude these entries from the computed implicit include directories since they are not actually implied by the compiler when we invoke it with "standard" include directories passed explicitly.
Instead teach the build system generators to treat the "standard" directories as implicit for purposes of excluding them from appearing earlier in the compiler command line due to