summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/VS10Project/VsDotnetTargetFrameworkVersion-check.cmake
blob: d2c3c3bf6915a9c8ee078961c82374cbb8e6264e (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
set(files foo.csproj bar.csproj)

set(inLib1 FALSE)
set(targetFrameworkInLib1 FALSE)

set(inLib2 FALSE)
set(targetFrameworksInLib2 FALSE)

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

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

  file(STRINGS "${csProjectFile}" lines)

  foreach(line IN LISTS lines)
    if(NOT inLib1)
      if(line MATCHES " *<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> *$")
        set(targetFrameworkInLib1  TRUE)
        set(inLib1  TRUE)
      endif()
    elseif(NOT inLib2)
      if(line MATCHES " *<TargetFramework>netcoreapp3.1</TargetFramework> *$")
        set(targetFrameworksInLib2  TRUE)
        set(inLib2 TRUE)
      endif()
    endif()
  endforeach()
endforeach()

if(NOT targetFrameworkInLib1)
  set(RunCMake_TEST_FAILED "TargetFrameworkVersion not set correctly.")
endif()

if(NOT targetFrameworksInLib2)
  set(RunCMake_TEST_FAILED "TargetFramework not set correctly.")
endif()