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语言中sizeof如何在自定义函数中正常工作 2023-04-09
- C语言详解float类型在内存中的存储方式 2023-03-27
- 我应该为我的项目使用相对包含路径,还是将包含目录放在包含路径上? 2022-10-30
- Qt计时器使用方法详解 2023-05-30
- C语言qsort()函数的使用方法详解 2023-04-26
- C++ 数据结构超详细讲解顺序表 2023-03-25
- Easyx实现扫雷游戏 2023-02-06
- c++ const 成员函数,返回一个 const 指针.但是返回的指针是什么类型的 const? 2022-10-11
- ubuntu下C/C++获取剩余内存 2023-09-18
- C语言手把手带你掌握带头双向循环链表 2023-04-03