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