cmake: Parse vcxproj filters for cmake generators

This commit is contained in:
TellowKrinkle 2021-05-07 17:35:36 -05:00 committed by tellowkrinkle
parent 55d0d40697
commit e34116e340
2 changed files with 31 additions and 0 deletions

View File

@ -198,3 +198,18 @@ macro(add_custom_glib_res out xml prefix)
--c-name ${prefix} "${RESOURCE_DIR}/${xml}" --target=${out}.cpp
DEPENDS res/${xml} ${RESOURCE_FILES})
endmacro()
function(source_groups_from_vcxproj_filters file)
file(READ "${file}" filecontent)
get_filename_component(parent "${file}" DIRECTORY)
if (parent STREQUAL "")
set(parent ".")
endif()
set(regex "<[^ ]+ Include=\"([^\"]+)\">[ \t\r\n]+<Filter>([^<]+)<\\/Filter>[ \t\r\n]+<\\/[^ >]+>")
string(REGEX MATCHALL "${regex}" filterstrings "${filecontent}")
foreach(filterstring IN LISTS filterstrings)
string(REGEX REPLACE "${regex}" "\\1" path "${filterstring}")
string(REGEX REPLACE "${regex}" "\\2" group "${filterstring}")
source_group("${group}" FILES "${parent}/${path}")
endforeach()
endfunction()

View File

@ -1172,6 +1172,7 @@ set(Common
${pcsx2GSHeaders}
${pcsx2GSSources}
${pcsx2DebugToolsSources}
${pcsx2DebugToolsHeaders}
${pcsx2GuiSources}
${pcsx2GuiResources}
${pcsx2GuiHeaders}
@ -1350,3 +1351,18 @@ if(NOT DISABLE_SETCAP)
install(CODE "execute_process(COMMAND /bin/bash -c \"echo 'Enabling networking capability on Linux...';set -x; [ -f '${CMAKE_SOURCE_DIR}/bin/${Output}' ] && sudo setcap 'CAP_NET_RAW+eip CAP_NET_ADMIN+eip' '${CMAKE_SOURCE_DIR}/bin/${Output}'; set +x\")")
endif()
endif()
source_groups_from_vcxproj_filters(pcsx2.vcxproj.filters)
# Unix-only files aren't in the vcxproj.filters
source_group(System/Ps2/DEV9 REGULAR_EXPRESSION DEV9/*)
source_group(System/Ps2/PAD FILES ${pcsx2PADSources} ${pcsx2PADHeaders})
source_group(System/Ps2/SPU2 REGULAR_EXPRESSION SPU2/*)
source_group(System/Ps2/USB REGULAR_EXPRESSION USB/*)
# Generated resource files
source_group(Resources/GUI FILES ${pcsx2GuiResources})
source_group(Resources/PAD FILES ${pcsx2PADResources})
source_group(Resources/Recording FILES ${pcsx2RecordingVirtualPadResources})
source_group(Resources FILES ../bin/GameIndex.yaml gui/Resources/PCSX2.icns)
source_group(Resources REGULAR_EXPRESSION ${CMAKE_CURRENT_BINARY_DIR}/*)