Installing Dependencies using VCPKG

Article Info
Last Updated
(c522687)

Installing packages

Once vcpkg is extracted and configured as mentioned above, you can now use it on the command line. Check this works by opening cmd from the start menu.

vcpkg --version

You should see the version listed. If you do not, ensure you have set the path environment variable correctly.

vcpkg version

Installing packages

Next we will try to install one of the libraries we will be using for testing, benchmark.

You can install this using the following command:

vcpkg install benchmark:x64-windows

This should finish by telling you that it’s now installed. Once this has been done, you should be able to open the cmake project from the labs and have the depencendies automatically processed correctly.

Tip
if you don’t spesificy the operating system, it will default to 32bit and cmake won’t find it. This is what the :x64-windows part of the command does.

Once installed, the packages will be available to any cmake project you load, assuming it’s been setup to load vcpkg first. To do this, make sure the following code snippet is in the root CMakeLists.txt.

##
# Windows
# When on windows, integrate vcpkg
##
if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
  set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
      CACHE STRING "")
endif()
Graduation Cap Book Open book GitHub Info chevron-right Sticky Note chevron-left Puzzle Piece Lightbulb Video Exclamation Triangle Globe