From 1cf032eeb163975d8ee1a61aaf9ed1cb71006c4b Mon Sep 17 00:00:00 2001 From: GPUCode Date: Sun, 5 Nov 2023 17:08:47 +0200 Subject: [PATCH] cmake: Add directory groups --- CMakeLists.txt | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4640a580..4c3a85b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,24 @@ endif() project(shadps4) +# This function should be passed a list of all files in a target. It will automatically generate +# file groups following the directory hierarchy, so that the layout of the files in IDEs matches the +# one in the filesystem. +function(create_target_directory_groups target_name) + # 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 ".") + + get_target_property(target_sources "${target_name}" SOURCES) + + foreach(file_name IN LISTS target_sources) + 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() + add_subdirectory(third-party) include_directories(src) @@ -129,6 +147,8 @@ add_executable(shadps4 src/core/hle/libraries/libkernel/time_management.h ) +create_target_directory_groups(shadps4) + target_link_libraries(shadps4 PRIVATE magic_enum::magic_enum fmt::fmt spdlog::spdlog toml11::toml11) target_link_libraries(shadps4 PRIVATE discord-rpc imgui SDL3-shared vulkan-1 xxhash Zydis) if (WIN32)