It's very likely your toolchain has issues if the compiler cannot find a libc header under some conditions.
Anyway, I need to get the actual compilation line used for this, which you could get if you used the CMake Ninja generator automatically or compiled with "make VERBOSE=1".