File: FindLibClang.cmake

package info (click to toggle)
doxygen 1.8.12-1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 19,856 kB
  • ctags: 30,758
  • sloc: cpp: 237,683; lex: 35,587; xml: 8,286; python: 2,768; ansic: 629; tcl: 594; php: 446; perl: 370; makefile: 241; yacc: 235; objc: 14; sh: 11; java: 1
file content (55 lines) | stat: -rw-r--r-- 2,080 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
51
52
53
54
55
if (NOT CLANG_ROOT)
  set(CLANG_ROOT $ENV{CLANG_ROOT})
endif ()

if (NOT LLVM_CONFIG)
  set(LLVM_CONFIG $ENV{LLVM_CONFIG})
  if (NOT LLVM_CONFIG)
    set(llvm_config_names llvm-config)
    foreach(minor RANGE 9 1)
      list(APPEND llvm_config_names "llvm-config3${minor}" "llvm-config-3.${minor}" "llvm-config-mp-3.${minor}")
    endforeach ()
    find_program(LLVM_CONFIG NAMES ${llvm_config_names})
  endif ()
endif ()

if (LLVM_CONFIG)
  message(STATUS "llvm-config found at: ${LLVM_CONFIG}")
else ()
  message(FATAL_ERROR "Could NOT find llvm-config executable.")
endif ()

if (NOT EXISTS ${CLANG_INCLUDEDIR})
  execute_process(COMMAND ${LLVM_CONFIG} --includedir OUTPUT_VARIABLE CLANG_INCLUDEDIR OUTPUT_STRIP_TRAILING_WHITESPACE)
  if (NOT EXISTS ${CLANG_INCLUDEDIR})
    message(FATAL_ERROR "Could NOT find clang includedir. You can fix this by setting CLANG_INCLUDEDIR in your shell or as a cmake variable.")
  endif ()
endif ()

if (NOT EXISTS ${CLANG_LIBDIR})
  execute_process(COMMAND ${LLVM_CONFIG} --libdir OUTPUT_VARIABLE CLANG_LIBDIR OUTPUT_STRIP_TRAILING_WHITESPACE)
  if (NOT EXISTS ${CLANG_LIBDIR})
    message(FATAL_ERROR "Could NOT find clang libdir. You can fix this by setting CLANG_LIBDIR in your shell or as a cmake variable.")
  endif ()
endif ()

if (NOT CLANG_LIBS)
  find_library(CLANG_LIB_HACK_CMAKECACHE_DOT_TEXT_BULLSHIT NAMES clang libclang ${CLANG_ROOT}/lib ${CLANG_LIBDIR} NO_DEFAULT_PATH)
  if (NOT EXISTS ${CLANG_CLANG_LIB_HACK_CMAKECACHE_DOT_TEXT_BULLSHIT})
    find_library(CLANG_LIBS NAMES clang libclang)
    if (NOT EXISTS ${CLANG_LIBS})
      if (MSVC)
        set (CLANG_LIBS "${CLANG_LIBDIR}/libclang.lib")
      else()
        set (CLANG_LIBS "-L${CLANG_LIBDIR}" "-lclang")
      endif()
    endif ()
  else ()
    set(CLANG_LIBS "${CLANG_LIB_HACK_CMAKECACHE_DOT_TEXT_BULLSHIT}")
  endif ()
endif ()

execute_process(COMMAND ${LLVM_CONFIG} --version OUTPUT_VARIABLE CLANG_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
message("-- Using Clang ${CLANG_VERSION} from ${CLANG_LIBDIR} with LIBS ${CLANG_LIBS} and CXXFLAGS ${CLANG_CXXFLAGS}")