--- protobuf-36.2/cmake/protobuf-config.cmake.in.orig 2026-10-17 20:48:10.964941560 +0200 +++ protobuf-36.2/cmake/protobuf-config.cmake.in 2026-10-17 20:48:10.974023059 +0200 @@ -9,6 +9,19 @@ include("${CMAKE_CURRENT_LIST_DIR}/proto # Imported targets include("${CMAKE_CURRENT_LIST_DIR}/protobuf-targets.cmake") +# the target protoc can not run when cross compiling, use the build host one +if(CMAKE_CROSSCOMPILING AND TARGET protobuf::protoc) + find_program(protobuf_HOST_PROTOC protoc NO_CMAKE_FIND_ROOT_PATH) + if(protobuf_HOST_PROTOC) + get_target_property(_protobuf_protoc_configs protobuf::protoc IMPORTED_CONFIGURATIONS) + foreach(_protobuf_config ${_protobuf_protoc_configs}) + set_target_properties(protobuf::protoc PROPERTIES + IMPORTED_LOCATION_${_protobuf_config} "${protobuf_HOST_PROTOC}") + endforeach() + set_target_properties(protobuf::protoc PROPERTIES IMPORTED_LOCATION "${protobuf_HOST_PROTOC}") + endif() +endif() + # protobuf-generate function include("${CMAKE_CURRENT_LIST_DIR}/protobuf-generate.cmake")