File: RunCMakeTest.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 (90 lines) | stat: -rw-r--r-- 2,960 bytes parent folder | download | duplicates (2)
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
include(RunCMake)

set(RunCMake_TEST_OPTIONS
  "-DPSEUDO_CPPCHECK=${PSEUDO_CPPCHECK}"
  "-DPSEUDO_CPPLINT=${PSEUDO_CPPLINT}"
  "-DPSEUDO_IWYU=${PSEUDO_IWYU}"
  "-DPSEUDO_TIDY=${PSEUDO_TIDY}"
  )

function(run_multilint lang)
  # Use a single build tree for tests without cleaning.
  set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${lang}-build")
  set(RunCMake_TEST_NO_CLEAN 1)
  file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
  file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
  run_cmake(${lang})
  set(RunCMake_TEST_OUTPUT_MERGE 1)
  run_cmake_command(${lang}-Build ${CMAKE_COMMAND} --build .)
endfunction()

run_multilint(C)
run_multilint(CXX)

if(NOT RunCMake_GENERATOR STREQUAL "Watcom WMake")
  run_multilint(C-launch)
  run_multilint(CXX-launch)
  run_multilint(genex)
endif()

function(run_skip_linting test_name prop_sf prop_tgt)
  set(RunCMake_TEST_VARIANT_DESCRIPTION " (prop_sf=${prop_sf}, prop_tgt=${prop_tgt})")
  list(APPEND RunCMake_TEST_OPTIONS "-Dprop_sf=${prop_sf}" "-Dprop_tgt=${prop_tgt}")

  set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${test_name}-build")
  set(RunCMake_TEST_NO_CLEAN 1)

  run_cmake(${test_name})
  set(RunCMake_TEST_OUTPUT_MERGE 1)
  run_cmake_command(${test_name}-Build ${CMAKE_COMMAND} --build .)
endfunction()

# There are a few `SKIP_LINTING` source/target propertiy combinations
# that affect the final result:
#
#  prop_sf   prop_tgt   result
#  ---------------------------
#    -         -         OFF
#    OFF       -         OFF
#    ON        -         ON
#    -         OFF       OFF
#    OFF       OFF       OFF
#    ON        OFF       ON
#    -         ON        ON
#    OFF       ON        OFF
#    ON        ON        ON
#
# where `-` means unset property.
#
# Here's the same table for convenience sorted by `result`:
#
#  prop_sf   prop_tgt   result
#  ---------------------------
#    -         -         OFF
#    OFF       -         OFF
#    -         OFF       OFF
#    OFF       OFF       OFF
#    OFF       ON        OFF
#    ON        -         ON
#    ON        OFF       ON
#    -         ON        ON
#    ON        ON        ON

foreach(lang IN ITEMS C CXX)
  # Testing `SKIP_LINTING=OFF` (first half of the table above)
  set(prop_sf_OFF_variants "-" OFF "-" OFF OFF)
  set(prop_tgt_OFF_variants "-" "-" OFF OFF ON)
  foreach(prop_fs prop_tgt IN ZIP_LISTS prop_sf_OFF_variants prop_tgt_OFF_variants)
    run_skip_linting(${lang}_skip_linting_OFF "${prop_fs}" "${prop_tgt}")
  endforeach()

  # Testing `SKIP_LINTING=ON` (second half of the table above)
  set(prop_sf_ON_variants ON ON "-" ON)
  set(prop_tgt_ON_variants "-" OFF ON ON)
  foreach(prop_fs prop_tgt IN ZIP_LISTS prop_sf_ON_variants prop_tgt_ON_variants)
    run_skip_linting(${lang}_skip_linting_ON "${prop_fs}" "${prop_tgt}")
    if(NOT RunCMake_GENERATOR STREQUAL "Watcom WMake")
      run_skip_linting(${lang}-launch_skip_linting_ON "${prop_fs}" "${prop_tgt}")
    endif()
  endforeach()
endforeach()