| 1 |
name: COLMAP (Windows) |
| 2 |
|
| 3 |
concurrency: |
| 4 |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 5 |
cancel-in-progress: ${{ github.event_name == 'pull_request' }} |
| 6 |
|
| 7 |
on: |
| 8 |
push: |
| 9 |
branches: |
| 10 |
- main |
| 11 |
- release/* |
| 12 |
pull_request: |
| 13 |
types: [ assigned, opened, synchronize, reopened ] |
| 14 |
release: |
| 15 |
types: [ published, edited ] |
| 16 |
|
| 17 |
jobs: |
| 18 |
build: |
| 19 |
name: ${{ matrix.config.os }} ${{ matrix.config.cmakeBuildType }} ${{ matrix.config.cudaEnabled && 'CUDA' || '' }} |
| 20 |
runs-on: ${{ matrix.config.os }} |
| 21 |
strategy: |
| 22 |
matrix: |
| 23 |
config: [ |
| 24 |
{ |
| 25 |
os: windows-2025-vs2026, |
| 26 |
cmakeBuildType: Release, |
| 27 |
cudaEnabled: true, |
| 28 |
testsEnabled: true, |
| 29 |
exportPackage: true, |
| 30 |
ccacheMaxSize: 200M, |
| 31 |
}, |
| 32 |
{ |
| 33 |
os: windows-2025-vs2026, |
| 34 |
cmakeBuildType: Release, |
| 35 |
cudaEnabled: false, |
| 36 |
testsEnabled: true, |
| 37 |
exportPackage: true, |
| 38 |
ccacheMaxSize: 300M, |
| 39 |
}, |
| 40 |
] |
| 41 |
|
| 42 |
env: |
| 43 |
COMPILER_CACHE_DIR: ${{ github.workspace }}/compiler-cache |
| 44 |
CCACHE_DIR: ${{ github.workspace }}/compiler-cache/ccache |
| 45 |
CCACHE_BASEDIR: ${{ github.workspace }} |
| 46 |
CCACHE_NOHASHDIR: "true" |
| 47 |
CCACHE_COMPILERCHECK: content |
| 48 |
CCACHE_MAXSIZE: ${{ matrix.config.ccacheMaxSize }} |
| 49 |
GLOG_v: 2 |
| 50 |
GLOG_logtostderr: 1 |
| 51 |
CUDA_MAJOR_VERSION: 13 |
| 52 |
CUDA_MINOR_VERSION: 2 |
| 53 |
CUDA_PATCH_VERSION: 0 |
| 54 |
|
| 55 |
steps: |
| 56 |
- uses: actions/checkout@v7 |
| 57 |
|
| 58 |
# We define the vcpkg binary sources using separate variables for read and |
| 59 |
# write operations: |
| 60 |
# * Read sources are defined as inline. These can be read by anyone and, |
| 61 |
# in particular, pull requests from forks. Unfortunately, we cannot |
| 62 |
# define these as action environment variables. See: |
| 63 |
# https://github.com/orgs/community/discussions/44322 |
| 64 |
# * Write sources are defined as action secret variables. These cannot be |
| 65 |
# read by pull requests from forks but only from pull requests from |
| 66 |
# within the target repository (i.e., created by a repository owner). |
| 67 |
# This protects us from malicious actors accessing our secrets and |
| 68 |
# gaining write access to our binary cache. For more information, see: |
| 69 |
# https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/ |
| 70 |
- name: Setup vcpkg binary cache |
| 71 |
shell: pwsh |
| 72 |
run: | |
| 73 |
# !!!PLEASE!!! be nice and don't use this cache for your own purposes. This is only meant for CI purposes in this repository. |
| 74 |
$VCPKG_BINARY_SOURCES = "clear;x-azblob,https://colmap.blob.core.windows.net/github-actions-cache,sp=r&st=2024-12-10T17:29:32Z&se=2030-12-31T01:29:32Z&spr=https&sv=2022-11-02&sr=c&sig=bWydkilTMjRn3LHKTxLgdWrFpV4h%2Finzoe9QCOcPpYQ%3D,read" |
| 75 |
if ("${{ secrets.VCPKG_BINARY_CACHE_AZBLOB_URL }}") { |
| 76 |
# The secrets are only accessible in runs triggered from within the target repository and not forks. |
| 77 |
$VCPKG_BINARY_SOURCES += ";x-azblob,${{ secrets.VCPKG_BINARY_CACHE_AZBLOB_URL }},${{ secrets.VCPKG_BINARY_CACHE_AZBLOB_SAS }},write" |
| 78 |
} |
| 79 |
echo "VCPKG_BINARY_SOURCES=${VCPKG_BINARY_SOURCES}" >> "${env:GITHUB_ENV}" |
| 80 |
|
| 81 |
- name: Restore compiler cache |
| 82 |
uses: ./.github/actions/compiler-cache |
| 83 |
id: cache-compiler |
| 84 |
with: |
| 85 |
mode: restore |
| 86 |
path: ${{ env.COMPILER_CACHE_DIR }} |
| 87 |
key-suffix: ${{ matrix.config.os }}-${{ matrix.config.cmakeBuildType }}-cuda_${{ matrix.config.cudaEnabled }} |
| 88 |
|
| 89 |
- name: Install compile cache |
| 90 |
shell: pwsh |
| 91 |
run: | |
| 92 |
New-Item -ItemType Directory -Force -Path "${{ env.CCACHE_DIR }}" |
| 93 |
echo "${{ env.COMPILER_CACHE_DIR }}/bin" | Out-File -Encoding utf8 -Append -FilePath $env:GITHUB_PATH |
| 94 |
if (!(Test-Path -PathType Leaf "${{ env.COMPILER_CACHE_DIR }}/bin/ccache.exe")) { |
| 95 |
.github/workflows/install-ccache.ps1 -Destination "${{ env.COMPILER_CACHE_DIR }}/bin" |
| 96 |
} |
| 97 |
& "${{ env.COMPILER_CACHE_DIR }}/bin/ccache.exe" --zero-stats |
| 98 |
|
| 99 |
- name: Install CUDA |
| 100 |
uses: Jimver/[email protected] |
| 101 |
if: matrix.config.cudaEnabled |
| 102 |
id: cuda-toolkit |
| 103 |
with: |
| 104 |
cuda: '${{ env.CUDA_MAJOR_VERSION }}.${{ env.CUDA_MINOR_VERSION }}.${{ env.CUDA_PATCH_VERSION }}' |
| 105 |
# CUDA 13 reorganized the toolkit, so the compiler now needs four |
| 106 |
# extra components beyond the old list: crt (crt/host_config.h, |
| 107 |
# included by cuda_runtime.h), nvvm (the cicc device compiler + |
| 108 |
# libdevice; no longer bundled in the nvcc subpackage), |
| 109 |
# nvptxcompiler, and thrust (Thrust/CUB headers, on Windows the |
| 110 |
# subpackage is "thrust", not "cccl"). We avoid a full install to |
| 111 |
# skip the large math/Nsight subpackages COLMAP does not use. |
| 112 |
sub-packages: '["nvcc", "crt", "nvvm", "nvptxcompiler", "thrust", "nvtx", "cudart", "curand", "curand_dev", "nvrtc_dev"]' |
| 113 |
method: 'network' |
| 114 |
|
| 115 |
- name: Setup vcpkg |
| 116 |
shell: pwsh |
| 117 |
run: | |
| 118 |
./scripts/shell/enter_vs_dev_shell.ps1 |
| 119 |
cd ${{ github.workspace }} |
| 120 |
git clone https://github.com/microsoft/vcpkg |
| 121 |
cd vcpkg |
| 122 |
./bootstrap-vcpkg.bat |
| 123 |
|
| 124 |
- name: Install CMake and Ninja |
| 125 |
uses: lukka/get-cmake@latest |
| 126 |
with: |
| 127 |
# CMake >= 4.1 knows the CUDA 13 architecture set, so "all-major" |
| 128 |
# expands to Turing..Blackwell (75..120). Older CMake predates CUDA 13 |
| 129 |
# and would expand it to a stale set including Maxwell/Pascal/Volta |
| 130 |
# (compute_50/60/70), which CUDA 13 no longer supports. |
| 131 |
cmakeVersion: "4.3.2" |
| 132 |
ninjaVersion: "1.12.1" |
| 133 |
|
| 134 |
- name: Configure and build |
| 135 |
shell: pwsh |
| 136 |
run: | |
| 137 |
./scripts/shell/enter_vs_dev_shell.ps1 |
| 138 |
cd ${{ github.workspace }} |
| 139 |
./vcpkg/vcpkg.exe integrate install |
| 140 |
mkdir -Force build |
| 141 |
cd build |
| 142 |
if ($${{ matrix.config.cudaEnabled }}) { |
| 143 |
# The windows-2025 runner ships a newer MSVC toolset (VS 18, |
| 144 |
# _MSC_VER 19.5x) than older CUDA host_config.h versions whitelist, |
| 145 |
# which otherwise aborts CUDA compiler detection with "unsupported |
| 146 |
# Microsoft Visual Studio version". Kept as a safety net in case the |
| 147 |
# pinned CUDA toolkit still lags the runner's MSVC; it is a no-op |
| 148 |
# when the host compiler is already supported. CMake reads CUDAFLAGS |
| 149 |
# during CUDA compiler detection. |
| 150 |
$env:CUDAFLAGS = "-allow-unsupported-compiler" |
| 151 |
} |
| 152 |
cmake .. ` |
| 153 |
-GNinja ` |
| 154 |
-DCMAKE_MAKE_PROGRAM=ninja ` |
| 155 |
-DCMAKE_BUILD_TYPE=Release ` |
| 156 |
-DTESTS_ENABLED=${{ matrix.config.testsEnabled }} ` |
| 157 |
-DGUI_ENABLED=ON ` |
| 158 |
-DCUDA_ENABLED=${{ matrix.config.cudaEnabled }} ` |
| 159 |
-DCMAKE_CUDA_ARCHITECTURES=all-major ` |
| 160 |
-DCUDAToolkit_ROOT="${{ steps.cuda-toolkit.outputs.CUDA_PATH }}" ` |
| 161 |
-DCMAKE_TOOLCHAIN_FILE="${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake" ` |
| 162 |
-DVCPKG_TARGET_TRIPLET=x64-windows-release ` |
| 163 |
-DVCPKG_USE_LEGACY_APPLOCAL=ON ` |
| 164 |
-DCMAKE_INSTALL_PREFIX=install |
| 165 |
ninja |
| 166 |
|
| 167 |
- name: Run tests |
| 168 |
shell: pwsh |
| 169 |
run: | |
| 170 |
./vcpkg/vcpkg.exe integrate install |
| 171 |
cd build |
| 172 |
$EXCLUDED_TESTS = "(feature/sift_test)|(util/opengl_utils_test)|(mvs/gpu_mat_test)" |
| 173 |
ctest -E ${EXCLUDED_TESTS} --output-on-failure |
| 174 |
|
| 175 |
- name: Export package |
| 176 |
if: matrix.config.exportPackage |
| 177 |
shell: pwsh |
| 178 |
run: | |
| 179 |
./vcpkg/vcpkg.exe integrate install |
| 180 |
|
| 181 |
cd build |
| 182 |
ninja install |
| 183 |
|
| 184 |
../vcpkg/vcpkg.exe install ` |
| 185 |
--triplet=x64-windows-release ` |
| 186 |
--x-feature=gui ` |
| 187 |
--x-feature=cgal ` |
| 188 |
$(if ($${{ matrix.config.testsEnabled }}) { echo "--x-feature=tests" }) ` |
| 189 |
$(if ($${{ matrix.config.cudaEnabled }}) { echo "--x-feature=cuda" }) |
| 190 |
../vcpkg/vcpkg.exe export --raw --output-dir vcpkg_export --output colmap |
| 191 |
cp vcpkg_export/colmap/installed/x64-windows/bin/*.dll install/bin |
| 192 |
cp vcpkg_export/colmap/installed/x64-windows-release/bin/*.dll install/bin |
| 193 |
# Deploy the Qt plugins from the x64-windows-release triplet, which is |
| 194 |
# the triplet COLMAP is actually built against. qtsvg is only installed |
| 195 |
# for that triplet, so copying from x64-windows would miss the SVG |
| 196 |
# plugins (imageformats/qsvg.dll and iconengines/qsvgicon.dll) that Qt |
| 197 |
# needs to render the SVG toolbar/menu icons, leaving them blank. |
| 198 |
cp -r vcpkg_export/colmap/installed/x64-windows-release/Qt6/plugins install |
| 199 |
|
| 200 |
# Fail loudly if the SVG plugins are missing: without them Qt cannot |
| 201 |
# render the SVG icons and the toolbar/menu icons show up blank, but |
| 202 |
# the build itself succeeds, so the regression is otherwise silent. |
| 203 |
if (-not (Test-Path install/plugins/iconengines/qsvgicon.dll)) { |
| 204 |
throw "Missing Qt SVG icon engine plugin (iconengines/qsvgicon.dll); SVG icons would not render." |
| 205 |
} |
| 206 |
if (-not (Test-Path install/plugins/imageformats/qsvg.dll)) { |
| 207 |
throw "Missing Qt SVG image format plugin (imageformats/qsvg.dll); SVG icons would not render." |
| 208 |
} |
| 209 |
if ($${{ matrix.config.cudaEnabled }}) { |
| 210 |
cp "${{ steps.cuda-toolkit.outputs.CUDA_PATH }}/bin/cudart64_*.dll" install/bin |
| 211 |
cp "${{ steps.cuda-toolkit.outputs.CUDA_PATH }}/bin/curand64_*.dll" install/bin |
| 212 |
} |
| 213 |
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue install/include,install/lib,install/share |
| 214 |
|
| 215 |
- name: Upload package |
| 216 |
uses: actions/upload-artifact@v7 |
| 217 |
if: ${{ matrix.config.exportPackage && matrix.config.cudaEnabled }} |
| 218 |
with: |
| 219 |
name: colmap-x64-windows-cuda |
| 220 |
path: build/install |
| 221 |
|
| 222 |
- name: Upload package |
| 223 |
uses: actions/upload-artifact@v7 |
| 224 |
if: ${{ matrix.config.exportPackage && !matrix.config.cudaEnabled }} |
| 225 |
with: |
| 226 |
name: colmap-x64-windows-nocuda |
| 227 |
path: build/install |
| 228 |
|
| 229 |
- name: Cleanup compiler cache |
| 230 |
shell: pwsh |
| 231 |
run: | |
| 232 |
ccache --cleanup |
| 233 |
ccache --show-stats --verbose |
| 234 |
|
| 235 |
- name: Save compiler cache |
| 236 |
uses: ./.github/actions/compiler-cache |
| 237 |
with: |
| 238 |
mode: save |
| 239 |
key: ${{ steps.cache-compiler.outputs.key }} |
| 240 |
path: ${{ env.COMPILER_CACHE_DIR }} |
| 241 |
cache-hit: ${{ steps.cache-compiler.outputs.cache-hit }} |