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
|
function(check_output name expected)
set(output "${${name}}")
if(NOT output STREQUAL expected)
message(FATAL_ERROR "\"string(REGEX)\" set ${name} to \"${output}\", expected \"${expected}\"")
endif()
endfunction()
# OLD
cmake_policy(SET CMP0186 OLD)
string(REGEX MATCHALL "^0" out "0000")
check_output(out "0;0;0;0")
string(REGEX MATCHALL "^0+" out "0000")
check_output(out "0000")
string(REGEX MATCHALL "^(0|a)" out "0000" )
check_output(out "0;0;0;0")
string(REGEX MATCHALL "^(0|a)" out "aaaa")
check_output(out "a;a;a;a")
string(REGEX MATCHALL "^(0|a)" out "a0a0")
check_output(out "a;0;a;0")
string(REGEX MATCHALL "(^|a)0" out "00a0")
check_output(out "0;0;a0")
string(REGEX REPLACE "^0" "" out "0000")
check_output(out "")
string(REGEX REPLACE "^0" "x" out "0000")
check_output(out "xxxx")
string(REGEX REPLACE "^0+" "x" out "0000")
check_output(out "x")
string(REGEX REPLACE "^(0|a)" "x" out "0000")
check_output(out "xxxx")
string(REGEX REPLACE "^(0|a)" "x" out "aaaa")
check_output(out "xxxx")
string(REGEX REPLACE "^(0|a)" "x" out "a0a0")
check_output(out "xxxx")
string(REGEX REPLACE "(^|a)0" "x" out "00a0")
check_output(out "xxx")
# NEW, same cases as above
cmake_policy(SET CMP0186 NEW)
string(REGEX MATCHALL "^0" out "0000")
check_output(out "0")
string(REGEX MATCHALL "^0+" out "0000")
check_output(out "0000")
string(REGEX MATCHALL "^(0|a)" out "0000")
check_output(out "0")
string(REGEX MATCHALL "^(0|a)" out "aaaa")
check_output(out "a")
string(REGEX MATCHALL "^(0|a)" out "a0a0")
check_output(out "a")
string(REGEX MATCHALL "(^|a)0" out "00a0")
check_output(out "0;a0")
string(REGEX REPLACE "^0" "" out "0000")
check_output(out "000")
string(REGEX REPLACE "^0" "x" out "0000")
check_output(out "x000")
string(REGEX REPLACE "^0+" "x" out "0000")
check_output(out "x")
string(REGEX REPLACE "^(0|a)" "x" out "0000")
check_output(out "x000")
string(REGEX REPLACE "^(0|a)" "x" out "aaaa")
check_output(out "xaaa")
string(REGEX REPLACE "^(0|a)" "x" out "a0a0")
check_output(out "x0a0")
string(REGEX REPLACE "(^|a)0" "x" out "00a0")
check_output(out "x0x")
|