check_include_file_cxx() does not work with LLVM 4.0 include files
The check_include_file_cxx() macro attempts to link the resulting program, which results in all header checks for LLVM 4.0 failing. For example, the following bit:
check_include_file_cxx("llvm/IR/DataLayout.h" HAVE_IR_DATALAYOUT_H)
fails with the following error (in CMakeError.log):
Determining if the include file llvm/IR/DataLayout.h exists failed with the following output:
Change Dir: /tmp/lightspark/_build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/gmake" "cmTC_cd252/fast"
/usr/bin/gmake -f CMakeFiles/cmTC_cd252.dir/build.make CMakeFiles/cmTC_cd252.dir/build
gmake[1]: Entering directory '/tmp/lightspark/_build/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_cd252.dir/CheckIncludeFile.cxx.o
/usr/bin/c++ -D__STDC_CONSTANT_MACROS=1 -D__STDC_LIMIT_MACROS=1 -std=c++11 -o CMakeFiles/cmTC_cd252.dir/CheckIncludeFile.cxx.o -c /tmp/lightspark/_build/CMakeFiles/CMakeTmp/CheckIncludeFile.cxx
Linking CXX executable cmTC_cd252
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_cd252.dir/link.txt --verbose=1
/usr/bin/c++ CMakeFiles/cmTC_cd252.dir/CheckIncludeFile.cxx.o -o cmTC_cd252 -rdynamic
CMakeFiles/cmTC_cd252.dir/CheckIncludeFile.cxx.o:(.data+0x0): undefined reference to `llvm::DisableABIBreakingChecks'
collect2: error: ld returned 1 exit status
gmake[1]: *** [CMakeFiles/cmTC_cd252.dir/build.make:98: cmTC_cd252] Error 1
gmake[1]: Leaving directory '/tmp/lightspark/_build/CMakeFiles/CMakeTmp'
gmake: *** [Makefile:126: cmTC_cd252/fast] Error 2
The reason for this is probably this bit from the include file:
extern int DisableABIBreakingChecks;
__attribute__((weak, visibility ("hidden"))) int *VerifyDisableABIBreakingChecks = &DisableABIBreakingChecks;
This is cmake 3.7.2 on Gentoo Linux amd64, with LLVM 4.0.0.rc1 installed.