FindClang.cmake 1.98 KB
Newer Older
Kevin Funk's avatar
Kevin Funk committed
1
2
3
4
5
6
7
8
9
10
11
12
# Detect Clang libraries
#
# Defines the following variables:
#  CLANG_CLANG_LIB             - LibClang library
#  CLANG_CLANGFRONTEND_LIB     - Clang Frontent Library
#  CLANG_CLANGDRIVER_LIB       - Clang Driver Library
#  ...
#
# Uses the same include and library paths detected by FindLLVM.cmake
#
# See http://clang.llvm.org/docs/InternalsManual.html for full list of libraries

13
if (NOT LLVM_INCLUDE_DIR OR NOT LLVM_LIBRARY_DIR)
Kevin Funk's avatar
Kevin Funk committed
14
15
  message(FATAL_ERROR "No LLVM and Clang support requires LLVM")
else()
16

Kevin Funk's avatar
Kevin Funk committed
17
macro(FIND_AND_ADD_CLANG_LIB _libname_)
Kevin Funk's avatar
Kevin Funk committed
18
19
  string(TOUPPER ${_libname_} _prettylibname_)
  find_library(CLANG_${_prettylibname_}_LIB ${_libname_} ${LLVM_LIBRARY_DIR} ${CLANG_LIB_DIR})
Kevin Funk's avatar
Kevin Funk committed
20
  if(CLANG_${_prettylibname_}_LIB)
Kevin Funk's avatar
Kevin Funk committed
21
22
    set(CLANG_LIBS ${CLANG_LIBS} ${CLANG_${_prettylibname_}_LIB})
  endif()
Kevin Funk's avatar
Kevin Funk committed
23
endmacro(FIND_AND_ADD_CLANG_LIB)
24

Kevin Funk's avatar
Kevin Funk committed
25
FIND_AND_ADD_CLANG_LIB(clang) # LibClang: high-level C interface
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
FIND_AND_ADD_CLANG_LIB(clangFrontend)
FIND_AND_ADD_CLANG_LIB(clangDriver)
FIND_AND_ADD_CLANG_LIB(clangCodeGen)
FIND_AND_ADD_CLANG_LIB(clangSema)
FIND_AND_ADD_CLANG_LIB(clangChecker)
FIND_AND_ADD_CLANG_LIB(clangAnalysis)
FIND_AND_ADD_CLANG_LIB(clangRewrite)
FIND_AND_ADD_CLANG_LIB(clangAST)
FIND_AND_ADD_CLANG_LIB(clangParse)
FIND_AND_ADD_CLANG_LIB(clangLex)
FIND_AND_ADD_CLANG_LIB(clangBasic)
FIND_AND_ADD_CLANG_LIB(clangARCMigrate)
FIND_AND_ADD_CLANG_LIB(clangEdit)
FIND_AND_ADD_CLANG_LIB(clangFrontendTool)
FIND_AND_ADD_CLANG_LIB(clangRewrite)
FIND_AND_ADD_CLANG_LIB(clangSerialization)
FIND_AND_ADD_CLANG_LIB(clangTooling)
FIND_AND_ADD_CLANG_LIB(clangStaticAnalyzerCheckers)
FIND_AND_ADD_CLANG_LIB(clangStaticAnalyzerCore)
FIND_AND_ADD_CLANG_LIB(clangStaticAnalyzerFrontend)
FIND_AND_ADD_CLANG_LIB(clangSema)
FIND_AND_ADD_CLANG_LIB(clangRewriteCore)

if(CLANG_LIBS)
  set(CLANG_FOUND TRUE)
Kevin Funk's avatar
Kevin Funk committed
51
endif()
52
53

if(CLANG_FOUND)
Kevin Funk's avatar
Kevin Funk committed
54
55
56
  message(STATUS "Found Clang: ${LLVM_INCLUDE_DIR}")
  message(STATUS "  Libraries: ${CLANG_LIBS}")
else()
57
  if(Clang_FIND_REQUIRED)
58
    message(FATAL_ERROR "Could NOT find Clang")
59
  endif()
Kevin Funk's avatar
Kevin Funk committed
60
endif()
61

Kevin Funk's avatar
Kevin Funk committed
62
endif()