Fix find_package logic for poselib in support of homebrew/vcpkg (#2971) #10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: COLMAP (Windows) | |
on: | |
push: | |
branches: | |
- main | |
- release/* | |
pull_request: | |
types: [ assigned, opened, synchronize, reopened ] | |
release: | |
types: [ published, edited ] | |
jobs: | |
build: | |
name: ${{ matrix.config.os }} ${{ matrix.config.cmakeBuildType }} ${{ matrix.config.cudaEnabled && 'CUDA' || '' }} | |
runs-on: ${{ matrix.config.os }} | |
strategy: | |
matrix: | |
config: [ | |
{ | |
os: windows-2022, | |
cmakeBuildType: Release, | |
cudaEnabled: true, | |
testsEnabled: true, | |
exportPackage: true, | |
}, | |
{ | |
os: windows-2022, | |
cmakeBuildType: Release, | |
cudaEnabled: false, | |
testsEnabled: true, | |
exportPackage: true, | |
}, | |
] | |
env: | |
COMPILER_CACHE_VERSION: 1 | |
COMPILER_CACHE_DIR: ${{ github.workspace }}/compiler-cache | |
CCACHE_DIR: ${{ github.workspace }}/compiler-cache/ccache | |
CCACHE_BASEDIR: ${{ github.workspace }} | |
VCPKG_COMMIT_ID: 10b7a178346f3f0abef60cecd5130e295afd8da4 | |
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Export GitHub Actions cache env | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); | |
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); | |
- name: Compiler cache | |
uses: actions/cache@v4 | |
id: cache-builds | |
with: | |
key: v${{ env.COMPILER_CACHE_VERSION }}-${{ matrix.config.os }}-${{ matrix.config.cmakeBuildType }}-${{ matrix.config.asanEnabled }}--${{ matrix.config.cudaEnabled }}-${{ github.run_id }}-${{ github.run_number }} | |
restore-keys: v${{ env.COMPILER_CACHE_VERSION }}-${{ matrix.config.os }}-${{ matrix.config.cmakeBuildType }}-${{ matrix.config.asanEnabled }}--${{ matrix.config.cudaEnabled }} | |
path: ${{ env.COMPILER_CACHE_DIR }} | |
- name: Install ccache | |
shell: pwsh | |
run: | | |
New-Item -ItemType Directory -Force -Path "${{ env.CCACHE_DIR }}" | |
echo "${{ env.COMPILER_CACHE_DIR }}/bin" | Out-File -Encoding utf8 -Append -FilePath $env:GITHUB_PATH | |
if (Test-Path -PathType Leaf "${{ env.COMPILER_CACHE_DIR }}/bin/ccache.exe") { | |
exit | |
} | |
.github/workflows/install-ccache.ps1 -Destination "${{ env.COMPILER_CACHE_DIR }}/bin" | |
- name: Install CUDA | |
uses: Jimver/[email protected] | |
if: matrix.config.cudaEnabled | |
id: cuda-toolkit | |
with: | |
cuda: '12.6.2' | |
sub-packages: '["nvcc", "nvtx", "cudart", "curand", "curand_dev", "nvrtc_dev"]' | |
method: 'network' | |
- name: Install CMake and Ninja | |
uses: lukka/get-cmake@latest | |
- name: Setup vcpkg | |
shell: pwsh | |
run: | | |
./scripts/shell/enter_vs_dev_shell.ps1 | |
cd ${{ github.workspace }} | |
git clone https://github.com/microsoft/vcpkg | |
cd vcpkg | |
git reset --hard ${{ env.VCPKG_COMMIT_ID }} | |
./bootstrap-vcpkg.bat | |
- name: Configure and build | |
shell: pwsh | |
run: | | |
./scripts/shell/enter_vs_dev_shell.ps1 | |
cd ${{ github.workspace }} | |
./vcpkg/vcpkg.exe integrate install | |
mkdir build | |
cd build | |
cmake .. ` | |
-GNinja ` | |
-DCMAKE_MAKE_PROGRAM=ninja ` | |
-DCMAKE_BUILD_TYPE=Release ` | |
-DTESTS_ENABLED=${{ matrix.config.testsEnabled }} ` | |
-DGUI_ENABLED=ON ` | |
-DCUDA_ENABLED=${{ matrix.config.cudaEnabled }} ` | |
-DCMAKE_CUDA_ARCHITECTURES=all-major ` | |
-DCUDAToolkit_ROOT="${{ steps.cuda-toolkit.outputs.CUDA_PATH }}" ` | |
-DCMAKE_TOOLCHAIN_FILE="${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake" ` | |
-DVCPKG_TARGET_TRIPLET=x64-windows-release ` | |
-DCMAKE_INSTALL_PREFIX=install | |
ninja | |
- name: Run tests | |
shell: pwsh | |
run: | | |
./vcpkg/vcpkg.exe integrate install | |
cd build | |
$EXCLUDED_TESTS = "(feature/colmap_feature_sift_test)|(util/colmap_util_opengl_utils_test)|(mvs/colmap_mvs_gpu_mat_test)" | |
ctest -E ${EXCLUDED_TESTS} --output-on-failure | |
- name: Export package | |
if: matrix.config.exportPackage | |
shell: pwsh | |
run: | | |
./vcpkg/vcpkg.exe integrate install | |
cd build | |
ninja install | |
../vcpkg/vcpkg.exe install ` | |
--triplet=x64-windows-release ` | |
--x-feature=gui ` | |
--x-feature=cgal ` | |
$(if ($${{ matrix.config.testsEnabled }}) { echo "--x-feature=tests" }) ` | |
$(if ($${{ matrix.config.cudaEnabled }}) { echo "--x-feature=cuda" }) | |
../vcpkg/vcpkg.exe export --raw --output-dir vcpkg_export --output colmap | |
cp vcpkg_export/colmap/installed/x64-windows/bin/*.dll install/bin | |
cp vcpkg_export/colmap/installed/x64-windows-release/bin/*.dll install/bin | |
cp -r vcpkg_export/colmap/installed/x64-windows/plugins install | |
if ($${{ matrix.config.cudaEnabled }}) { | |
cp "${{ steps.cuda-toolkit.outputs.CUDA_PATH }}/bin/cudart64_*.dll" install/bin | |
cp "${{ steps.cuda-toolkit.outputs.CUDA_PATH }}/bin/curand64_*.dll" install/bin | |
} | |
Remove-Item -Recurse -Force install/include,install/lib,install/share | |
- name: Upload package | |
uses: actions/upload-artifact@v4 | |
if: ${{ matrix.config.exportPackage && matrix.config.cudaEnabled }} | |
with: | |
name: colmap-x64-windows-cuda | |
path: build/install | |
- name: Upload package | |
uses: actions/upload-artifact@v4 | |
if: ${{ matrix.config.exportPackage && !matrix.config.cudaEnabled }} | |
with: | |
name: colmap-x64-windows-nocuda | |
path: build/install | |
- name: Cleanup compiler cache | |
shell: pwsh | |
run: | | |
ccache --show-stats --verbose | |
ccache --evict-older-than 1d | |
ccache --show-stats --verbose |