I've a CMake project that uses vcpkg.json
for using vcpkg, and CMakePresets.json
for setting the CMake options.
This is the vcpkg.json
:
{
"name": "myproj",
"version": "1.0.0",
"dependencies": [
"boost",
"qt"
]
}
This is the CMakePresets.json
:
{
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 22,
"patch": 1
},
"configurePresets": [
{
"name": "default",
"displayName": "Default Config",
"description": "Default config generator with ninja",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}",
"hidden": true,
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "e:/lib/vcpkg/scripts/buildsystems/vcpkg.cmake",
"VCPKG_DEFAULT_TRIPLET": "x64-windows",
"CMAKE_EXPORT_COMPILE_COMMANDS": "TRUE"
},
"environment": {
}
},
{
"inherits": "default",
"name": "debug",
"displayName": "Debug",
"description": "Debug build.",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"inherits": "default",
"name": "release",
"displayName": "Release",
"description": "Release build.",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
}
],
"buildPresets": [
{
"name": "Debug",
"configurePreset": "debug"
},
{
"name": "Release",
"configurePreset": "release"
}
],
"testPresets": [
{
"name": "debugtest",
"configurePreset": "debug",
"output": {"outputOnFailure": true},
"execution": {"noTestsAction": "error", "stopOnFailure": true}
}
]
}
When I open the project folder with Visual Studio 2022, it start to build the vcpkg
libraries, and everything goes well, until it builds qtwebengine
, that returns me an error:
1> [CMake] Installing 376/432 qtwebengine:x64-windows...
1> [CMake] Building qtwebengine[core,default-features,geolocation,spellchecker,webchannel]:x64-windows...
1> [CMake] -- Using cached pypa-get-pip-38e54e5de07c66e875c11a1ebbdb938854625dd8.tar.gz.
1> [CMake] -- Cleaning sources at E:/lib/vcpkg/buildtrees/qtwebengine/src/8854625dd8-861bd167bd.clean. Use --editable to skip cleaning for the packages you specify.
1> [CMake] -- Extracting source E:/lib/vcpkg/downloads/pypa-get-pip-38e54e5de07c66e875c11a1ebbdb938854625dd8.tar.gz
1> [CMake] -- Using source at E:/lib/vcpkg/buildtrees/qtwebengine/src/8854625dd8-861bd167bd.clean
1> [CMake] -- Setting up python virtual environmnent...
1> [CMake] -- Installing python packages: html5lib
1> [CMake] -- Setting up python virtual environmnent...finished.
1> [CMake] CMake Warning at ports/qtwebengine/portfile.cmake:85 (message):
1> [CMake] Buildtree path 'E:/lib/vcpkg/buildtrees/qtwebengine' is too long.
1> [CMake]
1> [CMake] Consider passing --x-buildtrees-root=<shortpath> to vcpkg!
1> [CMake]
1> [CMake] Trying to use 'E:/lib/vcpkg/buildtrees/qtwebengine/../tmp'
1> [CMake] Call Stack (most recent call first):
1> [CMake] scripts/ports.cmake:147 (include)
1> [CMake]
1> [CMake]
1> [CMake] CMake Error at ports/qtwebengine/portfile.cmake:90 (message):
1> [CMake] Buildtree path is too long. Build will fail! Pass
1> [CMake] --x-buildtrees-root=<shortpath> to vcpkg!
1> [CMake] Call Stack (most recent call first):
1> [CMake] scripts/ports.cmake:147 (include)
1> [CMake] error: building qtwebengine:x64-windows failed with: BUILD_FAILED
1> [CMake] error: Please ensure you're using the latest port files with `git pull` and `vcpkg update`.
Basically I need to set the --x-buildtrees-root=<shortpath>
option when building the library with vcpkg
. I can do it manually, but how can I set this option in order to be called automatically when I build the dependencies with Visual Studio? How can I update my configuration files?
The variable VCPKG_INSTALL_OPTIONS
is meant for passing further options to vcpkg install
. So just set it in your preset.