As you might know, using 3rd party software in CMake code is done via packages, by using the find_package command.
find_package does what the name says: it finds a package. If the package doesn’t exist, it will set the <PackageName>_FOUND variable to FALSE, and if the package was REQUIRED the the CMake configuration will error out.
This is where a package manager comes into play. The setup of the package manager could be done in CMake code, by hard coding specific code, or by documenting how the environment needs to be setup before configuring the CMake project.
Package manager auto-setup
CMake, starting with version 3.15, allows injecting custom code without modifying the project CMake source code via CMAKE_PROJECT_INCLUDE_BEFORE.
Qt Creator 4.15 will insert in the initial cmake parameters the line:
The cmake_find_package conan generator is needed for the fmt::fmt CMake target.
Getting conan on your system is as easy as running:
pip3 install conan
This assumes that you have python3 installed on your system.
Qt Creator’s auto-setup.cmake takes care of running conan install for the project and for making the experience as painless as possible. This has been made possible by the usage of the conan-cmake, which is also shipped with Qt Creator.
If you don’t want the conan auto-setup, you can set the CMake variable QT_CREATOR_SKIP_CONAN_SETUP to TRUE.
Using vcpkg for getting the fmt library into the project is as easy as creating this vcpkg.json file: