-
Notifications
You must be signed in to change notification settings - Fork 986
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
[question] How to limit CMake components' propagated dependencies? #17368
Comments
Thanks for your question. If I understood correctly, the If that is the case the
How this is happening. Who and how is linking Note that in any case So in your case both components will always propagate linkage requirements to the transitive dependencies. Please let me know if this helps. |
Thank you @memsharded for quick response, Not exactly, my bad - I've skipped fragment of code which sets recipe's
Could you please elaborate on that? I don't exactly understand how to determine if library is transitive or not. It sounds like they just "stick" to every target declared in the CMake, even if not linked. Does it make the dependencies declared in recipe's In my case On the contrary is
My other projects. I place
or
That is, I would like them to be distinct also in propagated linkage - so by linking the Please let me know if that could be done. Maybe I don't understand something fundamental in C++ linkage system or CMake's/Conan's behaviour. |
Yes, I don't think this is a Conan or CMake issue, it is a linking issue. When you have:
When you are linking So regarding library linkage, there is no way to not link the transitive dependencies, it doesn't depend on Conan 1 or Conan 2 at all, not even depend on Conan or CMake. Regarding the headers, Conan 1 can't do the headers isolation, but Conan 2 will also hide the |
I think I got it sorted. I needed some time to digest the fact that static libraries are not being linked to another ones, thus calling |
Conan 2 will effectively and automatically hide include directories of transitive dependencies by default
They don't come from |
What is your question?
Recently I've started a thread on stackoverflow, where one responders suggested that the problem I've met with might be an issue in Conan, so I'll paste the problem's description here:
I would like to optimize my CMake project, which uses Conan as dependency management tool. It is an executable, which depends on few Conan libraries. However, the need for sharing some headers and some dependencies arose, so I've split the project, resulting in two new targets additional to the already existing executable target.
I want to link those targets/components to various other projects, depending on the needs. They both share distinct headers and links. The thing is, I can't force CMake or Conan to respect this distinction and I've started to doubt if that's even possible.
To be more precise: I mean that, by linking
myproject::myLib
in another project, I don't want to include other libs, which would be, let's say, Boost, OpenSSL andMyOtherLib
, which are linked tomyproject::iface
with INTERFACE scope and indirectly tomyExecutable
(thanks to linkingiface
component). Is this possible?I'm using GCC 14.2, CMake 3.26 and Conan 1.65.0.
CMakeLists.txt:
conanfile.py
I've tried many things. At the beginning, I had problems with including headers of both components but I've managed to fix it with CMake's install:
However, the problem was still the fact that linking
myproject::myLib
effects with linking all other libraries.I've tried to add the component info in
cpp_info
section of the Conan file, hoping that, in setting therequires
field, I would be able to 'override' some default generated dependencies:No effect though. Linking
myproject::myLib
is still linking Boost and other libraries, which I would like to avoid without atomizing the project.Any ideas how could I achieve this division of propagated links, when all targets/components are defined in one CMake project and one Conan file? Is that even possible without separating targets to distinct project with their own CMakeLists and Conan files?
Have you read the CONTRIBUTING guide?
The text was updated successfully, but these errors were encountered: