This repository was archived by the owner on Apr 18, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBA_PACKAGE_VARS.cmake
More file actions
70 lines (63 loc) · 2.11 KB
/
BA_PACKAGE_VARS.cmake
File metadata and controls
70 lines (63 loc) · 2.11 KB
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
##
#
# BringAuto Package Variables
#
# Variables and Setter/Getter functions.
# - Every variable has a name (var_name).
# - Every variable accessed by Setter/Getter should
# be stored as INTERNAL cache variable.
# - Every variable is stored as a CMake cache variable with name BA_PACKAGE_VARS__<var_name>.
# Double _ is chosen to not need define a reserved variable names SET and GET.
# - Every variable shall be set/get by a SetterGetter function.
#
# Mechanism of Setter/Getter was chosen in order to simplify
# future maintenance and "configuration" (in backward compatibility manner)
#
# Example of REVISION
# BA_PACKAGE_VARS_SET(REVISION "main")
#
SET(BA_PACKAGE_VARS__REVISION "master"
CACHE INTERNAL
"Package repository revision to use"
)
##
#
# It sets the variable value.
#
# <function>(
# var_name // uppercase variable name
# va_value // variable value to set
# )
#
FUNCTION(BA_PACKAGE_VARS_SET var_name var_value)
IF(NOT var_name)
MESSAGE(FATAL_ERROR "Package tracker variable invalid set. Variable name not specified!")
ENDIF()
SET(cache_var_name "BA_PACKAGE_VARS__${var_name}")
IF(NOT DEFINED ${cache_var_name})
MESSAGE(FATAL_ERROR "Package variable invalid set. Trying to se non-defined BA_PACKAGE variable '${var_name}'")
ENDIF()
SET_PROPERTY(CACHE ${cache_var_name} PROPERTY VALUE "${var_value}")
ENDFUNCTION()
##
#
# It gets the variable value.
#
# <function>(
# var_name // uppercase variable name
# va_value // variable value to set
# )
#
FUNCTION(BA_PACKAGE_VARS_GET var_name output_var_name)
IF(NOT var_name)
MESSAGE(FATAL_ERROR "Package tracker variable invalid get. Variable name not specified!")
ENDIF()
SET(cache_var_name "BA_PACKAGE_VARS__${var_name}")
IF(NOT DEFINED ${cache_var_name})
MESSAGE(FATAL_ERROR "Package variable invalid get. Trying to set non-defined BA_PACKAGE variable '${var_name}'")
ENDIF()
IF(NOT output_var_name)
MESSAGE(FATAL_ERROR "Package tracker variable invalid get. Output var name is not defined!")
ENDIF()
SET(${output_var_name} ${${cache_var_name}} PARENT_SCOPE)
ENDFUNCTION()