Open fekir opened 1 year ago
Hi @fekir
Thanks for your question.
I am afraid this is not possible, because the interface is very different. Conan needs at least the package name
and version
. The libname
might be the same as the package name (but not mandatory), and the version is not even there.
There are also other side issues, for example, it is very important that dependencies are resolved together, as there can be version conflicts, propagation of options and other things, that really doesn't work if you evaluate dependencies one at a time, that only works for very flat hierarchies of dependencies (that is the reason the version is not even necessary there).
What might be possible is to just deactivate the FetchContent in the provider, and then rely on the normal find_package()
provider (and the definition of a conanfile
), but I am afraid that just deactivating FetchContent will not be good for many users that are using it and don't want Conan to mess with it.
Hi @memsharded
my intention was to take advantage of conan for third-party cmake files without changing them. My experience with conan is very limited, thus my naive question.
My understanding was that (for the download and caching part), the content is what matters, as hashes are used to avoid collisions.
I would have hoped that the function in conan_support.cmake
for fetching could eventually add a dummy version number if it was really necessary.
But if conan download
cannot download the data directly (similarly to curl/wget/...), then I guess I'm completely out of luck, unless there is another API for downloading and caching data or way I can take advantage of conan caching mechanism.
My understanding was that (for the download and caching part), the content is what matters, as hashes are used to avoid collisions.
When using a package manager, the "address" of the contents is what matters, all package managers refer to contents as "package/version" or a similar abstraction. A hash is not good enough the moment that there is a graph with more than one dependency, transitive dependencies, and things like version conflicts can exist (and they are very common, when you have diamond structures, app -> pkga -> common/1.0, and app->pkgb -> common/2.0)
But if conan download cannot download the data directly (similarly to curl/wget/...), then I guess I'm completely out of luck, unless there is another API for downloading and caching data or way I can take advantage of conan caching mechanism.
Yes, conan download
is able to download a Conan package, but it needs the version (and other abstractions like the revision
too).
The thing is that FetchContent and a package manager are quite opposite, colliding strategies for dependency management. find_package()
is a slightly better abstraction that allows to plug-in Conan with the dependency provider.
When using a package manager, the "address" of the contents is what matters, all package managers refer to contents as "package/version" or a similar abstraction. A hash is not good enough the moment that there is a graph with more than one dependency, transitive dependencies, and things like version conflicts can exist (and they are very common, when you have diamond structures, app -> pkga -> common/1.0, and app->pkgb -> common/2.0)
This is why I wrote "for the download and caching part", and I am not sure if your description disagrees with it.
Yes, for handling dependencies and deciding what to use in a given project (once it has been downloaded) the content is obviously not sufficient.
Hello @fekir, this is generally not how we suggest integrating Conan and CMake, especially when starting out and learning it.
You can very easily install third-party sources and use them from CMake https://docs.conan.io/2/tutorial/consuming_packages/build_simple_cmake_project.html, it just takes and extra command conan install .
before calling CMake.
This auxiliary project is mostly for a convince for hopefully skipping that one command line call :)
I'd suggest going through the tutorial to learn more about how Conan works :)
This is more a question than an issue
Suppose I have a cmake project that internally does
SET_DEPENDENCY_PROVIDER
(https://cmake.org/cmake/help/latest/command/cmake_language.html#set-dependency-provider) feature of cmake to let conan download and cache the dependency without changing the cmake file?conan download
?