Closed Dimitrius-dev closed 1 month ago
Hi @Dimitrius-dev
Please check the messages that appear when you conan install
the dependencies, they will print the find_package()
and the target names to use when target_link_libraries()
.
I think the issue might be a mispelling on the boost target, the correct target name would be Boost::boost
the first with uppercase.
Please also note that the example in this page for package_info()
is not designed as a base to derive your work, just as a base to explain the concepts in the tutorial. It might be missing some parts like package_type
that can be necessary to create a fully usable package when adding other transitive dependencies.
If the target typo above doesn't fix, please try to detail a bit more the exact steps, including the commands you are using to reproduce. Thanks for the feedback
The general target to link boost
is boost::boost
according official Conancenter repo. Therefore cmake find_package with REQUIRED
parameter did not stop the process. I suppose something is blocking inclusion of boost headers to the project. And there is no cmake target that matches with the conanfile project name.
I used command conan create .
. And I have already installed by conan boost 1.84.0.
I resolved this case adding lines self.cpp_info.components["network"].requires = ["boost::boost"]
and self.requires(transitive_headers=True)
in package_info
method. I assumed all requirements are open to all targets by default. And it is not, found example in https://github.com/mpusz/mp-units/blob/master/conanfile.py.
I really appreciate your time and your help. Thank you)
Note that the official ConanCenter recipes uses targets such as Boost::xxxx
the first with uppercase, see it in https://github.com/conan-io/conan-center-index/blob/efd720ca6e8ac24f62d59ee73a43452d4a832fe0/recipes/boost/all/test_package/CMakeLists.txt#L21, see also https://github.com/conan-io/conan-center-index/blob/efd720ca6e8ac24f62d59ee73a43452d4a832fe0/recipes/boost/all/conanfile.py#L1755. that uses Boost::boost
.
The find_package(Boost ...)
is correct, it is the target name that could be a problem
self.cpp_info.components["network"].requires = ["boost::boost"]
This is correct, the cpp_info.requires
uses the "package" reference, which is always lowercase, this is not the same as the CMake target name.
Thanks for the feedback!
So does the conancenter boost repo contain invalid boost target in readme file?
And does conan provide general lib target by default. I mean some lib "testlib" has components named ("a", "b"), so conan creates target testlib::testlib
which is linked with a, b, c, right?
Sorry, you were correct.
Boost::boost
is an alias of Boost::headers
, while boost::boost
is the target that aggregates all libraries, including compiled ones, I got confused while reading the test_package/conanfile.py
.
Description:
When i link external lib (like a boost) to my custom lib everything works fine. I tried to do the same with the lib that consists of several components and it did not work. For simplicity i took one of these examples to explain.
I used example of this repo:
examples/conanfile/package_info/components
These code was modified a little.
conanfile.py
network.h
network.h
CMakeLists.txt
The error i received:
_The file boost/asio/iocontext.hpp is in boost lib.
Question
Should i add some code to conanfile.py to fix this in this case?