summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/VsDotnetSdk/VsDotnetSdkXamlFiles-check.cmake
blob: 3e2c6deb3d8c582b7b4fc4127b9466b70e779427 (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
46
47
48
49
50
51
52
53
54
55
56
set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/dotNetSdkWpfApp.csproj")
if(NOT EXISTS "${vcProjectFile}")
  set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.")
  return()
endif()

set(inAppDefinition FALSE)
set(inPageDefinition FALSE)
set(inResourceDefinition FALSE)
set(xamlAppDefinitionSet FALSE)
set(xamlPageSet FALSE)
set(resourcesSet FALSE)

file(STRINGS "${vcProjectFile}" lines)
foreach(line IN LISTS lines)
  if(NOT inAppDefinition AND line MATCHES "^ *<ApplicationDefinition[^>]*>")
    set(inAppDefinition TRUE)
  elseif(inAppDefinition AND line MATCHES "^ *<Link>([^<>]+)</Link>$")
    if("${CMAKE_MATCH_1}" STREQUAL "App.xaml")
        message(STATUS "dotNetSdkWpfApp.csproj has app definition set")
        set(xamlAppDefinitionSet TRUE)
        set(inAppDefinition FALSE)
    endif()
  elseif(NOT inPageDefinition AND line MATCHES "^ *<Page[^>]*>")
    set(inPageDefinition TRUE)
  elseif(inPageDefinition AND line MATCHES "^ *<Link>([^<>]+)</Link>$")
    if("${CMAKE_MATCH_1}" STREQUAL "MainWindow.xaml")
        message(STATUS "dotNetSdkWpfApp.csproj has main window page set")
        set(xamlPageSet TRUE)
        set(inPageDefinition FALSE)
    endif()
  elseif(NOT inResourceDefinition AND line MATCHES "^ *<EmbeddedResource[^>]*>")
    set(inResourceDefinition TRUE)
  elseif(inResourceDefinition AND line MATCHES "^ *<Link>([^<>]+)</Link>$")
    if("${CMAKE_MATCH_1}" STREQUAL "Resources.resx")
        message(STATUS "dotNetSdkWpfApp.csproj has embedded resources set")
        set(resourcesSet TRUE)
        set(inResourceDefinition FALSE)
    endif()
  endif()
endforeach()

if(NOT xamlAppDefinitionSet)
  set(RunCMake_TEST_FAILED "Xaml App definition not set correctly.")
  return()
endif()

if(NOT xamlPageSet)
  set(RunCMake_TEST_FAILED "Xaml Page not set correctly.")
  return()
endif()

if(NOT resourcesSet)
  set(RunCMake_TEST_FAILED "resources not set correctly.")
  return()
endif()