summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-06-04 16:10:34 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-06-29 12:20:16 +0200
commit8e40388485b2b2bb45fb4104b13395728f312485 (patch)
tree26a210dcdd3c342eecd83759b23b2303ac85416f /cmake
parent896cdd0e28a8dc4e03bb287fea5c71519297886e (diff)
CMake: Use LLVM_INSTALL_DIR env and cache var when looking for clang
For convenience and compatibility with what Coin currently sets, instead of forcing a user to set CMAKE_PREFIX_PATH to point to the llvm dir path (and thus override any previously set path, perhaps by a toolchain file), allow usage of either the LLVM_INSTALL_DIR environment variable or CMake cache variable. Make sure to use the value for CMAKE_FIND_ROOT_PATH as well, in case if doing cross-builds, and the path is not in the sysroot. Change-Id: I6927f14d7f721a018323225f6276a2c388dfcf20 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/FindWrapLibClang.cmake21
1 files changed, 21 insertions, 0 deletions
diff --git a/cmake/FindWrapLibClang.cmake b/cmake/FindWrapLibClang.cmake
index 30be70b66..91133be06 100644
--- a/cmake/FindWrapLibClang.cmake
+++ b/cmake/FindWrapLibClang.cmake
@@ -3,8 +3,29 @@ if(TARGET WrapLibClang::WrapLibClang)
return()
endif()
+if(DEFINED ENV{LLVM_INSTALL_DIR})
+ set(__qt_wrap_clang_backup_prefix "${CMAKE_PREFIX_PATH}")
+ set(__qt_wrap_clang_backup_root_path ${CMAKE_FIND_ROOT_PATH})
+
+ list(PREPEND CMAKE_PREFIX_PATH "$ENV{LLVM_INSTALL_DIR}")
+ list(PREPEND CMAKE_FIND_ROOT_PATH "$ENV{LLVM_INSTALL_DIR}")
+elseif(DEFINED CACHE{LLVM_INSTALL_DIR})
+ set(__qt_wrap_clang_backup_prefix "${CMAKE_PREFIX_PATH}")
+ set(__qt_wrap_clang_backup_root_path ${CMAKE_FIND_ROOT_PATH})
+
+ list(PREPEND CMAKE_PREFIX_PATH "${LLVM_INSTALL_DIR}")
+ list(PREPEND CMAKE_FIND_ROOT_PATH "${LLVM_INSTALL_DIR}")
+endif()
+
find_package(Clang CONFIG)
+if(__qt_wrap_clang_backup_prefix)
+ set(CMAKE_PREFIX_PATH "${__qt_wrap_clang_backup_prefix}")
+ set(CMAKE_FIND_ROOT_PATH "${__qt_wrap_clang_backup_root_path}")
+ unset(__qt_wrap_clang_backup_prefix)
+ unset(__qt_wrap_clang_backup_root_path)
+endif()
+
set(WrapLibClang_FOUND FALSE)
set(__wrap_lib_clang_requested_version_found FALSE)