-
Notifications
You must be signed in to change notification settings - Fork 260
conan_provider.cmake and conan options? #659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @drmacdon Thanks for your feedback
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
I partially understand the desire to be able to keep 1 single command like 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 |
And these dependency providers cannot take any more information from within main In 1.x, I just:
...and that's it. If I switch from Release to Debug in QtCreator, all runs again, automatically, and it works beautifully (had to do some hacks when cross-compiling, or building mobile Qt application, but it's doable). Now with 2.0, by reading various issues here, it seems this usability I had with 1.x will go down the drain..? It seems I will have to pass -DCONAN_FOO... every time I open new (without existing CMakeLists.txt.user) Qt project, change/generate (where/when?) profile with package options, and make sure I sync options with Or am I missing something, @memsharded ? Thanks. |
Thanks @Talkless
Do you mean, editing
The variables listed in the docs for
can technically be defined in The same experience as before can be achieved, the recommended way in CMake is to use CMakePresets, which are also supported by Qt creator: CMake presets can live alongside CMakeLists.txt. I strongly suggest opening a new issue so that we can document this better if necessary, as this issue seems unrelated (it expects variables defined by the |
@Talkless it looks like you have a very similar problem to the one I had when trying to migrate to conan 2.0 - and that's the reason why I'm replying today as I subscribed to this issue at the time! - which is the impossibility to pass options defined in cmake to conan 2 with the approach used by cmake-conan v2. To circumvent that limitation I ended up creating cmake-conanfile which can inject cmake variables in |
@jcar87 I have bunch of "options()'s" in CMakeLists.txt: And then I can conveniently change them in QtCreator "Build settings" GUI:
With Conan 1.x, I have just:
With 2.0 I will have to list them in "Additiona CMake options" like this, manually, every time project is newly launched (without QtCreator's
Yeah maybe presets could help somehow, I'll have to research them.
I agree, new issue would be best, with some minimal example project. I'll see if I can find time for that. Thanks. |
Thanks for noting. It is complete alternative to |
Conan 2's |
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,The text was updated successfully, but these errors were encountered: