-
Notifications
You must be signed in to change notification settings - Fork 989
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
[bug] Problems with CMakeDeps generator #16911
Comments
This seems connected to this: conan-io/conan-center-index#24806, it is possible that it is a recipe issuel, will investigate |
As described in #16898 (comment), the fact that We are trying to reproduce with a full minimal example, but so far can't. |
Interesting... With the described steps, I reproduce it easily, all the time. |
Yes, we would need a full example that produces the linking errors that other users are seeing. I think it is related, but the above setup is not enough:
So what is needed is a full repro case that:
So having the full consumer |
Actually I'm quite surprised now that I'm reading git history of grpc recipe. I've added transitive_libs for abseil in conan-io/conan-center-index#17284 (it was already there for protobuf), but it has been removed later on for abseil & protobuf by conan-io/conan-center-index#24215 (while keeping transitive_headers, which is quite weird, those libs are not header-only so if headers are public, libs are also public). Why? I even provided a link conan-io/conan-center-index#17284 (comment) which was quite self explanatory for the reason why transitive_libs was required. So actually it might be a recipe issue. Moreover test package has been so simplified in conan-io/conan-center-index#24215 that it can't properly test anymore this kind of link issue. |
I hope the following is a better example. Take two files - test_package.cpp and helloworld.proto, from the previous version of grpc recipe Add CMakeLists.txt:
Add conanfile.txt:
Configure
Build:
Add protobuf into conanfile.txt:
configure, build. The output now says
|
Apologies for the grpc/abseil case - this is a regression that I introduced when adding the new version. fix here: https://github.com/conan-io/conan-center-index/pull/25087/files
Arguably, that is an overarching generalisation which does not apply to all cases. The case at hand (grpc) is different - the references are mostly in generated code (by protoc) in the consumer side - so it's neither of the cases above - in order to determine what is transitive we need to check the generated code too.
CMake's Whereas Conan's From what I can see, equivalent functionality was requested in CMake here And was implemented in CMake 3.27 as the thus I do like CMake's PRIVATE/PUBLIC/INTERFACE, but in practice, they do not map 1:1 with the Conan 2 traits, they map to the low-level behaviour of CMake ( Perhaps there is a case for Conan to give the ability to express in the recipe that consumers will reference symbols from a transitive dependency that may require propagating a linking library, depending on the specific combination of shared/static that we have.
I remember testing the new recipe revision against the old test_package, as well as other consumers that existed in Conan Center, manually, precisely to avoid this kind of regression. Bad on my part, as I clearly did not test the specific platforms where this issue arises. |
Thanks @gouriano for providing more details. The abseil build error is being fixed in https://github.com/conan-io/conan-center-index/pull/25087/files which will be merged today. As for the protobuf errors, if you are calling Abseil, on the other hand is implicit and unknown to the consumer - hence the need for the fix. |
I disagree. I do not see why protobuf is different than abseil. |
Using
Linking directly with libprotobuf when using gRPC C++ with protobuf generate, is also what all the grpc examples do, which is what was missing from your code
As well as explicit calls to both
This is also what we had in in the original test package: What we are advocating for and supporting in the recipe is to use gRPC in line with how it is in the gRPC examples and documentation. Abseil is different because it is used with (almost) zero visibility on the consumer side. |
FWIW, if I remember it correctly, theoretically gRPC can use other protocols (not protobuf). Not sure if anybody does that nowadays though. |
Any further question here @gouriano? |
Describe the bug
Environment:
Linux
cmake 3.21.2
conan 2.6.0
I have a problem linking against gRPC, but the real problem seems to be in CMakeDeps generator.
It fails to generate proper library settings for dependent packages (in this case, abseil and protobuf)
How to reproduce it
Take test_package.cpp source file from abseil recipe
https://github.com/conan-io/conan-center-index/blob/master/recipes/abseil/all/test_package/test_package.cpp
Create CMakeLists.txt
and create the following conanfile.txt:
Yes, require grpc (which requires abseil, as we know)
Now run
conan install . --build missing -s build_type=Release
and look at build/Release/generators/absl-release-x86_64-data.cmake
we see:
set(abseil_LIBS_RELEASE )
The list is empty.
Now delete build directory, add abseil into conanfile.txt, and do "conan install" again
Now in absl-release-x86_64-data.cmake we see
set(abseil_LIBS_RELEASE absl_flags_parse absl_log_flags .. and the long list of libraries)
I believe, it is a bug?
I do not know what is abseil and I do not care.
What I need is grpc. I request grpc, I "find_package(gRPC)", and then linking fails because abseil libraries are missing
The same story is with protobuf.
If it is absent in the list of requires, protobuf_LIBS_RELEASE list in protobuf-release-x86_64-data.cmake file is empty.
If present, protobuf_LIBS_RELEASE list is not empty.
It is so in "shared" mode only. in "shared=False", everything works as expected - LIBS_RELEASE lists are never empty
The text was updated successfully, but these errors were encountered: