vs下cmake遍历文件夹并建立过滤器
function(retrieve_files out_files)
set(source_list)
foreach(dirname ${
argn})
file(glob_recurse files relative ${
cmake_current_source_dir}
"${dirname}/*.cmake"
"${dirname}/*.h"
"${dirname}/*.hpp"
"${dirname}/*.c"
"${dirname}/*.cpp"
"${dirname}/*.cc"
)
foreach(filename ${
files})
list(append source_list "${cmake_current_source_dir}/${filename}")
set(file_abs_path "${cmake_current_source_dir}/${filename}")
get_filename_component(source_path "${filename}" path)
string(replace "/" "\\" filter_dir "${source_path}")
source_group("${filter_dir}" files "${filename}")
endforeach()
endforeach()
set(${
out_files} ${
source_list} parent_scope)
endfunction()