summaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-02-22 15:39:39 (GMT)
committerBrad King <brad.king@kitware.com>2018-02-22 15:44:07 (GMT)
commitdd2ca8bdb6025e4334ba935cddfa365b224c55ec (patch)
tree8ab8474b518165dac44b298e636593b3f1b7fce8 /CMakeLists.txt
parentedc85d8f17bf2f6054bbaa52e9b2d1911baf6f39 (diff)
downloadCastXML-dd2ca8bdb6025e4334ba935cddfa365b224c55ec.zip
CastXML-dd2ca8bdb6025e4334ba935cddfa365b224c55ec.tar.gz
CastXML-dd2ca8bdb6025e4334ba935cddfa365b224c55ec.tar.bz2
Search for Clang resources in a clang/ sibling of llvm/
Some distros package LLVM and Clang resources separately with a layout of the form <prefix>/lib/llvm/<major-version>/lib <prefix>/lib/clang/<full-version>/include Update our search for `CLANG_RESOURCE_DIR` to support this. Suggested-by: Gert Wollny <gw.fossdev@gmail.com>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt12
1 files changed, 12 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b0fa7d6..6fe0425 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -137,7 +137,19 @@ set(CLANG_RESOURCE_DIR "" CACHE PATH "Clang resource directory")
if(NOT CLANG_RESOURCE_DIR)
set(v ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH})
set(tried "")
+ set(dirs "")
foreach(d ${LLVM_LIBRARY_DIRS})
+ # Clang resources are typically inside LLVM's library directory.
+ list(APPEND dirs ${d})
+ # Some distros use a layout of the form
+ # <prefix>/lib/llvm/<major-version>/lib
+ # <prefix>/lib/clang/<full-version>/include
+ if("${d}" MATCHES "^(.*)/llvm/.*$")
+ list(APPEND dirs "${CMAKE_MATCH_1}")
+ endif()
+ endforeach()
+ # Look in each candidate directory for Clang resources.
+ foreach(d ${dirs})
if(IS_DIRECTORY "${d}/clang/${v}/include")
set(CLANG_RESOURCE_DIR ${d}/clang/${v})
break()