Debian Codegraph @

Tests/RunCMake/string/RegexClear.cmake

raw
1 function (output_results msg)
2 message("results from: ${msg}")
3 message("CMAKE_MATCH_0: -->${CMAKE_MATCH_0}<--")
4 message("CMAKE_MATCH_1: -->${CMAKE_MATCH_1}<--")
5 message("CMAKE_MATCH_2: -->${CMAKE_MATCH_2}<--")
6 message("CMAKE_MATCH_COUNT: -->${CMAKE_MATCH_COUNT}<--")
7 endfunction ()
8
9 function (check_for_success msg)
10 if (CMAKE_MATCH_1 STREQUAL "0" AND
11 CMAKE_MATCH_2 STREQUAL "1")
12 message("Matched string properly")
13 else ()
14 message("Failed to match properly")
15 endif ()
16 output_results("${msg}")
17 endfunction ()
18
19 function (check_for_failure msg)
20 if (CMAKE_MATCH_1 STREQUAL "" AND
21 CMAKE_MATCH_2 STREQUAL "")
22 message("Matched nothing properly")
23 else ()
24 message("Found a match where there should be none")
25 endif ()
26 output_results("${msg}")
27 endfunction ()
28
29 macro (do_regex_success msg)
30 string(REGEX MATCH "(0)(1)" output "01")
31 check_for_success("${msg}")
32 endmacro ()
33
34 macro (do_regex_failure msg)
35 string(REGEX MATCH "(0)(1)" output "12")
36 check_for_failure("${msg}")
37 endmacro ()
38
39 do_regex_success("setting up initial state")
40
41 list(INSERT CMAKE_MODULE_PATH 0
42 "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
43 find_package(dummy) # Ensure cmMakefile::PushScope/PopScope work.
44
45 check_for_failure("checking after find_package")
46 do_regex_failure("clearing out results with a failing match")
47 do_regex_success("making a successful match before add_subdirectory")
48
49 add_subdirectory(subdir)
50
51 check_for_success("ensuring the subdirectory did not interfere with the parent") # Ensure that the subdir didn't mess with this scope.