Skip to content

Commit 05ad652

Browse files
Only substitute prefixes during installation setup.
This caused an issue on some platforms where `protobuf/java/core/src/main/java/com/google/protobuf/java_features.proto` was getting turned into the invalid path `java/core/src/main/java/com/google/java_features.proto`. Fixes #14862 PiperOrigin-RevId: 586478133
1 parent c709a34 commit 05ad652

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

cmake/install.cmake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ foreach(_header ${protobuf_HEADERS})
7878
elseif (_find_nosrc GREATER -1)
7979
set(_from_dir "${protobuf_SOURCE_DIR}")
8080
endif()
81-
string(REPLACE "${_from_dir}" "" _header ${_header})
81+
# On some platforms `_form_dir` ends up being just "protobuf", which can
82+
# easily match multiple times in our paths. We force it to only replace
83+
# prefixes to avoid this case.
84+
string(REGEX REPLACE "^${_from_dir}" "" _header ${_header})
8285
get_filename_component(_extract_from "${_from_dir}/${_header}" ABSOLUTE)
8386
get_filename_component(_extract_name ${_header} NAME)
8487
get_filename_component(_extract_to "${CMAKE_INSTALL_INCLUDEDIR}/${_header}" DIRECTORY)

0 commit comments

Comments
 (0)