Fix generation of save-installed-headers.vcxproj regarding upb headers (#18135)

upb headers are not in `${protobuf_SOURCE_DIR}/src`, so the `string(REPLACE ...)` command fails and the `save-installed-headers.vcxproj` contains an invalid path regarding upb headers, causing a failure in compilation.

Closes #18135

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/18135 from Delcaran:main 28c40493e3
PiperOrigin-RevId: 686963169
pull/18883/head
Matteo 5 months ago committed by Copybara-Service
parent 8eef2b3edc
commit bd1806edc3
  1. 16
      cmake/tests.cmake

@ -220,6 +220,8 @@ add_custom_target(restore-installed-headers)
file(GLOB_RECURSE _local_hdrs
"${PROJECT_SOURCE_DIR}/src/*.h"
"${PROJECT_SOURCE_DIR}/src/*.inc"
)
file(GLOB_RECURSE _local_upb_hdrs
"${PROJECT_SOURCE_DIR}/upb/*.h"
)
@ -235,6 +237,7 @@ list(APPEND _exclude_hdrs ${test_util_hdrs} ${lite_test_util_hdrs} ${common_test
${compiler_test_utils_hdrs} ${upb_test_util_files})
foreach(_hdr ${_exclude_hdrs})
list(REMOVE_ITEM _local_hdrs ${_hdr})
list(REMOVE_ITEM _local_upb_hdrs ${_hdr})
endforeach()
foreach(_hdr ${_local_hdrs})
@ -250,6 +253,19 @@ foreach(_hdr ${_local_hdrs})
copy "${_tmp_file}" "${_hdr}")
endforeach()
foreach(_hdr ${_local_upb_hdrs})
string(REPLACE "${protobuf_SOURCE_DIR}/upb" "" _file ${_hdr})
set(_tmp_file "${CMAKE_BINARY_DIR}/tmp-install-test/${_file}")
add_custom_command(TARGET remove-installed-headers PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E remove -f "${_hdr}")
add_custom_command(TARGET save-installed-headers PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E
copy "${_hdr}" "${_tmp_file}" || true)
add_custom_command(TARGET restore-installed-headers PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E
copy "${_tmp_file}" "${_hdr}")
endforeach()
add_dependencies(remove-installed-headers save-installed-headers)
if(protobuf_REMOVE_INSTALLED_HEADERS)
# Make sure we remove all the headers *before* any codegen occurs.

Loading…
Cancel
Save