target_include_directories 和include_directories
时间: 2023-12-29 16:43:23 浏览: 79
target_include_directories和include_directories都是在CMake中用于指定编译器搜索头文件的路径的指令。
target_include_directories用于为特定的目标(target)设置头文件搜索路径。具体语法为:
target_include_directories(<target> [SYSTEM [AFTER|BEFORE <INTERFACE|PUBLIC|PRIVATE> [items1...])
其中,<target>表示目标名称,表示将路径视为系统路径,用于指定添加路径的位置,<INTERFACE|PUBLIC|PRIVATE>表示添加路径的可见性, [SYSTEM dir1 [dir2 ...])
其中,用于指定添加路径的位置,表示将路径视为系统路径,dir1 [dir2 ...表示要添加的路径。
总结起来,target_include_directories用于为特定目标设置头文件搜索路径,而include_directories用于为当前目录及其子目录设置头文件搜索路径。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [cmake:target_include_directories、include_directories、add_executable](https://blog.csdn.net/zhizhengguan/article/details/115331314)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [include_directories和target_include_directories](https://blog.csdn.net/qq_33726635/article/details/121896441)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文