我设法构建了llvm和clang,现在我正在尝试根据clang docs创建一个ClangTool。但是当我尝试构建它时,我收到以下错误:
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是:
set(LLVM_LINK_COMPONENTS support)
add_clang_executable(loop-convert
LoopConvert.cpp
)
target_link_libraries(loop-convert
clangTooling
clangBasic
clangASTMatchers
)
答案 0 :(得分:9)
您需要使用target_link_libraries
的关键字签名;实际上,您需要在PRIVATE
中的target_link_libraries
语句中添加CMakeLists.txt
:
target_link_libraries(loop-convert PRIVATE
clangTooling
clangBasic
clangASTMatchers
)
这是因为add_llvm_executable
使用了这样的签名而你无法在CMake中混合它们。