c++cmakepackage-managersvcpkg

How to stop vcpkg manifest mode from updating dependencies?


Building is very slow on my system. However about every few days to a week, VCPKG decides, somehow, on it's own volition, to start updating packages, cascading in a full rebuild of all dependencies. Some of these dependencies can take over a day to rebuild. It should be fairly simple just lock VCPKG to stop updating, but no matter what I do (setting 'builtin-baseline' for example) there appears to be something causing VCPKG to automatically update things.

Here is my vcpkg.json.

{
  "name": "myproject"
  "version-string": "1.0.0",
  "dependencies": [
    "zeromq",
    "cppzmq"
  ],
  "builtin-baseline": "871e20cf67ebaa80c048b868be53c8e7375c79f3"
}

When I look at the cmake output, it makes me think that vcpkg install is the culprit. I guess in manifest mode this is called every time I refresh the cmake package. But I don't want this to happen.

Here's my CMakePresets.json

{
  "version": 3,
  "cmakeMinimumRequired": {
    "major": 3,
    "minor": 17,
    "patch": 0
  },
  "configurePresets": [
    {
      "name": "Default",
      "displayName": "Default Config",
      "description": "",
      "generator": "Ninja",
      "hidden": true
    },
    {
      "name": "DebugTemplate",
      "displayName": "Debug Template",
      "description": "",
      "generator": "Ninja",
      "binaryDir": "${sourceDir}/cmake-build-debug",
      "cacheVariables": {
        "CMAKE_BUILD_TYPE": "Debug"
      },
      "hidden": true
    },
    {
      "name": "WindowsVcpkgTemplate",
      "displayName": "Default Linux Config with hardware",
      "description": "",
      "inherits": "Default",
      "cacheVariables": {
        "CMAKE_TOOLCHAIN_FILE": "${sourceDir}/vcpkg/scripts/buildsystems/vcpkg.cmake",
        "VCPKG_TARGET_TRIPLET": "x64-windows-static"
      },
      "environment": {
        "TEMP": "${sourceDir}/Temp",
        "TMP": "${sourceDir}/Temp",
        "VCPKG_BINARY_SOURCES" :"clear;files,${sourceDir}/vcpkg/archives,readwrite"
      },
      "condition": {
        "type": "equals",
        "lhs": "${hostSystemName}",
        "rhs": "Windows"
      },
      "hidden": true
    },
    {
      "name": "WindowsDebug",
      "displayName": "Windows Debug Config",
      "description": "",
      "inherits": [
        "WindowsVcpkgTemplate",
        "DebugTemplate"
      ]
    },
  ]
}

and my Cmake file:

cmake_minimum_required(VERSION 3.17)
project(MyProject)
set(CMAKE_CXX_STANDARD 20)

if(WIN32)
    set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()

find_package(Threads REQUIRED)
find_package(cppzmq REQUIRED)

add_executable(my_project)
target_sources(my_project PRIVATE main.cpp)
target_include_directories(my_project PRIVATE ./)
target_link_libraries(my_project PRIVATE
        Threads::Threads
        cppzmq
)

And my main file (though tbh, neither my CMake nor main are at all necessary here).

int main(){
    return 0; 
}

And here's the first part of the output in cmake, when VCPKG runs before it actually installs things:

C:\SomeDirectory\bin\cmake\win\x64\bin\cmake.exe" -DCMAKE_BUILD_TYPE=RelWithDebInfo --preset WindowsDebug -S C:\DEC\projects\adif-test-harness -B C:\ProjectDirectory\cmake-build-debug
Preset CMake variables:

  CMAKE_TOOLCHAIN_FILE="C:/ProjectDirectory/vcpkg/scripts/buildsystems/vcpkg.cmake"
  VCPKG_TARGET_TRIPLET="x64-windows-static"

Preset environment variables:

  TEMP="C:/DEC/projects/adif-test-harness/Temp"
  TMP="C:/DEC/projects/adif-test-harness/Temp"
  VCPKG_BINARY_SOURCES="clear;files,C:/ProjectDirectory/vcpkg/archives,readwrite"

-- Running vcpkg install
Detecting compiler hash for triplet x64-windows...
Detecting compiler hash for triplet x64-windows-static...
The following packages will be rebuilt:
    cppzmq:x64-windows-static -> 4.9.0 -- C:\ProjectDirectory\vcpkg\buildtrees\versioning_\versions\cppzmq\7f4360cc5fa484c4ecd286ef6c545bde4b01bc39
  * vcpkg-cmake:x64-windows -> 2022-12-22 -- C:\ProjectDirectory\vcpkg\buildtrees\versioning_\versions\vcpkg-cmake\1913f86defd2140d0a6751be2d51952e4090efa4
  * vcpkg-cmake-config:x64-windows -> 2022-02-06#1 -- C:\ProjectDirectory\vcpkg\buildtrees\versioning_\versions\vcpkg-cmake-config\8d54cc4f487d51b655abec5f9c9c3f86ca83311f
    zeromq:x64-windows-static -> 4.3.4#6 -- C:\ProjectDirectory\vcpkg\buildtrees\versioning_\versions\zeromq\7bdd3a27ea013a2d3b70032245631f114198cce9
Additional packages (*) will be modified to complete this operation.
Restored 0 package(s) from C:/ProjectDirectory/vcpkg/archives in 1.04 ms. Use --debug to see more details.

Is there a way to stop the automatic VCPKG install call or stop the updates with out my explicit permission? Even a way to feed into vcpkg manifest mode "no install" would be good enough for me.


Solution

  • Set VCPKG_MANIFEST_INSTALL to OFF when you call cmake.

    See vcpkg in CMake projects