vcpkg is a free C/C++ package manager for acquiring and managing libraries. Choose from over 1500 open source libraries to download and build in a single step or add your own private libraries to simplify your build process. Maintained by the Microsoft C++ team and open source contributors.
For simplicity and easier typing, we install vcpkg in C:\vcpkg
.
-
Clone the vcpkg repo
cd C:\ git clone https://github.com/Microsoft/vcpkg.git
-
Run the bootstrap script to build vcpkg.
.\vcpkg\bootstrap-vcpkg.bat
-
Using vcpkg with MSBuild / Visual Studio (may require elevation)
.\vcpkg.exe integrate install
-
Set enviornment variable
VCPKG_ROOT
to beC:\vcpkg
.
(This may take some time)
.\vcpkg.exe install tesseract --triplet x64-windows
cmake -B build/ -S . -DCMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts\buildsystems\vcpkg.cmake
cmake --build build
Add cmakeToolchain
setting to cmake preset json file.
"cmakeToolchain": "C:\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake"
An example CMakeSettings.json
:
{
"configurations": [
{
"name": "x64-Release",
"generator": "Ninja",
"configurationType": "RelWithDebInfo",
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeToolchain": "C:\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake",
"ctestCommandArgs": "",
"inheritEnvironments": [
"msvc_x64_x64"
]
}
]
}