-
Notifications
You must be signed in to change notification settings - Fork 994
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
[feature] Issues with the CMakeToolchain generator #11224
Comments
Hi @fredizzimo Thanks for the feedback. It is true, that the way we are considering now for the workspaces is based on cmake external projects, this is our current thinking:
So maybe this is the first bit that should be investigated. Why this integration via subprojects is not great? Which IDEs? Can we automate something at a different place than CMakeLists (like generation VS .sln on the fly?) |
Thanks, I have perhaps dismissed external projects too early, since I only did an initial research and found problems like these, but never tested it myself All of them seems to be related to the fact that proper targets are not created for the external executables. But perhaps there's a way to generate some dummy targets in the root cmake file, and make it work properly. I will do some experimentation with that and what you showed in the video and come back to you in a couple of days. But, I still think that suggestion 2. especially the ability to force overwrite cache variables, and 3. to a less degree is needed with this. |
That could be relevant, yes. As Conan is generating the targets itself, then maybe there is a chance that this is not problematic.
Yes, this could deserve a separate discussion. There are already some variables that are CACHE forced in the toolchain:
Should all of them be forced by default then? |
It's hard to comment about other projects, and even on our own without trying it out fully. But yes, if we can use external projects, then forcing them all seems to be a working solution. The most flexible would obviously be to expose different types of variables to the interface, but that's also tricky because they are set through a table and not a function. |
Ok, I think we should investigate the potential new workspace approach via external projects or wider IDE or build systems solutions, and from there we will work out the details for specific implementations like the toolchains. This will have to wait a bit, working on workspaces is not planned in the scope of 2.0, we can label it as 2.X. |
I have tested this a bit more now. And I don't think I can make the external projects work with proper IDE support. The way you demonstrated in the video is very specific to Visual Studio, and would not work with Visual Studio code for example, so I did not look into that any further. I have mostly looked at the "open folder" in both Visual Studio and Visual code. I haven't really looked at the cmake Visual Studio generators, since they are Visual Studio specific and as far as I know, they don't support compiling Linux configurations through WSL for example, which is something that we need. Microsoft themselves also only seem to document the "open folder" workflow. Here are some of the major problems that I have found:
So due to these problems I will move back to using It would be nice if a new generator was added, or if the CMakeToolchain generator was flexible enough to support both workflows. But meanwhile, I will try to just make a derived generator myself, which just replaces the template used and generates a file meant to be included. That file is then used when compiling in workspace mode, while the toolchain is used when actually exporting packages. |
We are building custom workspace functionality for Conan 1 based on the existing code, but using CMakeToolchain and the new layout method instead of of the old layout configuration files. It's not that generic at the moment, since it's generating everything dynamically based on our project structure, so it does not need a definition yml file. It's mostly working as it should now, but there are some issues with the toolchain generator.
add_subdirectory
. But that is problematic, since you can only specify the toolchain for the root level cmake file. Our current workaround for this is to just include the toolchain file, which seems to work, except for problem 2. But this is not how cmake toolchains should be used, and it's probably not guaranteed to work in the future, if more stuff is added to the toolchain. Additionally I'm not so sure about the whole idea of using toolchains for setting normal variables and project configuration, IMO toolchains should be reserved for what they actually are meant for, compiler toolchains and stuff. I think that we need a new additional generator that generates just plain cmake files with the project configuration, that can be then included manually. Then we could include a toolchain file at the top level, if needed, and this generated cmake file in each subproject. And when the package is actually exported, it would use both files._template
, that's not elegant, nor future proof, but at least I think it will work.I was also considering using cmake external projects instead of
add_subdirectory
, but sadly, the IDE integration for that is not great, so I'm not sure if that's a path I'm willing to take. I have read most of the issues related to workspaces here, and some people are suggesting that, but if you go that way with the official conan 2 integration, you should definitely make sure that the ide integration works properly.At least for our use cases, the way I'm doing it now seems to be solving all the issues I had with the existing implementation, and why I decided to write my own. The existing workspaces are too decoupled from the actual recipes, but by utilizing the layout and generators, everything can be shared.
The text was updated successfully, but these errors were encountered: