Closed Dimitrius-dev closed 1 week ago
Hi @Dimitrius-dev thanks a lot for taking the time to report your issue, we appreciate it :)
I'd say that this is not a bug, but expected Conan behaviour. There are two points worth discussing here:
If your library uses symbols from a library, then it's considered a direct dependency and it's good practice not to rely on transitive dependencies to provide them, but directly specify the direct dependency appropiately where necessary.
The key here is also to understand how Conan 2 decides what information to propagate downstream in the graph, with the so called traits
in each requirement (Docs here)
In your case, if from lib2
you'd need its dependencies' headers/libs to be propagated to lib1
(because lib2
exposes them in its public API for example), then you'd need to set the transitive_headers=True
trait, which will expose the include path of that holib1
dependency to its direct lib1
dependant. (So self.requires("holib1/1.0", transitive_headers=True)
)
The traits can be set in two different ways, by directly adding them in the requirements clause as shown above, or inferred by the package_type
of your packages
(In this case holib1
and 2 would be package_type = "header-only"
and lib1
and 2 package_type = "library"
. This would automatically infer the traits based on this table)
I go into a bit more detail on all of this for a similar case in https://github.com/conan-io/conan/issues/14600#issuecomment-1696353532 if you want some extra read with some diagrams and all!
Let me know if that helps, I can else provide the practical example if I find a bit of time :)
Thank you a lot. I got some info from this docs topics, so there is no need for detailed explanation.
As you wrote there are two ways to declare transitive requirement. I tried the second one (package_type
) and it did not work (i got the the error that i described above. The first approach resolved the problem (transitive_headers
).
I tried the second one (package_type) and it did not work
This is because the package_type is only used to infer the traits of your dependencies, which might not align with your expectations :)
The recommended "full" approach would then be to:
package_type
always (Possible values are documented here)Happy to hear you got this fixed, please feel free to reopen/create a new issue should you have any more questions :)
What is your question?
Hi, i found out that some case is not working with conan tools.
Example:
I simplified example. There are 4 libs:
lib1
- simple liblib2
- simple libholib1
- header-only libholib2
- header-only libThe top is
lib1
: The linking sequence islib1
<-nolib1
<-lib2
<-nolib2
All of links are PUBLIC or INTERFACE, so theoretically
lib1
is able to use functionality ofholib1
,lib2
,holib2
lib1
has includes in its headerWithout conan the project compiles fine.
With conan
lib1
has access only toholib1
and nothing else. Error:Project files are listed below in linking order.
My settings:
Questions:
lib2
,holib1
,holib2
?Perhaps there is some conanfile feature for it.
lib1
CMakeLists.txt:
conanfile.py
holib1
CMakeLists.txt
conanfile.py
lib2
CMakeLists.txt:
conanfile.py
holib2
CMakeLists.txt
conanfile.py
Have you read the CONTRIBUTING guide?