File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -78,10 +78,12 @@ foreach(_header ${protobuf_HEADERS})
7878 elseif (_find_nosrc GREATER -1)
7979 set (_from_dir "${protobuf_SOURCE_DIR} " )
8080 endif ()
81+ # Escape _from_dir for regex special characters in the directory name.
82+ string (REGEX REPLACE "([.+*?\^ $()[\] {}|\\ ])" "\\\\ $1" _from_dir_regexp ${_from_dir} )
8183 # On some platforms `_form_dir` ends up being just "protobuf", which can
8284 # easily match multiple times in our paths. We force it to only replace
8385 # prefixes to avoid this case.
84- string (REGEX REPLACE "^${_from_dir } " "" _header ${_header} )
86+ string (REGEX REPLACE "^${_from_dir_regexp } " "" _header ${_header} )
8587 get_filename_component (_extract_from "${_from_dir} /${_header} " ABSOLUTE )
8688 get_filename_component (_extract_name ${_header} NAME )
8789 get_filename_component (_extract_to "${CMAKE_INSTALL_INCLUDEDIR} /${_header} " DIRECTORY )
You can’t perform that action at this time.
0 commit comments