Changeset View
Changeset View
Standalone View
Standalone View
cmake/modules/SanitizeHelper.cmake
Show All 24 Lines | |||||
# Sanitize a variable intended to be used in a C/CXX #define statement. | # Sanitize a variable intended to be used in a C/CXX #define statement. | ||||
# This is useful when using CHECK_<C|CXX>_COMPILER_FLAG or similar functions. | # This is useful when using CHECK_<C|CXX>_COMPILER_FLAG or similar functions. | ||||
macro(sanitize_c_cxx_definition PREFIX RAW_VAR SANITIZED_VAR) | macro(sanitize_c_cxx_definition PREFIX RAW_VAR SANITIZED_VAR) | ||||
# Only allow for alphanum chars plus underscore. This will prevent the | # Only allow for alphanum chars plus underscore. This will prevent the | ||||
# compiler to issue a warning like: | # compiler to issue a warning like: | ||||
# `ISO C99 requires whitespace after the macro name [-Wc99-extensions]` | # `ISO C99 requires whitespace after the macro name [-Wc99-extensions]` | ||||
_sanitize("([^a-zA-Z0-9_])" "_" "${PREFIX}${RAW_VAR}" ${SANITIZED_VAR}) | _sanitize("([^a-zA-Z0-9_])" "_" "${PREFIX}${RAW_VAR}" ${SANITIZED_VAR}) | ||||
endmacro() | endmacro() | ||||
# Sanitize a variable intended to be used as a cmake target name. | |||||
macro(sanitize_target_name PREFIX RAW_VAR SANITIZED_VAR) | |||||
# Target names may contain upper and lower case letters, numbers, | |||||
# underscore, dot, plus and minus. | |||||
_sanitize("([^a-zA-Z0-9_.+-])" "-" "${PREFIX}${RAW_VAR}" ${SANITIZED_VAR}) | |||||
endmacro() |