This generator is especially useful if you are using
CMake based only on the
feature to locate the dependencies.
cmake_paths generator creates a file named
CMAKE_MODULE_PATHwith the folders of the required packages, to allow CMake to locate the included cmake scripts and
FindXXX.cmakefiles. The folder containing the conan_paths.cmake (self.install_folder when used in a recipe) is also included, so any custom file will be located too. Check :ref:`cmake_find_package_generator` generator.
find_library()to locate library files (.a, .lib, .so, .dll) in your packages and
find_dependency()to locate the transitive dependencies.
In the example above, the
zlib/1.2.11@conan/stable package is not packaging a custom
FindZLIB.cmake file, but the
included in the CMake installation directory (/Modules) will locate the zlib library from the Conan package because of the
CMAKE_PREFIX_PATH used by the
zlib/1.2.11@conan/stable would have included a custom
FindZLIB.cmake in the package root folder or any declared
:ref:`self.cpp_info.builddirs <cpp_info_attributes_reference>`, it would have been located because of the
Included as a toolchain
You can use the conan_paths.cmake as a toolchain without modifying your CMakeLists.txt file:
Included using the
CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE you can specify a file to be included by the
If you already have a toolchain file you can use this variable to include the
conan_paths.cmake and insert your toolchain with the
$ mkdir build && cd build $ conan install .. $ cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_PROJECT_helloworld_INCLUDE=build/conan_paths.cmake $ cmake --build .
Included in your CMakeLists.txt
$ mkdir build && cd build $ conan install .. $ cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release $ cmake --build .
.. seealso:: Check the section :ref:`cmake_paths_generator_reference` to read more about this generator.
CMAKE_PREFIX_PATH contain the paths to the
builddirs of every required package. By default the
root package folder is the only declared
builddirs directory. Check :ref:`cpp_info_attributes_reference`.