CMake递归搜索头文件路径
作者:
转角的咖啡店 | 来源:发表于
2019-04-09 20:18 被阅读0次
获取当前目录及子目录(递归获取),添加到头文件搜索路径(仅供参考)
function(include_sub_directories_recursively root_dir)
if (IS_DIRECTORY ${root_dir}) # 当前路径是一个目录吗,是的话就加入到包含目录
# if (${root_dir} MATCHES "include")
message("include dir: " ${root_dir})
include_directories(${root_dir})
# endif()
endif()
file(GLOB ALL_SUB RELATIVE ${root_dir} ${root_dir}/*) # 获得当前目录下的所有文件,让如ALL_SUB列表中
foreach(sub ${ALL_SUB})
if (IS_DIRECTORY ${root_dir}/${sub})
include_sub_directories_recursively(${root_dir}/${sub}) # 对子目录递归调用,包含
endif()
endforeach()
endfunction()
本文标题:CMake递归搜索头文件路径
本文链接:https://www.haomeiwen.com/subject/fpxwiqtx.html
网友评论