summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/VS10Project/SourceGroupHelpers.cmake
blob: c82a66e8c02a4393311b2ad1556954e63b247e15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
function(find_source_group LINES NAME)
  set(foundFileFilter 0)
  set(foundFilter 0)
  foreach(line IN LISTS LINES)
    if(line MATCHES "<Filter>${NAME}</Filter>")
      if(foundFileFilter)
        set(RunCMake_TEST_FAILED "Multiple files listed with filter for ${NAME}." PARENT_SCOPE)
        set(FILTER_FOUND 0 PARENT_SCOPE)
        return()
      endif()
      set(foundFileFilter 1)
    endif()
    if(line MATCHES "<Filter.*Include=\"${NAME}\"")
      if(foundFilter)
        set(RunCMake_TEST_FAILED "Multiple copies of ${NAME} filter listed." PARENT_SCOPE)
        set(FILTER_FOUND 0 PARENT_SCOPE)
        return()
      endif()
      set(foundFilter 1)
    endif()
  endforeach()

  if(NOT foundFileFilter)
    set(RunCMake_TEST_FAILED "File filter for ${NAME} not found." PARENT_SCOPE)
    set(FILTER_FOUND 0 PARENT_SCOPE)
    return()
  endif()
  if(NOT foundFilter)
    set(RunCMake_TEST_FAILED "Filter ${NAME} not found." PARENT_SCOPE)
    set(FILTER_FOUND 0 PARENT_SCOPE)
    return()
  endif()

  set(FILTER_FOUND 1 PARENT_SCOPE)
endfunction()