cmake - CMake 导入共享和静态库版本,但我只想要一个
问题描述
我想在项目中使用 Antlr 框架。我正在使用 CMake 来构建项目。
我想使用 Antlr 的 SHARED 库版本,而不是 STATIC 版本。它的 CMake 文件包含两者的目标。
Antlr 的 github 站点明确告诉我使用以下代码:
find_package(antlr4-runtime REQUIRED)
# add runtime include directories on this project.
include_directories( ${ANTLR4_INCLUDE_DIR} )
# add runtime to project dependencies
add_dependencies( Parsertest antlr4_shared )
# add runtime to project link libraries
target_link_libraries( Parsertest PRIVATE
antlr4_shared)
(另一个目标 ,antlr4_static
存在,但不应使用。)
我完全像这样复制它并收到以下错误:
CMake Error at /usr/lib64/cmake/antlr4-runtime/antlr4-targets.cmake:82 (message):
The imported target "antlr4_static" references the file
"/usr/lib/libantlr4-runtime.a"
but this file does not exist.
我的系统中没有安装静态库,因为我无意使用它。不过,我如何让 CMake 首先停止寻找错误的目标?我在 CMakeLists.txt 文件中没有使用它,并且对这种行为感到困惑。
解决方案
推荐阅读
- angular - Angular8 PrimeNG 反应形式的下拉菜单 - 初始值
- bash - 如何从bash中的随机子域中检索主域
- java - 无法使用特定配置文件运行 Spring Boot JAR 文件
- latex - 如何删除长表中的特定垂直线
- angular - 听 Angular 事件点击 webbrowser
- ruby-on-rails - 如何为在 Rails 5 中调用邮件程序的方法编写 rspec 模拟
- javascript - React.js 路由确切路径不正常
- botframework - 通过 Postman 与您的 microsoft bot 框架聊天
- c# - 如何在 ASP.NET 中发送 PUT 和 DELETE 表单?
- swift - Tensorflow中张量的可微积