“ target_link_libraries的使用必须是全关键字或全普通” [英] "uses of target_link_libraries must be either all-keyword or all-plain"
问题描述
我设法建立了llvm和clang,现在我试图创建一个根据 clang文档的ClangTool。但是在尝试构建它时出现以下错误:
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)
我当前的CMakeLists.txt是:
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
)
推荐答案
您需要使用 target_link_libraries
的关键字签名;有效地,您需要在 CMakeLists.txt中的
: target_link_libraries
语句中添加 PRIVATE
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
)
这是因为 add_llvm_executable
使用此类签名,您不能在CMake中将它们混合使用。
This is because add_llvm_executable
uses such signature and you can't mix them in CMake.
这篇关于“ target_link_libraries的使用必须是全关键字或全普通”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!