File: check-common.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 (42 lines) | stat: -rw-r--r-- 1,946 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
cmake_policy(SET CMP0140 NEW)
function(UseDebugLibraries_check tgt udl_expect_debug udl_expect_release)
  set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/${tgt}.vcxproj")
  if(NOT EXISTS "${vcProjectFile}")
    set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj does not exist.")
    return()
  endif()

  set(have_udl_debug 0)
  set(have_udl_release 0)
  set(inConfig "")

  file(STRINGS "${vcProjectFile}" lines)
  foreach(line IN LISTS lines)
    if(line MATCHES [[^ *<PropertyGroup Condition="'\$\(Configuration\)\|\$\(Platform\)'=='([^"|]+)\|[^"]+" Label="Configuration">.*$]])
      string(TOLOWER "${CMAKE_MATCH_1}" inConfig)
    elseif(inConfig)
      if(line MATCHES "^ *</PropertyGroup>.*$")
        set(inConfig "")
      elseif(line MATCHES "^ *<UseDebugLibraries>([^<>]+)</UseDebugLibraries>")
        set(udl_actual "${CMAKE_MATCH_1}")
        set(have_udl_${inConfig} 1)
        if (NOT "${udl_expect_${inConfig}}" STREQUAL "")
          if(NOT "${udl_actual}" STREQUAL "${udl_expect_${inConfig}}")
            string(APPEND RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj has ${inConfig} UseDebugLibraries '${udl_actual}', not '${udl_expect_${inConfig}}'.\n")
          endif()
        else()
          string(APPEND RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj has ${inConfig} UseDebugLibraries '${udl_actual}', but should not have one.\n")
        endif()
        unset(udl_actual)
      endif()
    endif()
  endforeach()

  if(NOT have_udl_debug AND NOT "${udl_expect_debug}" STREQUAL "")
    string(APPEND RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj does not have a debug UseDebugLibraries field, but should have one.\n")
  endif()
  if(NOT have_udl_release AND NOT "${udl_expect_release}" STREQUAL "")
    string(APPEND RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj does not have a release UseDebugLibraries field, but should have one.\n")
  endif()
  return(PROPAGATE RunCMake_TEST_FAILED)
endfunction()