diff options
author | Vincent Ambo <tazjin@google.com> | 2020-05-27T00·26+0100 |
---|---|---|
committer | Vincent Ambo <tazjin@google.com> | 2020-05-27T00·26+0100 |
commit | 6941048b7e55ec85ec257c4f597e7f0d54e1584d (patch) | |
tree | 35b90141e36142f5ebb5910fc0b08e0018e4486a /third_party/glog/cmake/GetCacheVariables.cmake | |
parent | 7dc094173b641c78a449395cc6f28a5e52b6fe64 (diff) | |
parent | afe04691aca3f669f517adaeb5bd4a87a481fb4a (diff) |
merge(3p/glog): Vendor glog from commit 'afe04691' r/863
Diffstat (limited to 'third_party/glog/cmake/GetCacheVariables.cmake')
-rw-r--r-- | third_party/glog/cmake/GetCacheVariables.cmake | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/third_party/glog/cmake/GetCacheVariables.cmake b/third_party/glog/cmake/GetCacheVariables.cmake new file mode 100644 index 000000000000..20485a8c8f8f --- /dev/null +++ b/third_party/glog/cmake/GetCacheVariables.cmake @@ -0,0 +1,63 @@ +cmake_policy (PUSH) +cmake_policy (VERSION 3.3) + +include (CMakeParseArguments) + +function (get_cache_variables _CACHEVARS) + set (_SINGLE) + set (_MULTI EXCLUDE) + set (_OPTIONS) + + cmake_parse_arguments (_ARGS "${_OPTIONS}" "${_SINGLE}" "${_MULTI}" ${ARGS} ${ARGN}) + + get_cmake_property (_VARIABLES VARIABLES) + + set (CACHEVARS) + + foreach (_VAR ${_VARIABLES}) + if (DEFINED _ARGS_EXCLUDE) + if ("${_VAR}" IN_LIST _ARGS_EXCLUDE) + continue () + endif ("${_VAR}" IN_LIST _ARGS_EXCLUDE) + endif (DEFINED _ARGS_EXCLUDE) + + get_property (_CACHEVARTYPE CACHE ${_VAR} PROPERTY TYPE) + + if ("${_CACHEVARTYPE}" STREQUAL INTERNAL OR + "${_CACHEVARTYPE}" STREQUAL STATIC OR + "${_CACHEVARTYPE}" STREQUAL UNINITIALIZED) + continue () + endif ("${_CACHEVARTYPE}" STREQUAL INTERNAL OR + "${_CACHEVARTYPE}" STREQUAL STATIC OR + "${_CACHEVARTYPE}" STREQUAL UNINITIALIZED) + + get_property (_CACHEVARVAL CACHE ${_VAR} PROPERTY VALUE) + + if ("${_CACHEVARVAL}" STREQUAL "") + continue () + endif ("${_CACHEVARVAL}" STREQUAL "") + + get_property (_CACHEVARDOC CACHE ${_VAR} PROPERTY HELPSTRING) + + # Escape " in values + string (REPLACE "\"" "\\\"" _CACHEVARVAL "${_CACHEVARVAL}") + # Escape " in help strings + string (REPLACE "\"" "\\\"" _CACHEVARDOC "${_CACHEVARDOC}") + # Escape ; in values + string (REPLACE ";" "\\\;" _CACHEVARVAL "${_CACHEVARVAL}") + # Escape backslash in values + string (REGEX REPLACE "\\\\([^\"])" "\\\\\\1" _CACHEVARVAL "${_CACHEVARVAL}") + + if (NOT "${_CACHEVARTYPE}" STREQUAL BOOL) + set (_CACHEVARVAL "\"${_CACHEVARVAL}\"") + endif (NOT "${_CACHEVARTYPE}" STREQUAL BOOL) + + if (NOT "${_CACHEVARTYPE}" STREQUAL "" AND NOT "${_CACHEVARVAL}" STREQUAL "") + set (CACHEVARS "${CACHEVARS}set (${_VAR} ${_CACHEVARVAL} CACHE ${_CACHEVARTYPE} \"${_CACHEVARDOC}\")\n") + endif (NOT "${_CACHEVARTYPE}" STREQUAL "" AND NOT "${_CACHEVARVAL}" STREQUAL "") + endforeach (_VAR) + + set (${_CACHEVARS} ${CACHEVARS} PARENT_SCOPE) +endfunction (get_cache_variables) + +cmake_policy (POP) |