File: VsPackageReferences-check.cmake

package info (click to toggle)
cmake 4.2.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 152,456 kB
  • sloc: ansic: 403,896; cpp: 303,920; sh: 4,105; python: 3,583; yacc: 3,106; lex: 1,279; f90: 538; asm: 471; lisp: 375; cs: 270; java: 266; fortran: 239; objc: 215; perl: 213; xml: 198; makefile: 111; javascript: 83; pascal: 63; tcl: 55; php: 25; ruby: 22
file content (61 lines) | stat: -rw-r--r-- 1,873 bytes parent folder | download | duplicates (6)
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
57
58
59
60
61
set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj")
if(NOT EXISTS "${vcProjectFile}")
  set(RunCMake_TEST_FAILED "Project file foo.vcxproj does not exist.")
  return()
endif()

set(installProjectFile "${RunCMake_TEST_BINARY_DIR}/INSTALL.vcxproj")
if(NOT EXISTS "${installProjectFile}")
  set(RunCMake_TEST_FAILED "Install file INSTALL.vcxproj does not exist.")
  return()
endif()


set(test1Library "boost")
set(test1Version "1.7.0")


set(test2Library "SFML")
set(test2Version "2.2.0")

set(Library1Found FALSE)
set(Library2Found FALSE)

file(STRINGS "${vcProjectFile}" lines)

foreach(i 1 2)
  set(testLibrary "${test${i}Library}")
  set(testVersion "${test${i}Version}")
  foreach(line IN LISTS lines)
    if(line MATCHES "^ *<PackageReference Include=\"${testLibrary}\".*>$")
      if(line MATCHES "^ *<PackageReference .* Version=\"${testVersion}\".*>$")
        set(Library${i}Found TRUE)
        message(STATUS "foo.vcxproj is using package reference ${testLibrary} with version ${testVersion}")
      else()
        message(STATUS "foo.vcxproj failed to define reference ${testLibrary} with version ${testVersion}")
        set(Library${i}Found FALSE)
      endif()
    endif()
  endforeach()
endforeach()

if(NOT Library1Found OR NOT Library2Found)
  set(RunCMake_TEST_FAILED "Failed to find package references")
  return()
endif()

set(DOT_NET_FRAMEWORK_VERSION_FOUND FALSE)

file(STRINGS "${installProjectFile}" installlines)
foreach(line IN LISTS lines)
  if(line MATCHES "^ *<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>$")
    set(DOT_NET_FRAMEWORK_VERSION_FOUND TRUE)
    message(STATUS "The install target contains the correct TargetFrameworkVersion.")
    break()
  endif()
endforeach()

if(NOT DOT_NET_FRAMEWORK_VERSION_FOUND)
  set(RunCMake_TEST_FAILED "Failed to find TargetFrameworkVersion in the install target")
  return()
endif()