Skip to content

Commit 65da5fd

Browse files
committed
Fix compile error when using cmake and -DWITH_OTLP=ON -DCMAKE_FIND_ROOT_PATH=<PROTOBUF INSTALL PREFIX DIR> with custom prebuilt protobuf. #424
1 parent 7e06316 commit 65da5fd

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

cmake/opentelemetry-proto.cmake

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,19 @@ add_library(
132132
${METRICS_SERVICE_PB_CPP_FILE}
133133
${METRICS_SERVICE_GRPC_PB_CPP_FILE})
134134

135+
if(TARGET protobuf::libprotobuf)
136+
target_link_libraries(opentelemetry_proto
137+
PUBLIC protobuf::libprotobuf
138+
)
139+
else() # cmake 3.8 or lower
140+
target_include_directories(opentelemetry_proto
141+
PUBLIC ${Protobuf_INCLUDE_DIRS}
142+
)
143+
target_include_directories(opentelemetry_proto
144+
INTERFACE ${Protobuf_LIBRARIES}
145+
)
146+
endif()
147+
135148
if(BUILD_SHARED_LIBS)
136149
set_property(TARGET opentelemetry_proto PROPERTY POSITION_INDEPENDENT_CODE ON)
137150
endif()

0 commit comments

Comments
 (0)