Closed Petross404 closed 5 years ago
The following snippet works but I think it's not elegant :
# Embed the clang header into the binary:
string(REPLACE "svn" "" LLVM_VERSION "${LLVM_VERSION}")
string(REGEX REPLACE "git.*$" "" LLVM_VERSION "${LLVM_VERSION}")
if(NOT CLANG_BUILTIN_HEADERS_DIR)
#Gentoo Linux systems use a different directory layout
if(${CMAKE_BUILD_TYPE} MATCHES "Gentoo")
set(CLANG_BUILTIN_HEADERS_DIR "${LLVM_LIBRARY_DIR}/../include/clang-c")
else()
set(CLANG_BUILTIN_HEADERS_DIR "${LLVM_LIBRARY_DIR}/clang/${LLVM_VERSION}/include")
endif()
endif()
file(GLOB BUILTINS_HEADERS "${CLANG_BUILTIN_HEADERS_DIR}/*.h")
if(NOT BUILTINS_HEADERS)
message(FATAL_ERROR "Could not find any clang builtins headers in ${CLANG_BUILTIN_HEADERS_DIR}")
endif()
You will notice that I use path/../
. That's because ${LLVM_LIBRARY_DIR}
points to /usr/lib/llvm/7/lib64/
but it's /usr/lib/llvm/7/
that contains a directory named include
. Any idea to do this better?
EDIT: Further info from bash :
$pwd ; ls include/clang-c/
/usr/lib/llvm/7
BuildSystem.h CXErrorCode.h Documentation.h Platform.h
CXCompilationDatabase.h CXString.h Index.h
What i'm trying to find here is not the libclang header, but the builtins header that need to be there for compilation. It is includes such as: inttypes.h avx2intrin.h stdarg.h stddef.h x86intrin.h ...
They are usually found in ../lib/clang/x.x/include , relative to the clang binary. Maybe then the cmake script should try to find the clang binary location, or find these particular headers
$ ls /usr/lib/clang/7.0.1/
include lib share
Yes you are right, I will re-adjust my patch. Thank you.
I get the following output when I try to compile moc-ng with portage :
And
CMakeLists.txt
is right because there is no such directory as/usr/lib/llvm/7/lib64/clang/7.0.1/include
on my Gentoo system.All there is under
/usr/lib/llvm
is this. It's a tree-representation of 5, 6 and 7th version of llvm/clang that are installed for me. Check under 7/ at Line 4021I can create a patch but I will have to know what header files is cmake looking for so I can locate them correctly.
Thanks ;)