diff options
author | Rebecca Palmer <rebecca_palmer@zoho.com> | 2015-03-24 14:46:18 +0800 |
---|---|---|
committer | Zhigang Gong <zhigang.gong@intel.com> | 2015-03-24 15:00:19 +0800 |
commit | fea74f7a6cb740789c556f4c45e8d60126f18060 (patch) | |
tree | 8fbcf708058d0416627f8021d7995ec0cd95453b /CMake | |
parent | c1107238d9afb090cc40fa216ad03d5ab98f8182 (diff) |
Use matching versions of clang/llvm and libclang/libllvm
compile the OpenCL standard library with the same version of clang
as will compile OpenCL user code, not plain "clang" (i.e. the
system default version, which may be different).
Signed-off-by: Rebecca Palmer <rebecca_palmer@zoho.com>
Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Diffstat (limited to 'CMake')
-rw-r--r-- | CMake/FindLLVM.cmake | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/CMake/FindLLVM.cmake b/CMake/FindLLVM.cmake index e214437a..01bf1c72 100644 --- a/CMake/FindLLVM.cmake +++ b/CMake/FindLLVM.cmake @@ -22,14 +22,16 @@ if (LLVM_CONFIG_EXECUTABLE) else (LLVM_CONFIG_EXECUTABLE) message(FATAL_ERROR "Could NOT find LLVM executable, please add -DLLVM_INSTALL_DIR=/path/to/llvm-config/ in cmake command") endif (LLVM_CONFIG_EXECUTABLE) +execute_process( + COMMAND ${LLVM_CONFIG_EXECUTABLE} --version + OUTPUT_VARIABLE LLVM_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE +) +string(REGEX REPLACE "([0-9])\\.([0-9]*).*" "\\1\\2" LLVM_VERSION_NODOT ${LLVM_VERSION}) +string(REGEX REPLACE "([0-9])\\.([0-9]*).*" "\\1.\\2" LLVM_VERSION_NOPATCH ${LLVM_VERSION}) if (LLVM_FIND_VERSION_MAJOR AND LLVM_FIND_VERSION_MINOR) SET(LLVM_FIND_VERSION_NODOT "${LLVM_FIND_VERSION_MAJOR}${LLVM_FIND_VERSION_MINOR}") - execute_process( - COMMAND ${LLVM_CONFIG_EXECUTABLE} --version - OUTPUT_VARIABLE LLVM_VERSION - ) - string(REGEX REPLACE "([0-9])\\.([0-9]*).*" "\\1\\2 " LLVM_VERSION_NODOT ${LLVM_VERSION}) if (LLVM_VERSION_NODOT VERSION_LESS LLVM_FIND_VERSION_NODOT) message(FATAL_ERROR "imcompatible LLVM version ${LLVM_VERSION} required ${LLVM_FIND_VERSION}") else (LLVM_VERSION_NODOT VERSION_LESS LLVM_FIND_VERSION_NODOT) @@ -42,6 +44,25 @@ if (LLVM_FIND_VERSION_MAJOR AND LLVM_FIND_VERSION_MINOR) endif (LLVM_VERSION_NODOT VERSION_LESS LLVM_FIND_VERSION_NODOT) endif (LLVM_FIND_VERSION_MAJOR AND LLVM_FIND_VERSION_MINOR) +if (LLVM_INSTALL_DIR) + find_program(CLANG_EXECUTABLE + NAMES clang-${LLVM_VERSION_NODOT} clang-${LLVM_VERSION_NOPATCH} clang + PATHS ${LLVM_INSTALL_DIR} NO_DEFAULT_PATH) + find_program(LLVM_AS_EXECUTABLE + NAMES llvm-as-${LLVM_VERSION_NODOT} llvm-as-${LLVM_VERSION_NOPATCH} llvm-as + PATHS ${LLVM_INSTALL_DIR} NO_DEFAULT_PATH) + find_program(LLVM_LINK_EXECUTABLE + NAMES llvm-link-${LLVM_VERSION_NODOT} llvm-link-${LLVM_VERSION_NOPATCH} llvm-link + PATHS ${LLVM_INSTALL_DIR} NO_DEFAULT_PATH) +else (LLVM_INSTALL_DIR) + find_program(CLANG_EXECUTABLE + NAMES clang-${LLVM_VERSION_NODOT} clang-${LLVM_VERSION_NOPATCH} clang) + find_program(LLVM_AS_EXECUTABLE + NAMES llvm-as-${LLVM_VERSION_NODOT} llvm-as-${LLVM_VERSION_NOPATCH} llvm-as) + find_program(LLVM_LINK_EXECUTABLE + NAMES llvm-link-${LLVM_VERSION_NODOT} llvm-link-${LLVM_VERSION_NOPATCH} llvm-link) +endif (LLVM_INSTALL_DIR) + execute_process( COMMAND ${LLVM_CONFIG_EXECUTABLE} --includedir OUTPUT_VARIABLE LLVM_INCLUDE_DIR |