conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
7.96k stars 952 forks source link

[question] Define custom layouts #16467

Closed BjarneLorenzen closed 3 weeks ago

BjarneLorenzen commented 3 weeks ago

What is your question?

Is there a way to define custom layout functions that can be used as the predefined ones like cmake_layout(self)?

Have you read the CONTRIBUTING guide?

memsharded commented 3 weeks ago

Hi @BjarneLorenzen

Thanks for your question.

Not sure what do you mean exactly. But if you want to create your own layouts and reuse them, it is possible:

You can check https://docs.conan.io/2/reference/extensions/python_requires.html#reference-extensions-python-requires for more information.

Please let me know if this is what you want.

Otherwise, cmake_layout has some customizations via conf:

$ conan config list 

tools.cmake.cmake_layout:build_folder: (Experimental) Allow configuring the base folder of the build for local builds
tools.cmake.cmake_layout:build_folder_vars: Settings and Options that will produce a different build folder and different CMake presets names
tools.cmake.cmake_layout:test_folder: (Experimental) Allow configuring the base folder of the build for test_package
BjarneLorenzen commented 3 weeks ago

Thanks for the quick response, that approach would work for me. I just want to avoid having the lengthy layout code inside every recipe.

memsharded commented 3 weeks ago

Thanks for the quick response, that approach would work for me. I just want to avoid having the lengthy layout code inside every recipe.

Sure, to reuse code among different recipes, the python_requires is the way to go. The feature allows not only to reuse, but also to control the re-build of packages when you want, based on the version changes of the python_requires.

Thanks to you for the feedback!