Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing find_dependency() when OTel plugin is enabled #36624

Closed
Tracked by #14260
coryan opened this issue May 15, 2024 · 3 comments
Closed
Tracked by #14260

Missing find_dependency() when OTel plugin is enabled #36624

coryan opened this issue May 15, 2024 · 3 comments

Comments

@coryan
Copy link
Contributor

coryan commented May 15, 2024

What version of gRPC and what language are you using?

1.63.0, C++.

What operating system (Linux, Windows,...) and version?

Linux

What runtime / compiler are you using (e.g. python version or version of gcc)

Many, but let's say Clang 18 and GCC 14.

What did you do?

Compiled gRPC with:

curl -fsSL https://github.com/grpc/grpc/archive/v1.63.0.tar.gz | \
    tar -xzf - --strip-components=1 && \
    cmake \
      -DCMAKE_BUILD_TYPE=Release \
      -DBUILD_SHARED_LIBS=ON \
      -DgRPC_INSTALL=ON \
      -DgRPC_BUILD_TESTS=OFF \
      -DgRPC_ABSL_PROVIDER=package \
      -DgRPC_CARES_PROVIDER=package \
      -DgRPC_PROTOBUF_PROVIDER=package \
      -DgRPC_PROTOBUF_PACKAGE_TYPE=CONFIG \
      -DgRPC_RE2_PROVIDER=package \
      -DgRPC_SSL_PROVIDER=package \
      -DgRPC_ZLIB_PROVIDER=package \
      -DgRPC_OPENTELEMETRY_PROVIDER=package \
      -DgRPC_BUILD_GRPCPP_OTEL_PLUGIN=ON \
      -GNinja -S . -B cmake-out && \
    cmake --build cmake-out --target install && \
    ldconfig && cd /var/tmp && rm -fr build

Then try to use find_package(gRPC CONFIG REQUIRED)

What did you expect to see?

The gRPC package successfully found.

What did you see instead?

CMake Error at /usr/local/lib/cmake/grpc/gRPCTargets.cmake:223 (set_target_properties):
  The link interface of target "gRPC::grpcpp_otel_plugin" contains:

    opentelemetry-cpp::api

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

Call Stack (most recent call first):
  /usr/local/lib/cmake/grpc/gRPCConfig.cmake:24 (include)
  cmake/FindgRPC.cmake:116 (find_package)
  CMakeLists.txt:205 (find_package)

I think the grpCConfig.cmake file is missing a find_dependency(opentelemetry-cpp) when gRPC is compiled with the OTel plugin enabled.

Anything else we should know about your project / environment?

You know where to find me.

@yashykt
Copy link
Member

yashykt commented May 17, 2024

Hmm, I don't understand. It's present at

find_package(opentelemetry-cpp CONFIG REQUIRED)

and our example builds as well

@coryan
Copy link
Contributor Author

coryan commented May 17, 2024

When somebody is trying to use an installed version gRPC the grpc/cmake/opentelemetry-cpp.cmake file has no effect. That file is not even installed. As part of make install (or cmake --install) gRPC creates a CMake configuration file:

ls -l /usr/local/lib/cmake/grpc/gRPCConfig.cmake 

That file should list all the dependencies for all the targets, but it does not:

$ cat /usr/local/lib/cmake/grpc/gRPCConfig.cmake 
# Module path
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/modules)

# Depend packages
if(NOT ZLIB_FOUND)
  find_package(ZLIB)
endif()
include(CMakeFindDependencyMacro)
find_dependency(Protobuf CONFIG)
if(NOT OPENSSL_FOUND)
  find_package(OpenSSL)
endif()
if(NOT c-ares_FOUND)
  find_package(c-ares)
endif()
if(NOT TARGET absl::strings)
  find_package(absl CONFIG)
endif()
if(NOT re2_FOUND)
  find_package(re2)
endif()

# Targets
include(${CMAKE_CURRENT_LIST_DIR}/gRPCTargets.cmake)
if(NOT CMAKE_CROSSCOMPILING)
  include(${CMAKE_CURRENT_LIST_DIR}/gRPCPluginTargets.cmake)
endif()

@yashykt
Copy link
Member

yashykt commented May 21, 2024

Thanks for the details! @coryan

yashykt added a commit to yashykt/grpc that referenced this issue May 22, 2024
…nfiguration (grpc#36674)

Fix grpc#36624

Closes grpc#36674

COPYBARA_INTEGRATE_REVIEW=grpc#36674 from yashykt:OTelCMakeConfig 80366ae
PiperOrigin-RevId: 635968262
yashykt added a commit to yashykt/grpc that referenced this issue May 22, 2024
…nfiguration (grpc#36674)

Fix grpc#36624

Closes grpc#36674

COPYBARA_INTEGRATE_REVIEW=grpc#36674 from yashykt:OTelCMakeConfig 80366ae
PiperOrigin-RevId: 635968262
jdcormie pushed a commit to jdcormie/grpc that referenced this issue May 24, 2024
…nfiguration (grpc#36674)

Fix grpc#36624

Closes grpc#36674

COPYBARA_INTEGRATE_REVIEW=grpc#36674 from yashykt:OTelCMakeConfig 80366ae
PiperOrigin-RevId: 635968262
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants