diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2018-05-07 16:29:29 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2018-05-08 08:27:51 +0000 |
commit | 7fd609e76fd9eef35b0d1f208ea2bf36ad4fc691 (patch) | |
tree | ab70ffa214123adb5fed6cadc504b197645ef783 /sources | |
parent | 91cbb903ac899c9b5ff2184e644c677a56b029db (diff) |
Improve libclang extra include headers detection
On certain distros (e.g. ArchLinux) there may be additional files in
the path where we GLOB for clang version include folders
(e.g. /usr/lib/llvm/lib/clang/6.0.0 and
/usr/lib/llvm/lib/clang/ccc-analyzer).
Filter the files out, and only consider folders starting with a
number (e.g. 6.0.0).
Change-Id: I85052e45610090f399ec92200f7a666c4872f78d
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources')
-rw-r--r-- | sources/shiboken2/CMakeLists.txt | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/sources/shiboken2/CMakeLists.txt b/sources/shiboken2/CMakeLists.txt index 513c4ed7e..3efc6fefe 100644 --- a/sources/shiboken2/CMakeLists.txt +++ b/sources/shiboken2/CMakeLists.txt @@ -115,7 +115,16 @@ message(STATUS "CLANG: ${CLANG_DIR}, ${CLANG_LIBRARY} detected by ${CLANG_DIR_SO # Find highest version clang builtin includes folder to pass along to shiboken. set(CLANG_BUILTIN_INCLUDES_DIR_PREFIX ${CLANG_DIR}/lib/clang) -file(GLOB CLANG_BUILTIN_INCLUDES_DIR_VERSIONS "${CLANG_BUILTIN_INCLUDES_DIR_PREFIX}/*") +file(GLOB CLANG_BUILTIN_INCLUDES_DIR_CANDIDATES "${CLANG_BUILTIN_INCLUDES_DIR_PREFIX}/*") + +# Collect only directories, and not files, and only directories starting with a number. +set(CLANG_BUILTIN_INCLUDES_DIR_VERSIONS "") +foreach(candidate ${CLANG_BUILTIN_INCLUDES_DIR_CANDIDATES}) + get_filename_component(candidate_basename ${candidate} NAME) + if (IS_DIRECTORY ${candidate} AND ${candidate_basename} MATCHES "^[0-9]") # starts with number + list(APPEND CLANG_BUILTIN_INCLUDES_DIR_VERSIONS ${candidate}) + endif() +endforeach() # Sort in alphabetical order the list of version folders. list(SORT CLANG_BUILTIN_INCLUDES_DIR_VERSIONS) @@ -123,7 +132,9 @@ list(SORT CLANG_BUILTIN_INCLUDES_DIR_VERSIONS) # Reverse it so the first element is the highest version. list(REVERSE CLANG_BUILTIN_INCLUDES_DIR_VERSIONS) -message(STATUS "Found the following CLANG builtins includes directories: ${CLANG_BUILTIN_INCLUDES_DIR_VERSIONS}") +message(STATUS + "Found the following CLANG builtins includes directories: ${CLANG_BUILTIN_INCLUDES_DIR_VERSIONS} \ + Considered the following directories: ${CLANG_BUILTIN_INCLUDES_DIR_CANDIDATES}") if(CLANG_BUILTIN_INCLUDES_DIR_VERSIONS) # Get highest version. list(GET CLANG_BUILTIN_INCLUDES_DIR_VERSIONS 0 CLANG_BUILTIN_INCLUDES_DIR_HIGHEST_VERSION) @@ -132,8 +143,16 @@ if(CLANG_BUILTIN_INCLUDES_DIR_VERSIONS) set(CLANG_BUILTIN_INCLUDES_DIR "${CLANG_BUILTIN_INCLUDES_DIR_HIGHEST_VERSION}/include") endif() endif() + message(STATUS "CLANG builtins includes directory chosen: ${CLANG_BUILTIN_INCLUDES_DIR}") +# We don't exit with a hard error here, because it is uncertain whether all clang extra include +# paths follow the same layout across OSes and distros. +if (NOT CLANG_BUILTIN_INCLUDES_DIR) + message(WARNING "No CLANG builtins includes directory found. This may lead to shiboken \ + execution failure.") +endif() + set(CLANG_EXTRA_INCLUDES ${CLANG_DIR}/include) set(CLANG_EXTRA_LIBRARIES ${CLANG_LIBRARY}) |