Commit 2e1fcb89 authored by Kevin Funk's avatar Kevin Funk
Browse files

Also detect llvm-config from build tree

parent 8bb6a41a
......@@ -18,7 +18,7 @@ macro_log_feature(CLANG_FOUND "libclang" "LibClang is a high level C interface t
add_definitions(${LLVM_CFLAGS})
include_directories(
${LLVM_INCLUDE_DIR}
${CLANG_INCLUDE_DIR}
)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
......
# Detect Clang libraries
#
# Defines the following variables:
# CLANG_FOUND - True if Clang was found
# CLANG_INCLUDE_DIR - Where to find Clang includes
# CLANG_LIBRARY_DIR - Where to find Clang libraries
#
# CLANG_CLANG_LIB - LibClang library
# CLANG_CLANGFRONTEND_LIB - Clang Frontend Library
# CLANG_CLANGDRIVER_LIB - Clang Driver Library
......@@ -19,6 +23,7 @@
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
find_package(LLVM ${Clang_FIND_VERSION} ${Clang_FIND_REQUIRED})
......@@ -28,7 +33,7 @@ set(CLANG_FOUND FALSE)
if (LLVM_FOUND AND LLVM_LIBRARY_DIR)
macro(FIND_AND_ADD_CLANG_LIB _libname_)
string(TOUPPER ${_libname_} _prettylibname_)
find_library(CLANG_${_prettylibname_}_LIB ${_libname_} ${LLVM_LIBRARY_DIR} ${CLANG_LIB_DIR})
find_library(CLANG_${_prettylibname_}_LIB ${_libname_} ${LLVM_LIBRARY_DIR})
if(CLANG_${_prettylibname_}_LIB)
set(CLANG_LIBS ${CLANG_LIBS} ${CLANG_${_prettylibname_}_LIB})
endif()
......@@ -66,8 +71,24 @@ else()
endif()
if(CLANG_FOUND)
message(STATUS "Found Clang: ${LLVM_INCLUDE_DIR}")
message(STATUS " Libraries: ${CLANG_LIBS}")
set(CLANG_LIBRARY_DIR ${LLVM_LIBRARY_DIR})
set(CLANG_INCLUDE_DIR ${LLVM_INCLUDE_DIR})
# check whether llvm-config comes from an install prefix
execute_process(
COMMAND ${LLVM_CONFIG_EXECUTABLE} --src-root
OUTPUT_VARIABLE _llvmSourceRoot
OUTPUT_STRIP_TRAILING_WHITESPACE
)
string(FIND "${LLVM_INCLUDE_DIR}" "${_llvmSourceRoot}" _llvmIsInstalled)
if (NOT _llvmIsInstalled)
message(STATUS "Detected that llvm-config comes from a build-tree, adding includes from source dir")
list(APPEND CLANG_INCLUDE_DIR "${_llvmSourceRoot}/tools/clang/include")
endif()
message(STATUS "Found Clang (LLVM version: ${LLVM_VERSION}")
message(STATUS " Include dirs: ${CLANG_INCLUDE_DIR}")
message(STATUS " Libraries: ${CLANG_LIBS}")
else()
if(Clang_FIND_REQUIRED)
message(FATAL_ERROR "Could NOT find Clang")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment