aboutsummaryrefslogtreecommitdiff
path: root/vcpkg/scripts/cmake/z_vcpkg_escape_regex_control_characters.cmake
diff options
context:
space:
mode:
authorEthan Morgan <ethan@gweithio.com>2026-02-14 16:44:06 +0000
committerEthan Morgan <ethan@gweithio.com>2026-02-14 16:44:06 +0000
commit54409423f767d8b1cf30cb7d0efca6b4ca138823 (patch)
treed915ac7828703ce4b963efdd9728a1777ba18c1e /vcpkg/scripts/cmake/z_vcpkg_escape_regex_control_characters.cmake
move to own git serverHEADmaster
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()