summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/CMP0054/CMP0054-NEW.cmake
blob: 23a912476024ba09fcf741e04f999b64a6e91450 (plain)
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
cmake_policy(SET CMP0054 NEW)

set(FOO "BAR")
set(BAZ "ZZZ")
set(MYTRUE ON)
set(MYNUMBER 3)
set(MYVERSION 3.0)

function(assert_unquoted PREFIX FIRST)
  string(REPLACE ";" " " ARGN_SP "${ARGN}")
  if(${PREFIX} ${FIRST} ${ARGN})
    message(FATAL_ERROR "Assertion failed [${PREFIX} ${FIRST} ${ARGN_SP}]")
  endif()
endfunction()

function(assert_quoted PREFIX FIRST)
  string(REPLACE ";" " " ARGN_SP "${ARGN}")
  if(${PREFIX} "${FIRST}" ${ARGN})
    message(FATAL_ERROR "Assertion failed [${PREFIX} \"${FIRST}\" ${ARGN_SP}]")
  endif()
endfunction()

function(assert FIRST)
  assert_unquoted(NOT ${FIRST} ${ARGN})
  assert_quoted("" ${FIRST} ${ARGN})
endfunction()

assert(MYTRUE)

assert(FOO MATCHES "^BAR$")

assert(MYNUMBER LESS 4)
assert(MYNUMBER GREATER 2)
assert(MYNUMBER EQUAL 3)

assert(FOO STRLESS CCC)
assert(BAZ STRGREATER CCC)
assert(FOO STREQUAL BAR)

assert_unquoted(NOT MYVERSION VERSION_LESS 3.1)
assert_unquoted("" MYVERSION VERSION_LESS 2.9)

assert_quoted(NOT MYVERSION VERSION_LESS 2.9)
assert_quoted(NOT MYVERSION VERSION_LESS 3.1)

assert(MYVERSION VERSION_GREATER 2.9)
assert(MYVERSION VERSION_EQUAL 3.0)