summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/VS10Project/VsVCTargetsPath-check.cmake
blob: 5b1701c85c71ef92cd098886073b694b7e65433a (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
macro(check_project_file projectFile)
  set(insideGlobals FALSE)
  set(pathFound FALSE)

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

  string(REPLACE "${RunCMake_TEST_BINARY_DIR}/" "" projectName ${projectFile})

  file(STRINGS "${projectFile}" lines)
  foreach(line IN LISTS lines)
    if(line MATCHES "^ *<PropertyGroup Label=\"Globals\">.*$")
      set(insideGlobals TRUE)
    elseif(insideGlobals)
      if(line MATCHES "^ *</PropertyGroup>.*$")
        set(insideGlobals FALSE)
      elseif(line MATCHES "^ *<VCTargetsPath>(.+)</VCTargetsPath>*$")
        message(STATUS "Found VCTargetsPath = ${CMAKE_MATCH_1} in PropertyGroup 'Globals' in ${projectName}")
        set(pathFound TRUE)
      endif()
    endif()
  endforeach()
  if(NOT pathFound)
    set(RunCMake_TEST_FAILED "VCTargetsPath not found in \"Globals\" propertygroup in ${projectName}")
    return() # This should intentionally return from the caller, not the macro
  endif()
endmacro()

check_project_file("${RunCMake_TEST_BINARY_DIR}/CMakeFiles/${CMAKE_VERSION}/CompilerIdCXX/CompilerIdCXX.vcxproj")
check_project_file("${RunCMake_TEST_BINARY_DIR}/foo.vcxproj")