Possible to add an imported library to target_link_libraries that takes care of include directories too?(是否可以将导入的库添加到 target_link_libraries 来处理包含目录?)
问题描述
somehow I am struggling with finding out whether it is possible to define an imported library in CMake, specifying target properties (include_directories and library path) and hoping that CMake will append the include directories once I add that project to target_link_libraries in another project.
Let's say I have an imported library in a file called Module-Conf.cmake:
add_library(mymodule STATIC IMPORTED)
set_target_properties(mymodule PROPERTIES IMPORTED_LOCATION "${OUTPUT_DIR}/lib")
set_target_properties(mymodule PROPERTIES INCLUDE_DIRECTORIES "${OUTPUT_DIR}/include")
And in a project I add the dependency:
include(Module-Conf)
target_link_libraries(${PROJECT_NAME} mymodule)
Will CMake append the include_directories property to the include path? Right now I cannot see the path so it seems that I have to do it by myself by using get_target_property?
Question: Can I do some CMake magic to automatically append the include to the include directories of another project?
Thanks a lot. Martin
The difference between the INCLUDE_DIRECTORIES property and the INTERFACE_INCLUDE_DIRECTORIES property is transitivity.
Set INTERFACE_INCLUDE_DIRECTORIES instead.
http://www.cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html#transitive-usage-requirements
这篇关于是否可以将导入的库添加到 target_link_libraries 来处理包含目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:是否可以将导入的库添加到 target_link_libraries 来处理包含目录?
基础教程推荐
- 全面了解C语言 static 关键字 2023-03-26
- centos 7 vscode cmake 编译c++工程 2023-09-17
- C++实战之二进制数据处理与封装 2023-05-29
- C语言 详解字符串基础 2023-03-27
- [C语言]二叉搜索树 2023-09-07
- C语言实现宾馆管理系统课程设计 2023-03-13
- C++实现ETW进行进程变动监控详解 2023-05-15
- 带你深度走入C语言取整以及4种函数 2022-09-17
- C语言编程C++旋转字符操作串示例详解 2022-11-20
- [c语言-函数]不定量参数 2023-09-08
