-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
glog fails to resolve its gflags dependency when GFLAGS_USE_TARGET_NAMESPACE is ON #18733
Comments
Hi @bucurb Thanks for posting this issue. I have some questions here. Could you please help clarify these? Where do you get For the usage, it's unnecessary to add
|
Hi @NancyLi1013 You're right, it's not necessary to add gflags to my project. However, the problem is with the glog dependency. The GFLAGS_USE_TARGET_NAMESPACE variable is checked here . gflags exposes 2 flavors of targets, one with no namespace and one with the gflags:: namespace. In my project I'd like to set GFLAGS_USE_TARGET_NAMESPACE so that gflags exposes the gflags::gflags target. The problem is glog is not aware of this and continues to reference gflags as its dependency. I'm in a project where everything is statically built to libraries, so in this case the glog -> gflags dependency is resolved when my target is linked, at which point I only have a gflags::gflags target. I think this is not a problem for dll builds, as there glog can happily resolve to gflags privately. |
Is your error like this?
|
When building dynamic, the gflags targets are After reading the generated cmake configuration files, I feel that the contents between them are completely the same except for the namespace. |
@NancyLi1013 yes, exactly |
@JackBoosY so starting from my project's CMakefile:
we end-up in gflags-config.cmake where we hit this:
gflags-targets.cmake only defines gflags::gflags_static
What is defining the non-namespaced gflags_static target? I didn't find anything |
@bucurb Check In summary, the use of any target is consistent. |
@JackBoosY you are right on both counts of course, but I never said there is a difference between the namespaced and non-namespaced targets. Yes, they're identical except for the name, as they should be. I also know about the gflags / gflags::gflags targets being added to simplify picking between static and shared targets. Again, this is not my problem. My problem is that in a project you either get the target gflags or the target gflags::gflags, but not both in the same time - assuming you have a project-wide If you're saying there is a way to have both |
@bucurb Yes, the problem is In addition, we should also provide |
@JackBoosY yup, so that's pretty much what I was trying to achieve with my PR. If you choose to install gflags[target-namespace] then you will get a |
Describe the bug
glog fails to link gflags if used in a project that defines GFLAGS_USE_TARGET_NAMESPACE
Environment
To Reproduce
Steps to reproduce the behavior:
Notice how target blah fails to link as glog depends on target gflags which is not defined due to the gflags:: namespace.
Expected behavior
glog should be able to find gflags::gflags in this case. More generally for the static build case it probably doesn't make a lot of sense to be able to mix gflags and gflags::gflags, so it should be possible to decide on either with or without namespace and have all dependent libraries respect that setting.
Failure logs
N/A
Additional context
N/A
The text was updated successfully, but these errors were encountered: