1set(LLVM_LINK_COMPONENTS
2  ${LLVM_TARGETS_TO_BUILD}
3  BitReader
4  Core
5  MCDisassembler
6  Object
7  Target
8  )
9
10# We should only have llvm-c-test use libLLVM if libLLVM is built with the
11# default list of components. Using libLLVM with custom components can result in
12# build failures.
13
14set (USE_LLVM_DYLIB FALSE)
15
16if (TARGET LLVM)
17  set (USE_LLVM_DYLIB TRUE)
18  if (DEFINED LLVM_DYLIB_COMPONENTS)
19    foreach(c in ${LLVM_LINK_COMPONENTS})
20      list(FIND LLVM_DYLIB_COMPONENTS ${c} C_IDX)
21      if (C_IDX EQUAL -1)
22        set(USE_LLVM_DYLIB FALSE)
23        break()
24      endif()
25    endforeach()
26  endif()
27endif()
28
29if(USE_LLVM_DYLIB)
30  set(LLVM_LINK_COMPONENTS)
31endif()
32
33if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
34  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wstrict-prototypes")
35endif ()
36
37add_llvm_tool(llvm-c-test
38  calc.c
39  disassemble.c
40  helpers.c
41  include-all.c
42  main.c
43  module.c
44  metadata.c
45  object.c
46  targets.c
47  )
48
49if(USE_LLVM_DYLIB)
50  target_link_libraries(llvm-c-test LLVM)
51endif()
52