我设法构建了 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
)
最佳答案
需要使用target_link_libraries的关键字签名;实际上,您需要将 PRIVATE 添加到 CMakeLists.txt 中的 target_link_libraries 语句:
target_link_libraries(loop-convert PRIVATE
clangTooling
clangBasic
clangASTMatchers
)
这是因为 add_llvm_executable 使用了这样的签名,您不能在 CMake 中混合使用它们。
关于c++ - "uses of target_link_libraries must be either all-keyword or all-plain",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47737558/