I want to use conan in an existing CMake project. I have the conanfile.txt in the root directory and run conan install . --build=missing --output-folder=build/conan, but I don't know how to get CMake to find the dependencies it has built/downloaded.
I am using the VSCode CMake extension and it runs this command to generate:
/usr/bin/cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/g++ -S/home/me/myproject -B/home/me/myproject/build/Debug -G Ninja
conanfile.txt
[requires]
boost/1.85.0
fmt/10.2.1
openssl/3.0.9
cryptopp/8.9.0
[generators]
CMakeDeps
Also, I am using find_package in CMake to find them.
CMakeToolchaingenerator and then use-DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmakeor better thecmake --preset conan-default/conan-release. Also better to use the[layout]withcmake_layoutand forget about the--output-folderargumentconan install ... -s build_type=Debug. Likewise, if those compilers are not the default ones in the system (in that case you wouldn't need to define them in command line), better define them in a profile file too, in the[buildenv]section asCC/CXXenv-vars, or with[conf]liketools.build:compiler_executables. Check the getting started tutorial: docs.conan.io/2/tutorial/consuming_packages/…