Skip to content

Commit 53f4f9a

Browse files
committed
Carry the vcpkg root under a name vcvars does not own
The six Windows jobs installed Boost into one vcpkg and then pointed CMake at another. vcvars sets VCPKG_ROOT to the copy Visual Studio bundles, and the msvc-dev-cmd step sits between the install and the configure, so the variable the install step wrote was gone by the time the toolchain file and the prefix path were built from it. The step logs show it outright: VCPKG_ROOT is C:/vcpkg while boost-test is installing, and the VC\vcpkg under Visual Studio 18 by the time cmake runs. Visual Studio 2022 does not do this, which is why it never showed anywhere but on the runner. The root now travels as STDC_VCPKG_ROOT, which nothing else writes. This is also the correction to the previous commit. Caching the install state rather than the built binaries is a real hazard and the change stands, but it was not what made find_package come up empty: the diagnostic it added shows BoostConfig.cmake present in C:/vcpkg the whole time.
1 parent 523bc16 commit 53f4f9a

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

.github/workflows/ci.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,13 @@ jobs:
7171
if: runner.os == 'macOS'
7272
run: brew install ninja boost
7373

74-
# Ninja is not on the Windows image, and there are two vcpkgs: the one Visual Studio bundles,
75-
# which is what VCPKG_INSTALLATION_ROOT points at, and the one on PATH. Deriving the root
76-
# from the executable that will actually run the install is what keeps those from being
77-
# different directories.
74+
# Ninja is not on the Windows image, and there are two vcpkgs: the one Visual Studio bundles
75+
# and the one on PATH. Deriving the root from the executable that will actually run the
76+
# install is what keeps those from being different directories.
77+
#
78+
# It is carried under our own name, not VCPKG_ROOT. vcvars sets VCPKG_ROOT to the copy
79+
# Visual Studio bundles, so the msvc-dev-cmd step below silently repoints it between the
80+
# install and the configure: Boost lands in one vcpkg and CMake is aimed at the other.
7881
- name: Install Ninja and locate vcpkg (Windows)
7982
id: vcpkg
8083
if: runner.os == 'Windows'
@@ -83,7 +86,7 @@ jobs:
8386
choco install ninja -y --no-progress
8487
root=$(cygpath -m "$(dirname "$(command -v vcpkg)")")
8588
echo "vcpkg root: $root"
86-
echo "VCPKG_ROOT=$root" >> "$GITHUB_ENV"
89+
echo "STDC_VCPKG_ROOT=$root" >> "$GITHUB_ENV"
8790
echo "VCPKG_DEFAULT_BINARY_CACHE=$RUNNER_TEMP\\vcpkg-archives" >> "$GITHUB_ENV"
8891
mkdir -p "$RUNNER_TEMP/vcpkg-archives"
8992
# The port versions come from whichever vcpkg the image shipped, so its commit is what
@@ -112,8 +115,8 @@ jobs:
112115
# find_package(Boost CONFIG) turns on exactly one file, which the boost-cmake port
113116
# brings in as a dependency of boost-test. Saying whether it arrived makes a failure
114117
# downstream one question rather than two.
115-
config="$VCPKG_ROOT/installed/x64-windows/share/boost/BoostConfig.cmake"
116-
ls -l "$config" || { echo "missing: $config"; ls "$VCPKG_ROOT/installed" || true; }
118+
config="$STDC_VCPKG_ROOT/installed/x64-windows/share/boost/BoostConfig.cmake"
119+
ls -l "$config" || { echo "missing: $config"; ls "$STDC_VCPKG_ROOT/installed" || true; }
117120
118121
# Ninja everywhere, which needs the MSVC environment on Windows since there is no generator
119122
# to set it up.
@@ -134,9 +137,9 @@ jobs:
134137
if [ "${{ runner.os }}" = "Windows" ]; then
135138
# The prefix path as well as the toolchain file. The toolchain works out the triplet
136139
# for itself, and naming the directory outright is one fewer thing to be wrong.
137-
extra=(-DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake"
140+
extra=(-DCMAKE_TOOLCHAIN_FILE="$STDC_VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake"
138141
-DVCPKG_TARGET_TRIPLET=x64-windows
139-
-DCMAKE_PREFIX_PATH="$VCPKG_ROOT/installed/x64-windows")
142+
-DCMAKE_PREFIX_PATH="$STDC_VCPKG_ROOT/installed/x64-windows")
140143
fi
141144
cmake -G Ninja -S . -B build \
142145
-DCMAKE_BUILD_TYPE=${{ steps.cfg.outputs.type }} \

0 commit comments

Comments
 (0)