aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shiboken2/CMakeLists.txt')
-rw-r--r--sources/shiboken2/CMakeLists.txt23
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})