Tests: Fix VS10Project SourceGroupTreeCMakeLists check

Fix an `IN LISTS` loop, fix a variable check, and escape backslashes
in the regex used to search for source group names.
This commit is contained in:
Kyle Edwards
2022-08-24 15:16:50 -04:00
parent 6fa11ecf03
commit bcc3965813
2 changed files with 5 additions and 4 deletions

View File

@@ -1,8 +1,9 @@
function(find_source_group LINES NAME)
set(foundFileFilter 0)
set(foundFilter 0)
string(REPLACE "\\" "\\\\" regexName "${NAME}")
foreach(line IN LISTS LINES)
if(line MATCHES "<Filter>${NAME}</Filter>")
if(line MATCHES "<Filter>${regexName}</Filter>")
if(foundFileFilter)
set(RunCMake_TEST_FAILED "Multiple files listed with filter for ${NAME}." PARENT_SCOPE)
set(FILTER_FOUND 0 PARENT_SCOPE)
@@ -10,7 +11,7 @@ function(find_source_group LINES NAME)
endif()
set(foundFileFilter 1)
endif()
if(line MATCHES "<Filter.*Include=\"${NAME}\"")
if(line MATCHES "<Filter.*Include=\"${regexName}\"")
if(foundFilter)
set(RunCMake_TEST_FAILED "Multiple copies of ${NAME} filter listed." PARENT_SCOPE)
set(FILTER_FOUND 0 PARENT_SCOPE)

View File

@@ -18,9 +18,9 @@ set(SOURCE_GROUPS_TO_FIND
"SourcesPrefix\\PrefixedNested"
)
foreach(GROUP_NAME IN LISTS ${SOURCE_GROUPS_TO_FIND})
foreach(GROUP_NAME IN LISTS SOURCE_GROUPS_TO_FIND)
find_source_group("${lines}" ${GROUP_NAME})
if(NOT ${FILTER_FOUND})
if(NOT FILTER_FOUND)
return()
endif()
endforeach()