summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/VS10Project/VsTargetsFileReferences-check.cmake
blob: 3d01c2c30c427c7aa86f6e4f876b2273ed0d3170 (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
36
37
38
39
40
41
42
43
44
45
set(files foo.vcxproj bar.vcxproj baz.vcxproj)

foreach(file ${files})
  set(vsProjectFile ${RunCMake_TEST_BINARY_DIR}/${file})

  if(NOT EXISTS "${vsProjectFile}")
    set(RunCMake_TEST_FAILED "Project file ${vsProjectFile} does not exist.")
    return()
  endif()

  set(waldoFound FALSE)
  set(xyzzyFound FALSE)
  file(STRINGS "${vsProjectFile}" lines)
  foreach(line IN LISTS lines)
    if(line MATCHES "^ *<Import Project=.*/>$")
      if(line MATCHES "^.*waldo.targets.*$")
        set(waldoFound TRUE)
        message(STATUS "${file} is importing waldo.targets")
      elseif(line MATCHES "^.*xyzzy.targets.*$")
        set(xyzzyFound TRUE)
        message(STATUS "${file} is importing xyzzy.targets")
      endif()
    endif()
  endforeach()

  if("${file}" STREQUAL "foo.vcxproj")
    if(NOT xyzzyFound)
      set(RunCMake_TEST_FAILED "xyzzy.targets not imported from ${file}")
      return()
    endif()
    if(waldoFound)
      set(RunCMake_TEST_FAILED "waldo.targets imported from ${file}")
      return()
    endif()
  else()
    if(NOT xyzzyFound)
      set(RunCMake_TEST_FAILED "xyzzy.targets not imported from ${file}")
      return()
    endif()
    if(NOT waldoFound)
      set(RunCMake_TEST_FAILED "waldo.targets not imported from ${file}")
      return()
    endif()
  endif()
endforeach()