Let's start by introducing the library into our code by using Conan. Put the following in your conanfile.txt:
[requires] benchmark/1.5.2 [generators] CMakeDeps
We're going to use the CMakeDeps generator as it's the recommended CMake generator in Conan 2.0. It relies on CMake's find_package feature to use the packages installed by our barbaric dependency manager. To install the dependencies in their release versions, run the following:
cd <build_directory> conan install <source_directory> --build=missing -s build_type=Release
If you're using a custom Conan profile, remember to add it here as well.
Using it from your CMakeLists.txt file is also pretty straightforward, as shown next:
list(APPEND CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}") find_package(benchmark REQUIRED)
First, we add our build directory to CMAKE_PREFIX_PATH so that CMake can find the config and/or target files produced by Conan. Next, we just use them...