aboutsummaryrefslogtreecommitdiff
path: root/vcpkg/scripts/cmake/z_vcpkg_escape_regex_control_characters.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'vcpkg/scripts/cmake/z_vcpkg_escape_regex_control_characters.cmake')
-rw-r--r--vcpkg/scripts/cmake/z_vcpkg_escape_regex_control_characters.cmake8
1 files changed, 8 insertions, 0 deletions
diff --git a/vcpkg/scripts/cmake/z_vcpkg_escape_regex_control_characters.cmake b/vcpkg/scripts/cmake/z_vcpkg_escape_regex_control_characters.cmake
new file mode 100644
index 0000000..b238f00
--- /dev/null
+++ b/vcpkg/scripts/cmake/z_vcpkg_escape_regex_control_characters.cmake
@@ -0,0 +1,8 @@
+function(z_vcpkg_escape_regex_control_characters out_var string)
+ if(ARGC GREATER "2")
+ message(FATAL_ERROR "z_vcpkg_escape_regex_control_characters passed extra arguments: ${ARGN}")
+ endif()
+ # uses | instead of [] to avoid confusion; additionally, CMake doesn't support `]` in a `[]`
+ string(REGEX REPLACE [[\[|\]|\(|\)|\.|\+|\*|\^|\\|\$|\?|\|]] [[\\\0]] escaped_content "${string}")
+ set("${out_var}" "${escaped_content}" PARENT_SCOPE)
+endfunction()