File: RemoveEmptyCommands-check.cmake

package info (click to toggle)
cmake 4.2.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 152,344 kB
  • sloc: ansic: 403,894; cpp: 303,807; sh: 4,097; python: 3,582; 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: 108; javascript: 83; pascal: 63; tcl: 55; php: 25; ruby: 22
file content (63 lines) | stat: -rw-r--r-- 1,859 bytes parent folder | download | duplicates (7)
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
62
63
set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/exe.vcxproj")
if(NOT EXISTS "${vcProjectFile}")
  set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.")
  return()
endif()

set(inGroup FALSE)
set(inCommand FALSE)

set(expected_Debug
  "cmd_1 cmd_1_arg"
  "cmd_1_dbg cmd_1_dbg_arg"
  "cmd_2_dbg cmd_2_dbg_arg"
  "cmd_3_dbg cmd_3_dbg_arg")

set(expected_Release
  "cmd_1 cmd_1_arg"
  "cmd_3_rel cmd_3_rel_arg")

# extract build events
file(STRINGS "${vcProjectFile}" lines)
foreach(line IN LISTS lines)
  if(line MATCHES "^ *<ItemDefinitionGroup Condition=.*Configuration.*Platform.*>$")
    set(inGroup TRUE)
    string(REGEX MATCH "=='(.*)\\|(.*)'" out ${line})
    set(config ${CMAKE_MATCH_1})
  elseif(line MATCHES "^ *</ItemDefinitionGroup>$")
    set(inGroup FALSE)
  elseif(inGroup)
    if(line MATCHES "^ *<Command>.*$")
      set(inCommand TRUE)
      string(REGEX MATCH "<Command>(.*)" cmd ${line})
      set(currentCommand ${CMAKE_MATCH_1})
    elseif(line MATCHES "^(.*)</Command>$")
      string(REGEX MATCH "(.*)</Command>" cmd ${line})
      list(APPEND currentCommand ${CMAKE_MATCH_1})
      set(command_${config} ${currentCommand})
      set(inCommand FALSE)
    elseif(inCommand)
      list(APPEND currentCommand ${line})
    endif()
  endif()
endforeach()

foreach(config "Debug" "Release")
  set(currentName command_${config})
  set(expectedName expected_${config})
  set(strippedCommand "")
  if(DEFINED ${currentName})
    foreach(v ${${currentName}})
      if(${v} MATCHES "cmd_")
        list(APPEND strippedCommand ${v})
      endif()
    endforeach()
    if(NOT "${strippedCommand}" STREQUAL
      "${${expectedName}}")
      message(" - ${strippedCommand}")
      message(" + ${${expectedName}}")
      set(RunCMake_TEST_FAILED "build event command does not match")
      return()
    endif()
  endif()
endforeach()