-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
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.
- Toolchains are not really suitable for this use case. We want to use the same model that was used in the original workspaces model of using
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. - The variables are set to the cache and not force overwritten. In our case this means that you can't use the same variable in two different projects, which means that they can't be cached. Other use cases need the cache see, [bug] CMakeToolchain now requires double configure to set cache variables #7832, but even in those cases I believe that the variables should be force set, otherwise you have to delete the cache in order to be able to change the variable from the recipe. So you should probably provide an interface for setting different variable types.
- You can't provide a template file to the generator, only a static toolchain file. If a template file was allowed, then we would at least have a quite elegant workaround for the issue, by making a custom template that just sets normal variables instead of cache ones. Custom blocks could also be an alternative, but sadly an interface for setting that does not seem to be available either. So I think my current workaround would be to just make a custom class that overrides the internal
_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.
- I've read the CONTRIBUTING guide.