-
Notifications
You must be signed in to change notification settings - Fork 0
/
pm__core.vars.cmake
79 lines (65 loc) · 1.82 KB
/
pm__core.vars.cmake
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
include_guard(GLOBAL)
include(pm__core.list_join)
include(pm__core.msg)
function(pm_print_var VARn)
if(DEFINED ${VARn})
__pm_list__join(${VARn} ", " PRETTY)
pm_status("${VARn} :: ${PRETTY}")
else()
pm_status("${VARn} is not defined!")
endif()
endfunction()
function(pm_print_is_var_defined VARn)
if(DEFINED ${VARn})
pm_status("${VARn} :: is defined")
else()
pm_status("${VARn} :: is not defined")
endif()
endfunction()
function(pm_print_raw_list LISTln)
# This regex is designed to replace un-escaped semicolons with escaped
# semicolons, s.t. passing the new string into `pm_status` will result in
# printed semicolons.
# Apparently, that means 8 `\`s in the replacement string.
# Thanks, CMake.
string(REGEX REPLACE "([^\\]|^);" "\\1\\\\\\\\;" PRETTY "${ARGN}")
pm_status("${LISTln} :: ${PRETTY}")
endfunction()
function(pm_is_var_set OUTn VARn)
if(DEFINED ${VARn})
set(${OUTn} TRUE PARENT_SCOPE)
else()
set(${OUTn} FALSE PARENT_SCOPE)
endif()
endfunction()
function(pm_is_var_unset OUTn VARn)
if(NOT DEFINED ${VARn})
set(${OUTn} TRUE PARENT_SCOPE)
else()
set(${OUTn} FALSE PARENT_SCOPE)
endif()
endfunction()
function(pm_is_var_truthy OUTn VARn)
if(${VARn})
set(${OUTn} TRUE PARENT_SCOPE)
else()
set(${OUTn} FALSE PARENT_SCOPE)
endif()
endfunction()
function(pm_is_var_falsy OUTn VARn)
if(NOT ${VARn})
set(${OUTn} TRUE PARENT_SCOPE)
else()
set(${OUTn} FALSE PARENT_SCOPE)
endif()
endfunction()
function(pm_set_if_unset VARn VAL)
if(NOT DEFINED ${VARn})
set(${VARn} ${VAL} PARENT_SCOPE)
endif()
endfunction()
function(pm_set_if_falsy VARn VAL)
if(NOT ${VARn})
set(${VARn} ${VAL} PARENT_SCOPE)
endif()
endfunction()