Open drmacdon opened 4 months ago
Hi @drmacdon
Thanks for your feedback
The CMake conan_provider.cmake approach as pointed out in https://github.com/conan-io/cmake-conan/issues/635 does not invoke conan until the first find_package(), but CMake processes it just after the project() line. I was not clear on why conan was deferred until the first find_package()?
This is how the CMake dependency providers work: https://cmake.org/cmake/help/latest/guide/using-dependencies/index.html#dependency-providers, CMake designed them as interceptors of find_package()
calls. Conan just followed their design.
But if conan was resolvable at the point that conan_provider.cmake was evaluated it could do something similar with far less dependencies and be more seamless enabling the CMake to remain entirely agnostic of conan.
I partially understand the desire to be able to keep 1 single command like cmake ...
and have everything integrated from there. But at some point, if the added complexity to do this is very high, it is simply not worth it. Other programming languages have had flows such as npm install
to install dependencies, then gulp build
to do the actual build with a different tools for long time.
Hiding the package and dependency resolution is not always a good thing, from our experience. It often just "delays" the issues, overloading the "build" engineers everytime something doesn't work because the "build is broken" without understanding if it is a dependency new version, if it is a compiler error somewhere, or what.
The aim of "remain agnostic of conan" recalls me from devs using some abstractions over git when migrating from subversion (to not have to learn the complexity of git). Our experience is that we have seen in general better results in organizations that accept Conan as another new tool in the developers flow and "toolbelt" (because it really is a new tool in the flow) than organizations trying to completely hide it as a build internal implementation detail.
I understand that this is not always possible, and this is why we provide this cmake-conan
integration, with a special focus on being able to provide a transparent integration without modifying the CMakeLists.txt
, and following the recommended practices of the CMake dependency providers. But this doesn't allow to provide a multi-stage bidirectional flow of information between Conan and CMake, so cases like what you are trying to implement will be quite challenging.
The CMake
conan_provider.cmake
approach as pointed out in #635 does not invokeconan
until the firstfind_package()
, but CMake processes it just after theproject()
line. I was not clear on whyconan
was deferred until the firstfind_package()?
Today, when
conan
is invoked it includes the option setting in theconan_toolchain.cmake
but those option settings are unavailable to theconan_provider.cmake
path and the point at whichfind_package()
is actually invoked typically means CMake options have already been initialized.To avoid replicating
conan
options when usingconan_provider.cmake
, I ended up doing something like the below which shells out toconan graph info
to get the current values set prior the regular CMake option setting.But if
conan
was resolvable at the point thatconan_provider.cmake
was evaluated it could do something similar with far less dependencies and be more seamless enabling the CMake to remain entirely agnostic of conan.Where the
just cmake-options
writes out the options via graph,