2017-11-26 11:39:27 +00:00
|
|
|
# This function should be passed a name of an existing target. It will automatically generate
|
2016-08-22 14:12:46 +01:00
|
|
|
# file groups following the directory hierarchy, so that the layout of the files in IDEs matches the
|
|
|
|
# one in the filesystem.
|
2017-11-26 11:39:27 +00:00
|
|
|
function(create_target_directory_groups target_name)
|
2016-08-22 14:12:46 +01:00
|
|
|
# Place any files that aren't in the source list in a separate group so that they don't get in
|
|
|
|
# the way.
|
|
|
|
source_group("Other Files" REGULAR_EXPRESSION ".")
|
|
|
|
|
2017-11-26 11:39:27 +00:00
|
|
|
get_target_property(target_sources "${target_name}" SOURCES)
|
|
|
|
|
|
|
|
foreach(file_name IN LISTS target_sources)
|
2016-08-22 14:12:46 +01:00
|
|
|
get_filename_component(dir_name "${file_name}" PATH)
|
|
|
|
# Group names use '\' as a separator even though the entire rest of CMake uses '/'...
|
|
|
|
string(REPLACE "/" "\\" group_name "${dir_name}")
|
|
|
|
source_group("${group_name}" FILES "${file_name}")
|
|
|
|
endforeach()
|
|
|
|
endfunction()
|