Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"uses of target_link_libraries must be either all-keyword or all-plain"

I managed to build llvm and clang and now I am trying to create a ClangTool according to clang docs. But I am getting the following error when I am trying to build it:

CMake Error at tools/clang/tools/loop-convert/CMakeLists.txt:6 (target_link_libraries):
  The keyword signature for target_link_libraries has already been used with 
  the target "loop-convert".  All uses of target_link_libraries with a target
  must be either all-keyword or all-plain.

  The uses of the keyword signature are here:

    * cmake/modules/LLVM-Config.cmake:105 (target_link_libraries)
    * cmake/modules/AddLLVM.cmake:771 (target_link_libraries)

My current CMakeLists.txt is:

set(LLVM_LINK_COMPONENTS support)

add_clang_executable(loop-convert
  LoopConvert.cpp
)

target_link_libraries(loop-convert
  clangTooling
  clangBasic
  clangASTMatchers
)
like image 692
Horatiu Vultur Avatar asked Dec 10 '17 09:12

Horatiu Vultur


1 Answers

You need to use keyword signature of target_link_libraries; effectively, you need to add PRIVATE to the target_link_libraries statement in your CMakeLists.txt:

target_link_libraries(loop-convert PRIVATE
  clangTooling
  clangBasic
  clangASTMatchers
)

This is because add_llvm_executable uses such signature and you can't mix them in CMake.

like image 68
arrowd Avatar answered Oct 17 '22 10:10

arrowd