C++ header dependencies are incorrect with CXX=clang++
$ cat test.cpp
#include <stdlib.h>
void f()
{
}
$ cat CMakeLists.txt
PROJECT(test)
add_library(test test.cpp)
With clang compiler this project is getting rebuilt every time I run make because of the dependence to the C++ version of stdlib.h. The reason seems to be that the dependence is generated as '/include/c++/11.1.0/stdlib.h' instead of '/usr/include/c++/11.1.0/stdlib.h', and that prerequisite is not found. The issue goes away if I do any of the following:
- build with gcc;
- rename test.cpp to test.c;
- change stdlib.h to stdio.h (there is no C++ version of stdio.h);
- downgrade to cmake 3.19.6 (but it doesn't seem to record any system C++ header deps).