2

I am using VS2022 with vcpkg integration in manifest mode for a CMake project. I already have defined a version in the CMakeLists.txt that gets configured into a header and resource file:

cmake_minimum_required(VERSION 3.23)
project(clcto-lib VERSION 1.2.0.0)
# ...

To use vcpkg in manifest mode, I also include a vcpkg.json:

{
  "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json",
  "name": "clcto-lib",
  "version": "1.2.0.0",
  "dependencies": [
    "log4cxx"
  ]
}

Now, I have to specify the version in 2 places that should be kept in sync. I would like to avoid this so that the version is only specified once.

When in manifest mode, why do I have to specify the version? How is it used? How would I consume this in the CMakeLists.txt file or when configuring? Since the vcpkg manifest is a good start for the port manifest, I would like to have this be the single-source of truth for the version if possible.

Upon further investigation it looks like the manifest file works with just "dependencies" (and no "name" and "version" attributes). Is there a reason to include them in the project manifest as opposed to just the port?

clcto
  • 9,530
  • 20
  • 42

1 Answers1

1

Is there a reason to include them in the project manifest as opposed to just the port?

To keep the manifest in the port in sync with the projects manifest. Theoretically the idea is that you can simply drop the manifest from your project into a port, write a little portfile and be done with it. Without the version field you need to add it.

If you commit of having a vcpkg manifest you could use string(JSON) and read the version from the manifest and feed it to the project command

Alexander Neumann
  • 1,479
  • 8
  • 17