Fix CMake regex escaping.

CMake documentation (https://cmake.org/cmake/help/latest/command/string.html#regex-replace) indicates subexpressions are actually referenced via \1 not $1 in cmake.

PiperOrigin-RevId: 606307156
pull/15800/head
Sandy Zhang 10 months ago committed by Copybara-Service
parent 78a3f8a8cb
commit b9273fa7c7
  1. 2
      cmake/install.cmake

@ -79,7 +79,7 @@ foreach(_header ${protobuf_HEADERS})
set(_from_dir "${protobuf_SOURCE_DIR}") set(_from_dir "${protobuf_SOURCE_DIR}")
endif() endif()
# Escape _from_dir for regex special characters in the directory name. # Escape _from_dir for regex special characters in the directory name.
string(REGEX REPLACE "([.+*?\^$()[\]{}|\\])" "\\\\$1" _from_dir_regexp ${_from_dir}) string(REGEX REPLACE "([$^.[|*+?()]|])" "\\\\\\1" _from_dir_regexp "${_from_dir}")
# On some platforms `_form_dir` ends up being just "protobuf", which can # On some platforms `_form_dir` ends up being just "protobuf", which can
# easily match multiple times in our paths. We force it to only replace # easily match multiple times in our paths. We force it to only replace
# prefixes to avoid this case. # prefixes to avoid this case.

Loading…
Cancel
Save