You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't understand the platform_requires feature or rather what use-cases it was designed for. As far as I understood it just removes the listed requirements from the dependency graph. However, it is not clear to me what problem this is supposed to solve, it rather generates new ones. Most consumers have a find_package for the corresponding libraries in their CMakeLists, but as far as I can see, it would not be able to find a library in CONFIG mode in the case of a platform_requires, as no config file is generated for the library. The standard find module of CMake (if one exists) could possibly find the library in the sysroot in MODULE mode, but this is not a universal solution, because there could also be other requirements in the graph that depend on this library. These could not retrieve any meta information about the library at Conan level, as this is not generated anywhere. Also the default find module name in CMake is not guaranteed to be the same as the one used by the corresponding Conan recipes. Even if the consumer does not do find_package in CMakeLists, but links directly to the lib file, platform_requires is not useful in my opinion, because the CMakeLists would then no longer be Conan-agnostic because you would need two different paths for builds with or without Conan (or maybe with or without platform_requires).
Have you read the CONTRIBUTING guide?
I've read the CONTRIBUTING guide
The text was updated successfully, but these errors were encountered:
Most consumers have a find_package for the corresponding libraries in their CMakeLists, but as far as I can see, it would not be able to find a library in CONFIG mode in the case of a platform_requires, as no config file is generated for the library. The standard find module of CMake (if one exists) could possibly find the library in the sysroot in MODULE mode, but this is not a universal solution, because there could also be other requirements in the graph that depend on this library.
Note that the system openssl must be available and usable for consumers to link it fully transparently, as Conan will no longer be injecting any information about it to the consumers. Having such a transparent usage will not be possible in many cases, because consumers still need some extra information to locate and use those system installed dependencies. In that case the following [replace_requires] will be the recommended approach:
It basically means that for a platform_requires to work it is necessary:
That the dependency exists in the system, and it is fully C/C++ API compatible
That the necessary files to consume that dependency, like xxx-config.cmake files or findxxx.cmake modules exist and can be found by the build tool (as Conan will not be providing the path to those)
That the interface provided by the system files for that dependency, like the above xxx-config.cmake/findxxx.cmake files is fully compatible with the replaced ones, for example if replacing zlib by zlib-ng, the zlib-ng files must define a ZLIB::ZLIB target too.
This is unlikely to happen transparently in most cases. Still there are some users that control well their system/platform dependencies and the corresponding system .cmake files, and can achieve this. This doesn't mean that they have to condition their CMakeLists.txt (sometimes they do), but it is possible to inject extra paths to locate the .cmake files to use those platform dependencies via presets, toolchains or variables.
This is why the blog post describes that in practice in most situations this will not work transparently, only for [platform_tool_requires], and for typical requires it might need [replace_requires] custom recipes that can adapt/wrap the contents to match the consumers.
I have read the docs and it is true that the Conan docs doesn't clearly define this scope and issues, so let's try to add some clarifications there.
What is your question?
I don't understand the
platform_requires
feature or rather what use-cases it was designed for. As far as I understood it just removes the listed requirements from the dependency graph. However, it is not clear to me what problem this is supposed to solve, it rather generates new ones. Most consumers have afind_package
for the corresponding libraries in their CMakeLists, but as far as I can see, it would not be able to find a library inCONFIG
mode in the case of aplatform_requires
, as no config file is generated for the library. The standard find module of CMake (if one exists) could possibly find the library in the sysroot inMODULE
mode, but this is not a universal solution, because there could also be other requirements in the graph that depend on this library. These could not retrieve any meta information about the library at Conan level, as this is not generated anywhere. Also the default find module name in CMake is not guaranteed to be the same as the one used by the corresponding Conan recipes. Even if the consumer does not dofind_package
in CMakeLists, but links directly to the lib file,platform_requires
is not useful in my opinion, because the CMakeLists would then no longer be Conan-agnostic because you would need two different paths for builds with or without Conan (or maybe with or withoutplatform_requires
).Have you read the CONTRIBUTING guide?
The text was updated successfully, but these errors were encountered: