【发布时间】:2020-08-14 02:43:27
【问题描述】:
我的项目中有以下结构。
project-
include-
src-
ab.cpp
ab.h
tests
CMakeLists.txt
CMakeLists.txt
我使用add_library 在project/CMakeLists.txt 目录中创建库。在测试目录 CMake 中,我使用 target_link_libraries。现在我的 test.cpp 它没有找到 ab.h 我必须使用 target_include_directories 和 project/src 路径。 target_link_libraries 是否仅从 include 目录中找到标头或我在这里缺少什么?
【问题讨论】:
-
target_link_libraries仅影响链接器设置,与添加额外的包含位置无关 -
与其只知道项目的结构,还需要查看您的 CMakeLists.txt 文件以提供合理的建议。