conan icon indicating copy to clipboard operation
conan copied to clipboard

[feature] provide a more advanced autotools_layout() to the level of cmake for autotools package supporting out-of-tree build

Open hpe-ykoehler opened this issue 1 year ago • 5 comments

What is your suggestion?

autotools package support building outside of the source tree folder using the approach

cd $build ../configure && make && ...

for those autotools package supporting this mode a autotools_layout() function should exists with the same function as cmake_layout as to set the build_folder directly in the recipe of via a settings set in the conan profile.

Have you read the CONTRIBUTING guide?

  • [ ] I've read the CONTRIBUTING guide

hpe-ykoehler avatar Nov 13 '24 13:11 hpe-ykoehler

Thanks for the suggestion @hpe-ykoehler

In order to consider this feature, it would be necessary to have some evidence of autotools projects supporting this flow. Up to my knowledge the vast majority of projects will work building only in-source. Then, the best way to proceed is to define a very simple example, like using conan new autotools_lib, and first write manually a layout() method that implements the necessary layout, and then it can be taken from there and abstract that layout() method into its own helper if necessary.

Could you please provide:

  • Some references of existing autotools projects that allow building outside of the source
  • A very basic, the most simple autotools based project (ideally starting from conan new autotools_lib with a manually written layout() method that would implement the out-of-source build?

Thanks for your feedback.

memsharded avatar Nov 13 '24 19:11 memsharded

The out-of-source build feature (also referred to as parallel build trees) of autotools/automake is not new.

You can find many articles about it on Google. And you can pull recent autotools based package to try it in a shell directly.

As with anything, some package may not use this function and may write build system file that make it incompatible, similar things can also be done in CMake (but it is a little harder to achieve thanks to the higher level language used).

hpe-ykoehler avatar Nov 14 '24 13:11 hpe-ykoehler

I have been checking this. Autotools helpers already have the basic_layout() that locates the "build" folder outside of the source folder. This layout will create a build-release or build-debug folders for the build by default, and can also be instructed to create a different one with --output-folder=myfolder. You can cd to that folder and issue the commands for the build.

The cmake_layout() has a build_folder argument because its logic is way more complex than the one for basic_layout(). For an autotools project, users can directly do:

def layout(self):
     self.folders.build = "myfolder"

memsharded avatar Nov 19 '24 19:11 memsharded

Interesting, is there a way to harmonize those two layout so that we can set the build folder to be similar independently of cmake/autotool usage, which is really what I wish here.

I think that the way it should work is that we should set our "desire" build folder value/format, then if the tool can use an out-of-source folder to build, it default to that.

Instead of having one way to set it for cmake, and a different way to set it for autotools...

hpe-ykoehler avatar Nov 27 '24 16:11 hpe-ykoehler

Hello @hpe-ykoehler, I have been testing, and it seems that it should work.

In https://github.com/conan-io/conan/pull/18442, a new parameter is added to the basic_layout to define the build folder. The basic_layout should be sufficient to handle autotools in this way.

ErniGH avatar Jun 10 '25 13:06 ErniGH

Hi!

PR https://github.com/conan-io/conan/pull/18442 was adding a new parameter that would allow out-of-source build for some Autotools projects with a basic_layout(..., build_folder=xxx) new argument, that would at least enable that flow if defined in recipes.

Still the fully configurable from conf not there, it would require to deprecate all the current cmake.xxxx specific confs, to replace them with other more generic confs, and that would be massive given that CMake is the most popular by far, so unfortunately there is not enough evidence of demand for the autotools ecosystem to do this move, it would be problematic for all CMake users.

memsharded avatar Jun 23 '25 12:06 memsharded

Closed by https://github.com/conan-io/conan/pull/18442 for next Conan 2.18 release. Autotools based recipes can define multi-config layouts (not Conan-conf driven, but at least possible in the recipes), with:

basic_layout(..., build_folder=f"{self.settings.compiler}-{self.settings.arch}-{self.settings.build_type}")

memsharded avatar Jun 24 '25 12:06 memsharded