cmake-conan icon indicating copy to clipboard operation
cmake-conan copied to clipboard

[question] Using layout and -of together Conan 2

Open forry opened this issue 8 months ago • 4 comments

Hi, while using conan 2.4.1 on Windows 10 I want to make a conan 2 recipe for an application using cmake. I want to use the conan-cmake deps provider (supplied as a top-level include via our cmake preset through the GUI) and make it possible to drive the build process either from cmake or conan. The problem I'm encountering is when the layout is defined in some way but the conan dependency provider (or user) runs conan install with the -of argument.

I like to use out-of-source builds so I define my layout like this:

    def layout(self):
        cmake_layout(self, build_folder='../build')
        print(f"generator folder {self.folders.generators}")

But the user building it will start the cmake-gui with the binary dir of his choosing. When called the conan install . it creates a folder build with subfolder generators with the files, which is great. When called conan install . -of ../build the result is the same - build/generators. But when called like conan install . -of ../build/conan which is what deps provider does when doing cmake configure the result is build\build\generators - one subfolder more than I would like to and no conan subfolder why? When I comment out the layout(self) method and call conan install . -of ../build/conan the result is just build/conan.

If I would like to consistently generate the generator files by conan, let's say in a <build folder>\conan, where the <build folder> is either selected by the user through CMAKE_BINARY_DIR var or by typing conan install. in a source folder, what should I do?

Have you read the CONTRIBUTING guide?

  • [ ] I've read the CONTRIBUTING guide

forry avatar Jun 21 '24 11:06 forry