-
Notifications
You must be signed in to change notification settings - Fork 992
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
[question] Possible Workflow with CMake (and CLion) #11627
Comments
I guess that you are talking about the https://github.com/conan-io/cmake-conan integration, but you are concerned about its limitations. That project was born by the desire of some users to run just cmake, and let it call conan automatically. Even if I didn't love this integration, it worked relatively well with the previous CMake integrations ( Relatively well, means that it has its issues, for example, need to deal with multi-configuration projects, installing Debug/Release configurations in one pass, further polluting every But on the other hand, we got a huge pressure to implement a "transparent" integration, that is, one that didn't need to modify anything in your But this introduced a chicken-and-egg problem. You can't have both, it is impossible to have a transparent integration, and also have CMake call automatically Conan, because that highly pollutes the CMakeLists.txt files. But more importantly because the integration relies on generating CMake So the only possibilities that we see moving forward are:
|
Hi James, thanks again for taking the time to look into my concerns!
No, not necessary. While evaluating our options to integrate Conan, I've also stumbled over the project above. I would love to keep the dependencies purely in our conan.py file. The problem is, that one not just have to invoke Conan, when one do a fresh In our current workflow (still work in progress) to do a build (using GCC for debug build), we issue the following commands:
The last step, would be omitted, when used in an IDE. There is a lot of redundancy between the call to conan and cmake and getting something wrong here can easily lead to an hour debug "ghost problems". If we could move the But in general, I think our project does not have any special requirements. Vanilla CMake, Vanilla GCC and clang, Vanilla CLion, so I though I might have problems to understand the concepts of Conan somehow. I really like the approach to generate CMake files, that can be used by In the end, Thanks a lot! best regards, |
Hi Torsten,
in order to reconfigure when a change in conanfile.py has happend, you need to unset some package-cache variables...
best regards, |
Hi @memsharded, I stumbled into this issue because I have a very similar experience as @TorstenRobitzki. We are using Conan 1.x for a while now, in combination with Now, while trying to migrate to the newer Conan 2.x technology I have similar concerns. For example, we are bound to old CMake version (original from Ubuntu 20.04 distribution) by our customer. AFAIK this version has no preset support. I'm not sure how this will be handled by the new
I cannot agree to this statement. Well yes, for example with Python virtual environments, we prepare the venv before using it. But in case of Conan, there are files installed into the build folder of the projects, not only general files. And running only CMake inside CLion is a requirement. And finally, I'm currently really confused about the "need" to use generated toolchain files and/or preset files. We have our own toolchain files, and when producing a package including these files into the generated toolchain file at the top of the file doesn't work well. Currently I'm collecting information about the new features, and it seems the documentation is not complete yet. But overall, Conan is a great tool, I don't want to miss it! BR Andi |
Hi @andioz, Now that we have launched 2.0, we have resumed our efforts in cmake-conan, we are experimenting with the new dependency providers, please track the efforts in conan-io/cmake-conan#473
CMakeDeps and CMakeToolchain can both work with CMake >=3.15 (per conan-io/tribe#4), it is not mandatory to use CMakePresets, it can be convenient, but not mandatory. For the
There is also no "need" to use it. It can be super convenient, because it can help a lot to map the Conan settings to the CMake build, but if you can guarantee that your build is consistent with the settings, then it is good to not use it. Conan also provide ways to fully replace the
In especial |
Hi @memsharded Thank you for taking time for an answer.
That's good news! Would really appreciate a clean solution, at best integrated in CMake or Conan itself ;)
Well, Focal version is 3.16, that should be fine. But presets were introduced with 3.19, thats why we're not using it currently. I have not tried how conan would work with this old version, I will try when having some spare time, maybe.
Yes, I found these conf settings. Currently I'm hacking this setting into self.conf inside the generate() method, which is not really the correct way to do it, right? I tried to set it in the profile, but then I had troubles with dependencies I think, and the profile is not the right place, it's a need for one recipe, not the whole system, in my opinion. What I currently want: having a CMake project for a library with (optional) dependencies (gtest, benchmark, ...) via conan. We are building packages with CMake and additionally a conan package with a producer recipe. Consumers will use it mostly using CMake again but we are open for other client toolchains. For me right now, the producer/consumer sides looks a little bit entangled, at least the CMake components. I liked the old cmake generator with a lightweight way to use the packages without need for find_package(). The need to use find_package() add more conditional code to the global CMakeLists.txt (well, I can put it into every subdir, but than I have duplications). And finally, I had trouble to include "build_type=Release" dependencies within a "Debug" project - I use the "&:build_type=Debug" setting with conan install, no idea if this is the best way to map release packages to my current build type? BR Andi |
Yes, not the best, the profile info (settings, options, conf) is read-only in recipes. While python might allow assigning values to some in recipes, that might stop working anytime, raise exceptions or have other undefined behavior. Providing it in the profiles is the very recommended way, because it is the only approach that can provide flexibility enough, hardcoding things in recipes leads to worse maintainability.
That is unexpected, in general it is not possible to use a toolchain in one package that links with packages build with another toolchain without linking (or other worse, more subtle runtime) errors.
yeah, I liked it too! It was the first generator we created and worked quite well. But the push of a large majority of users was towards having a "transparent" cmake integration that was not intrusive in the
Yes, it is possible to use the CMAKE_MAP thing for this too, but it seems that properly telling Conan: "my consumer is Debug, but the dependencies are Release" works fine without needing to add extra things to CMakeLists.txt |
OK, conf is read-only for the whole recipe, good to know. I have to retry with the profile, not sure what's the problem. But I'm still not convinced that the profile would be the best place for such details; information is spreaded over several places then, and usually we use profiles for more general settings. jinja2 templating in profile I tried but I think it didn't work (thought then its only for global.conf). But have to retry too. cmake generator: I see, find_package() is more popular. But I hope later is time for lightweight alternatives. So, regarding Debug/Release, using my approach looks like being the best solution. I really appreciate the discussion culture here in Conan projects (CCI too), no question is too stupid and everybody takes time to write a proper answer. Thanks for that! BR Andi UPDATE: I'm on Conan 1.59 right now but want to prepare for moving to 2.x later on |
Hello,
I'm currently working on a project with a small team working on a relative small code base. Nevertheless, the code base has some dependencies on external libraries and these external libraries have their dependencies on their own. Up to now, we use a shell script to install the dependencies in docker. The exact versions of the installed dependencies where more or less random and depended on the time of execution.
I've convinced my team to use Conan to install the dependencies and thus to codify our dependency and to pin the exact version, we are using with a specific version of our own project.
We use CMake for the build. We have 3 different build configurations (gcc-debug, gcc-release, clang-debug). So far, I was able to configure Conan to install our dependencies (using the 3 configurations above) and to build the software and their tests.
Now I have a pretty large command line for installing every configuration, which I probably could shorten a little bit, by using profiles and a large command line for the CMake configuration, which I can shorten largely by using presets.
Now, I would like to integrate Conan into CMake. I had the dream, that I could simply checkout our sources and use CMake to configure and build the software and that Conan is integrated into the CMake build, so that it gets called to determine the required include and library paths and of cause, to install missing libraries / dependencies. And of cause, if our Conan configuration changes (which simply can happen, by switching the branch), I don't want to explicitly run Conan, but use CMake to detect the required update.
The preferred method to integrate both, seems to be the CMakeToolchain integration. But in this case, the required toolchain file has to exist already before I call CMake (and as there is a chance, that the project has to be cross build in the future, we probably are going to use the tool chain feature of CMake on our own).
Is there a seamless integration of Conan into CMake that doesn't require me to call Conan before I call CMake? Is my expectation, about what Conan should be used for / should be capable of, somehow wrong? Is there an example project accessible, that integrates CMake and Conan).
best regards,
Torsten
The text was updated successfully, but these errors were encountered: