我设法构建了llvm和clang,现在我正试图根据clang文档创建一个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
)
2条答案
按热度按时间0kjbasz61#
您需要使用关键字
target_link_libraries
签名;实际上,您需要将PRIVATE
添加到CMakeLists.txt
中的target_link_libraries
语句中:这是因为
add_llvm_executable
使用了这样的签名,您不能在CMake中混合它们。nwo49xxi2#
恕我直言,CMake应该只是打印一个迂腐的警告,而不是硬破坏人们一直依赖的API。下面的代码使函数向后兼容,同时仍然允许使用较新的签名。它打印一个警告,提醒你升级代码。