CMake如何把源文件分组?
# Organize them into source groups based on their directory
# source_group(groupName FILES sourceFiles)
foreach(source ${MY_SOURCE_FILES})
# Get the directory of the source file
get_filename_component(source_dir "${source}" PATH)
# Remove common path prefix
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" group "${source_dir}")
string(REPLACE "OtherCommonDir/" "" group "${group}")
# Make sure we use forward slashes even on Windows
string(REPLACE "\\" "/" group "${group}")
# Group by folder
source_group("${group}" FILES "${source}")
endforeach()