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] `conanbuildinfo.cmake` replacement in Conan 2? #16457

Closed PauloCarvalhoRJ closed 3 weeks ago

PauloCarvalhoRJ commented 3 weeks ago

conanbuildinfo.cmake replacement in Conan 2?

Hello,

I am migrating from Conan 1 to Conan 2 and I have some CMakeLists.txts in my packages with code like this:

message(STATUS "Conan CMake Wrapper")
include(conanbuildinfo.cmake)
conan_basic_setup()

I understand that this is Conan 1 boilerplate. However, Conan 2 is not generating conanbuildinfo.cmake before calling CMake when I do a conan create, so CMake aborts with an include could not find requested file error. What is the current protocol using CMake with Conan 2? I mean what changes should I do to these CMakeLists.txts so they are compliant with Conan 2? The migration guide (https://docs.conan.io/1/migrating_to_2.0/recipes.html) does not present anything related to changes necessary to CMake config scripts.

Thank you in advance,

Paulo

Have you read the CONTRIBUTING guide?

memsharded commented 3 weeks ago

Hi @PauloCarvalhoRJ

The replacement is a transparent integration: CMakeDeps and CMakeToolchain can work without having to have anything Conan related in the CMakeLists.txt.

You might learn about this integration nicely in https://docs.conan.io/2/tutorial/consuming_packages/build_simple_cmake_project.html, it is the Conan 2 docs, but the CMakeDeps/CMakeToolchain works the same in Conan 1.X

PauloCarvalhoRJ commented 3 weeks ago

Thank you, @memsharded . So, that was a great improvement in Conan 2, since we no longer need Canan code in CMake scripts as the build can be done without Conan too.

Thanks again for your time.

memsharded commented 3 weeks ago

Thanks to you for the feedback!