Classic mode

vcpkg classic mode is less recommended than vcpkg manifest mode but remains a solid approach to compile Rat C++ libraries with vcpkg.

It allows to install packages globally using the local vcpkg repository which has been bootsrapped during the previous Setup section. All binaries then reside in this directory and all projects can share this same installation.

vcpkg classic mode however does not allow precise versioning of the packages to compile and install, unlike vcpkg manifest mode.

Consume packages

Using vcpkg classic mode the idea is to exposes rat-vcpkg/ports as overlays by passing the --overlay-ports=ports flag to the install command to make vcpkg aware of these port definitions.

vcpkg solves dependencies quite neatly so one can try to install rat-models using the desired vcpkg triplet to get the whole dependency chain started.

Warning

VTK ports recently changed to introduce a vtk-compile-tools port which is host specific and might break CMake configuration.

To fix this, ensure the vtk-compile-tools package is installed in global vcpkg using classic mode by running the following command from outside the current manifest project:

vcpkg install vtk-compile-tools

git clone https://gitlab.com/project-rat-extras/rat-vcpkg.git
  • Run the following command from within the cloned Rat-vcpkg repository:

# Need to point to local Rat-vcpkg ports directory
vcpkg install rat-models:x64-windows-release --overlay-ports=ports --clean-after-build

# or if one needs to keep the buildtrees for debugging purposes
vcpkg install rat-models:x64-windows-release --overlay-ports=ports

Note

Depencies might take some time to build depending on the hardware.

The heaviest one for Rat seems to be VTK, which is even longer to build in Debug.

This will install packages in the local vcpkg repository.

  • Ensure the VCPKG_ROOT environment variable is defined and points to the local vcpkg repository installation.

  • Configure a CMake project using the vcpkg toolchain file:

cd myproject
cmake -B build -S . -G "Ninja" `
    -DCMAKE_BUILD_TYPE="Release" `
    -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT\scripts\buildsystems\vcpkg.cmake" `
    -DVCPKG_TARGET_TRIPLET="x64-windows-release" `
    -DVCPKG_HOST_TRIPLET="x64-windows-release"
  • Build the project:

cmake --build build