Skip to content

Commit

Permalink
Fix CMake regex escaping.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
zhangskz committed Feb 14, 2024
1 parent f740f52 commit 3ad69cf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cmake/install.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ foreach(_header ${protobuf_HEADERS})
set(_from_dir "${protobuf_SOURCE_DIR}")
endif()
# 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
# easily match multiple times in our paths. We force it to only replace
# prefixes to avoid this case.
Expand Down

0 comments on commit 3ad69cf

Please sign in to comment.