1 find_program(LLVM_CONFIG NAMES llvm-config-3.5 llvm-config llvm-config-3.6)
4 execute_process(COMMAND ${LLVM_CONFIG} --version
5 OUTPUT_VARIABLE LLVM_VERSION)
7 if(((${LLVM_VERSION} VERSION_LESS 3.7.0)
8 AND (${LLVM_VERSION} VERSION_GREATER 3.5))
9 OR (${LLVM_VERSION} VERSION_EQUAL 3.5))
11 execute_process(COMMAND ${LLVM_CONFIG} --cxxflags
12 OUTPUT_VARIABLE LLVM_CFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
13 execute_process(COMMAND ${LLVM_CONFIG} --ldflags
14 OUTPUT_VARIABLE LLVM_LDFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
15 execute_process(COMMAND ${LLVM_CONFIG} --libs
16 OUTPUT_VARIABLE LLVM_LIBS OUTPUT_STRIP_TRAILING_WHITESPACE)
17 execute_process(COMMAND ${LLVM_CONFIG} --system-libs
18 OUTPUT_VARIABLE LLVM_SYSTEM_LIBS OUTPUT_STRIP_TRAILING_WHITESPACE)
20 string(REPLACE -O2 "" LLVM_CFLAGS ${LLVM_CFLAGS})
21 string(REPLACE -fno-exceptions "" LLVM_CFLAGS ${LLVM_CFLAGS})
22 string(REPLACE -fno-rtti "" LLVM_CFLAGS ${LLVM_CFLAGS})
23 string(REPLACE -DNDEBUG "" LLVM_CFLAGS ${LLVM_CFLAGS})
24 string(REPLACE -I "-isystem" LLVM_CFLAGS ${LLVM_CFLAGS})
26 separate_arguments(LLVM_CFLAGS)
28 if(${LLVM_VERSION} VERSION_LESS 3.6)
29 set(LLVM_CFLAGS ${LLVM_CFLAGS} -DLLVM_35)
30 set(LLVM_DYNAMIC_LIB -lLLVM-3.5)
32 set(LLVM_CFLAGS ${LLVM_CFLAGS} -DLLVM_36)
33 set(LLVM_DYNAMIC_LIB -lLLVM-3.6)
38 if(NOT DEFINED LLVM_CFLAGS)
39 message(SEND_ERROR "LLVM 3.5 required but not found")