# https://www.coder.work/article/807942
foreach(FILE ${all_files})
#convert source file to absolute
get_filename_component(ABSOLUTE_PATH "${FILE}" ABSOLUTE)
# Get the directory of the absolute source file
get_filename_component(PARENT_DIR "${ABSOLUTE_PATH}" DIRECTORY)
# Remove common directory prefix to make the group
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}" "" GROUP "${PARENT_DIR}")
source_group("${GROUP}" FILES "${FILE}")
endforeach()
CMake 工程按文件夹显示层次结构
最新推荐文章于 2023-04-08 22:17:56 发布