是否可以使用 cmake 全局创建或访问库?
我的项目位于此文件路径中:
C:\Users\zaina\OneDrive\foo_directory\bar_projectname
我想要全局使用的库和 git 存储库位于此文件路径中:
C:\dev\github\foobar
例如 这个存储库是关于用 C++ 语言控制 Tello 无人机,我克隆了这个
我使用 Cmake GUI 来配置构建,使用 Visual Studio 来构建库,但我根本无法将其包含在我的项目由调用:
#include <tello/tello.hpp>
所以一定有一些东西可能有帮助。
我尝试了 git 子模块,效果很好,但它只是适用于单个项目而不是全局。
所以我想知道是否有可能将克隆存储库设置为全局库或创建一个。如果是的话,又如何呢?
我尝试将此作为我的 CMakeLists.txt:
project(foo)
# Setup testing
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
enable_testing()
add_executable(foo main.cpp)
target_include_directories(foo PRIVATE ${tello_SOURCE_DIR}/src)
target_link_libraries(tello_test PRIVATE tello)
但这不起作用,因为我的程序找不到 Tello 头文件。
My project is located in this filepath:
C:\Users\zaina\OneDrive\foo_directory\bar_projectname
The libraries and git repositories, which I want to use globally, are located in this file path:
C:\dev\github\foobar
For example This repository is about controlling Tello drone with c++ language, and I cloned this
I used Cmake GUI to configure the build and Visual Studio to build the libraries, but I simply can't include it in my project by invoking:
#include <tello/tello.hpp>
So there must be something that might help.
I tried git submodules and it worked fine, but it only works for a single project and not globally.
So I was wondering that is there a possibility to set a cloned repository as a global library or create one. If it is, then how?
I tried this as my CMakeLists.txt:
project(foo)
# Setup testing
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
enable_testing()
add_executable(foo main.cpp)
target_include_directories(foo PRIVATE ${tello_SOURCE_DIR}/src)
target_link_libraries(tello_test PRIVATE tello)
But that did not work, because my program can't find the tello header files.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论