diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b37ac5c..cb532eb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -22,20 +22,28 @@ use_cxx(etcd-cpp-api-core-objects) add_dependencies(etcd-cpp-api-core-objects protobuf_generates) include_generated_protobuf_files(etcd-cpp-api-core-objects) target_link_libraries(etcd-cpp-api-core-objects PUBLIC - protobuf::libprotobuf ${OPENSSL_LIBRARIES} ${GRPC_LIBRARIES} ) +if(TARGET protobuf::libprotobuf) + target_link_libraries(etcd-cpp-api-core-objects PUBLIC protobuf::libprotobuf) +else() + target_link_libraries(etcd-cpp-api-core-objects PUBLIC ${PROTOBUF_LIBRARIES}) +endif() if(BUILD_ETCD_CORE_ONLY) # add the core library, includes the sycnhronous client only add_library(etcd-cpp-api-core $) use_cxx(etcd-cpp-api-core) target_link_libraries(etcd-cpp-api-core PUBLIC - protobuf::libprotobuf - ${OPENSSL_LIBRARIES} - ${GRPC_LIBRARIES} + ${OPENSSL_LIBRARIES} + ${GRPC_LIBRARIES} ) + if(TARGET protobuf::libprotobuf) + target_link_libraries(etcd-cpp-api-core PUBLIC protobuf::libprotobuf) + else() + target_link_libraries(etcd-cpp-api-core PUBLIC ${PROTOBUF_LIBRARIES}) + endif() include_generated_protobuf_files(etcd-cpp-api-core) else() # add the client with asynchronus client @@ -44,10 +52,14 @@ else() use_cxx(etcd-cpp-api) target_link_libraries(etcd-cpp-api PUBLIC ${CPPREST_LIB} # n.b.: the asynchronous client requires pplx in cpprestsdk - protobuf::libprotobuf ${OPENSSL_LIBRARIES} ${GRPC_LIBRARIES} ) + if(TARGET protobuf::libprotobuf) + target_link_libraries(etcd-cpp-api PUBLIC protobuf::libprotobuf) + else() + target_link_libraries(etcd-cpp-api PUBLIC ${PROTOBUF_LIBRARIES}) + endif() include_generated_protobuf_files(etcd-cpp-api) endif()