diff --git a/CMakeLists.txt b/CMakeLists.txt index 177296d81c..6f5fbe587c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -419,20 +419,21 @@ if(WITH_OTLP_GRPC endif() endif() endif() - # Latest Protobuf imported targets and without legacy module support - if(TARGET protobuf::protoc) - project_build_tools_get_imported_location(PROTOBUF_PROTOC_EXECUTABLE - protobuf::protoc) - # If protobuf::protoc is not a imported target, then we use the target - # directly for fallback - if(NOT PROTOBUF_PROTOC_EXECUTABLE) - set(PROTOBUF_PROTOC_EXECUTABLE protobuf::protoc) + if(NOT PROTOBUF_PROTOC_EXECUTABLE) + # Latest Protobuf imported targets and without legacy module support + if(TARGET protobuf::protoc) + project_build_tools_get_imported_location(PROTOBUF_PROTOC_EXECUTABLE + protobuf::protoc) + # If protobuf::protoc is not a imported target, then we use the target + # directly for fallback + if(NOT PROTOBUF_PROTOC_EXECUTABLE) + set(PROTOBUF_PROTOC_EXECUTABLE protobuf::protoc) + endif() + elseif(Protobuf_PROTOC_EXECUTABLE) + # Some versions of FindProtobuf.cmake uses mixed case instead of uppercase + set(PROTOBUF_PROTOC_EXECUTABLE ${Protobuf_PROTOC_EXECUTABLE}) endif() - elseif(Protobuf_PROTOC_EXECUTABLE) - # Some versions of FindProtobuf.cmake uses mixed case instead of uppercase - set(PROTOBUF_PROTOC_EXECUTABLE ${Protobuf_PROTOC_EXECUTABLE}) endif() - include(CMakeDependentOption) message(STATUS "PROTOBUF_PROTOC_EXECUTABLE=${PROTOBUF_PROTOC_EXECUTABLE}") set(SAVED_CMAKE_CXX_CLANG_TIDY ${CMAKE_CXX_CLANG_TIDY})