Skip to content

Commit 23562e6

Browse files
authored
[BUILD] Fix cross-compilation with protoc (open-telemetry#3186)
1 parent 150256c commit 23562e6

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

CMakeLists.txt

+10-6
Original file line numberDiff line numberDiff line change
@@ -428,12 +428,16 @@ if(WITH_OTLP_GRPC
428428
endif()
429429
# Latest Protobuf imported targets and without legacy module support
430430
if(TARGET protobuf::protoc)
431-
project_build_tools_get_imported_location(PROTOBUF_PROTOC_EXECUTABLE
432-
protobuf::protoc)
433-
# If protobuf::protoc is not a imported target, then we use the target
434-
# directly for fallback
435-
if(NOT PROTOBUF_PROTOC_EXECUTABLE)
436-
set(PROTOBUF_PROTOC_EXECUTABLE protobuf::protoc)
431+
if(CMAKE_CROSSCOMPILING AND Protobuf_PROTOC_EXECUTABLE)
432+
set(PROTOBUF_PROTOC_EXECUTABLE ${Protobuf_PROTOC_EXECUTABLE})
433+
else()
434+
project_build_tools_get_imported_location(PROTOBUF_PROTOC_EXECUTABLE
435+
protobuf::protoc)
436+
# If protobuf::protoc is not a imported target, then we use the target
437+
# directly for fallback
438+
if(NOT PROTOBUF_PROTOC_EXECUTABLE)
439+
set(PROTOBUF_PROTOC_EXECUTABLE protobuf::protoc)
440+
endif()
437441
endif()
438442
elseif(Protobuf_PROTOC_EXECUTABLE)
439443
# Some versions of FindProtobuf.cmake uses mixed case instead of uppercase

0 commit comments

Comments
 (0)