docs
docs copied to clipboard
[question] Profiles: apply package selector for [conf] section / Recipe: custom build folder layout per package
What is your question?
Hello, I'm developing a library package and would like to work with a custom build folder layout. Goal is the simultaneous development of multiple architectures within a single IDE instance. For now, I want this custom build folder layout only to be applied within my project without worrying about breaking other peoples stuff.
First I tried with cmake_layouts build_folder argument inside my recipe.
This had the drawback that for two architectures, the generated cmake user presets ended up with the same name.
Finally, I figured out that tools.cmake.cmake_layout:build_folder_vars does what I want.
I end up with a build folder like: build/<settings.arch> and a configure preset named <settings.arch>.
Unfortunately I found no way to specify this setting inside my recipe only.
So I had to put it into my profiles.
cross
[settings]
arch=armv8
# ...
[conf]
mypackage:tools.cmake.cmake_layout:build_folder_vars=["settings.arch"]
mypackage:tools.cmake.cmaketoolchain:generator="Ninja Multi-Config"
native
[settings]
arch=x86_64
# ...
[conf]
mypackage:tools.cmake.cmake_layout:build_folder_vars=["settings.arch"]
mypackage:tools.cmake.cmaketoolchain:generator="Ninja Multi-Config"
Here I encountered two problems:
- Limiting the elements of the
[conf]section to my package does not seem to be recognized (Possibly due to two colons). Not limiting it to my package affects the build folder layout of others. - Everytime I build my package, I need to ensure that the users profile has this settings set.
Is there a way to specify tools.cmake.cmake_layout:build_folder_vars only for my recipe without the manipulation of profiles?
Have you read the CONTRIBUTING guide?
- [X] I've read the CONTRIBUTING guide
this solution ended up working just fine.
conanfile.py
def layout(self):
# experimental:
# rename build folder and generated cmake user presets only for this package
# does nothing if already specified via profile
conf_key = 'tools.cmake.cmake_layout:build_folder_vars'
conf_value = ['settings.os.distro']
self.conf[conf_key] = self.conf.get(conf_key, conf_value)
cmake_layout(self, "Ninja Multi-Config")
I would still like to have some feedback from the maintainers whether or not this should be intentional.
Hi @dornbirndevelops
Thanks for your question.
Please have a look to https://docs.conan.io/2/knowledge/guidelines.html. There it explicitly says that defining conf and settings values in recipes is not possible.
If you want to define it in recipe, you can define self.folders.build_folder_vars inside the layout() method.
It is probably that this is not documented yet, please try it, and if it works, we can move this ticket to the docs repo.