File: VsCharacterSet-check.cmake

package info (click to toggle)
cmake 4.2.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 152,336 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 (49 lines) | stat: -rw-r--r-- 2,018 bytes parent folder | download | duplicates (4)
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
macro(check_project_file projectFile outvar)
  set(insideConfiguration FALSE)
  set(characterSetFound 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 Condition=\"'[$][(]Configuration[)]|[$][(]Platform[)]'=='([^\"])+\" Label=\"Configuration\">.*$")
      set(insideConfiguration TRUE)
    elseif(insideConfiguration)
      if(line MATCHES "^ *</PropertyGroup>.*$")
        set(insideConfiguration FALSE)
      elseif(line MATCHES "^ *<CharacterSet>(.+)</CharacterSet>*$")
        message(STATUS "Found CharacterSet = ${CMAKE_MATCH_1} in PropertyGroup 'Configuration' in ${projectName}")
        set(characterSetFound TRUE)
        set(${outvar} ${CMAKE_MATCH_1})
      endif()
    endif()
  endforeach()
  if(NOT characterSetFound)
    set(RunCMake_TEST_FAILED "CharacterSet not found in \"Configuration\" 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" MULTI_BYTE_CHARSET)
check_project_file("${RunCMake_TEST_BINARY_DIR}/foo.vcxproj" OVERRIDDEN_CHARSET)

if (NOT "${MULTI_BYTE_CHARSET}" STREQUAL "MultiByte")
  set(RunCMake_TEST_FAILED "Default character-set (\"MultiByte\") was overridden (it shouldn't)")
  return()
endif()

if(NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/set_charset.txt")
  set(RunCMake_TEST_FAILED "File 'set_charset.txt' with set charset does not exist.")
  return()
endif()
file(STRINGS "${RunCMake_TEST_BINARY_DIR}/set_charset.txt" SET_CHARSET)

if (NOT "${OVERRIDDEN_CHARSET}" STREQUAL "${SET_CHARSET}")
  set(RunCMake_TEST_FAILED "Failed to override the character-set with \"${SET_CHARSET}\"")
  return()
endif()