diff --git a/.github/workflows/install-ccache.ps1 b/.github/workflows/install-ccache.ps1 index f56a9533..c9d15035 100644 --- a/.github/workflows/install-ccache.ps1 +++ b/.github/workflows/install-ccache.ps1 @@ -4,10 +4,10 @@ param ( [string] $Destination ) -$version = "4.8" -$folder = "ccache-$version-windows-x86_64" +$version = "4.10.2" +$folder="ccache-$version-windows-x86_64" $url = "https://github.com/ccache/ccache/releases/download/v$version/$folder.zip" -$expectedSha256 = "A2B3BAB4BB8318FFC5B3E4074DC25636258BC7E4B51261F7D9BEF8127FDA8309" +$expectedSha256 = "6252F081876A9A9F700FAE13A5AEC5D0D486B28261D7F1F72AC11C7AD9DF4DA9" $ErrorActionPreference = "Stop" diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index ebd56549..f3c2afcc 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -16,7 +16,13 @@ jobs: strategy: matrix: config: [ - + { + os: ubuntu-24.04, + cmakeBuildType: RelWithDebInfo, + asanEnabled: false, + cudaEnabled: false, + checkCodeFormat: true, + }, { os: ubuntu-22.04, cmakeBuildType: Release, @@ -35,7 +41,7 @@ jobs: os: ubuntu-22.04, cmakeBuildType: Release, asanEnabled: true, - cudaEnabled: true, + cudaEnabled: false, checkCodeFormat: false, }, { @@ -62,14 +68,15 @@ jobs: 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 compiler cache run: | mkdir -p "$CCACHE_DIR" "$CTCACHE_DIR" echo "$COMPILER_CACHE_DIR/bin" >> $GITHUB_PATH + if [ -f "$COMPILER_CACHE_DIR/bin/ccache" ]; then exit 0 fi + set -x wget https://github.com/ccache/ccache/releases/download/v4.8.2/ccache-4.8.2-linux-x86_64.tar.xz echo "0b33f39766fe9db67f40418aed6a5b3d7b2f4f7fab025a8213264b77a2d0e1b1 ccache-4.8.2-linux-x86_64.tar.xz" | sha256sum --check @@ -81,14 +88,16 @@ jobs: echo "108b087f156a9fe7da0c796de1ef73f5855d2a33a27983769ea39061359a40fc ${ctcache_commit_id}.zip" | sha256sum --check unzip "${ctcache_commit_id}.zip" mv ctcache-${ctcache_commit_id}/clang-tidy* "$COMPILER_CACHE_DIR/bin" + - name: Check code format if: matrix.config.checkCodeFormat run: | set +x -euo pipefail - sudo apt-get update && sudo apt-get install -y clang-format-14 black - ./scripts/format/clang_format.sh + python -m pip install clang-format==19.1.0 + ./scripts/format/c++.sh git diff --name-only git diff --exit-code || (echo "Code formatting failed" && exit 1) + - name: Setup Ubuntu run: | sudo apt-get update && sudo apt-get install -y \ @@ -96,11 +105,9 @@ jobs: cmake \ ninja-build \ libboost-program-options-dev \ - libboost-filesystem-dev \ libboost-graph-dev \ libboost-system-dev \ libeigen3-dev \ - libsuitesparse-dev \ libceres-dev \ libflann-dev \ libfreeimage-dev \ @@ -116,7 +123,9 @@ jobs: libcgal-qt5-dev \ libgl1-mesa-dri \ libunwind-dev \ + libcurl4-openssl-dev \ xvfb + if [ "${{ matrix.config.cudaEnabled }}" == "true" ]; then if [ "${{ matrix.config.os }}" == "ubuntu-20.04" ]; then sudo apt-get install -y \ @@ -134,16 +143,19 @@ jobs: echo "CUDAHOSTCXX=/usr/bin/g++-10" >> $GITHUB_ENV fi fi + if [ "${{ matrix.config.asanEnabled }}" == "true" ]; then sudo apt-get install -y clang-15 libomp-15-dev echo "CC=/usr/bin/clang-15" >> $GITHUB_ENV echo "CXX=/usr/bin/clang++-15" >> $GITHUB_ENV fi + if [ "${{ matrix.config.cmakeBuildType }}" == "ClangTidy" ]; then sudo apt-get install -y clang-15 clang-tidy-15 libomp-15-dev echo "CC=/usr/bin/clang-15" >> $GITHUB_ENV echo "CXX=/usr/bin/clang++-15" >> $GITHUB_ENV fi + - name: Upgrade CMake run: | CMAKE_VERSION=3.28.6 @@ -152,6 +164,7 @@ jobs: tar -xzf ${CMAKE_DIR}.tar.gz sudo cp -r ${CMAKE_DIR}/* /usr/local/ rm -rf ${CMAKE_DIR}* + - name: Configure and build run: | set -x @@ -167,6 +180,7 @@ jobs: -DTESTS_ENABLED=ON \ -DASAN_ENABLED=${{ matrix.config.asanEnabled }} ninja -k 10000 + - name: Run tests if: ${{ matrix.config.cmakeBuildType != 'ClangTidy' }} run: | @@ -176,15 +190,17 @@ jobs: sleep 3 cd build ctest --output-on-failure -E .+colmap_.* + - name: Cleanup compiler cache run: | set -x ccache --show-stats --verbose ccache --evict-older-than 1d ccache --show-stats --verbose + echo "Size of ctcache before: $(du -sh $CTCACHE_DIR)" echo "Number of ctcache files before: $(find $CTCACHE_DIR | wc -l)" # Delete cache older than 10 days. find "$CTCACHE_DIR"/*/ -mtime +10 -print0 | xargs -0 rm -rf echo "Size of ctcache after: $(du -sh $CTCACHE_DIR)" - echo "Number of ctcache files after: $(find $CTCACHE_DIR | wc -l)"'' + echo "Number of ctcache files after: $(find $CTCACHE_DIR | wc -l)" diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 1adc3635..2cfde898 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -16,13 +16,6 @@ jobs: strategy: matrix: config: [ - { - os: windows-2019, - cmakeBuildType: Release, - cudaEnabled: false, - testsEnabled: true, - exportPackage: false, - }, { os: windows-2022, cmakeBuildType: Release, @@ -44,18 +37,35 @@ jobs: COMPILER_CACHE_DIR: ${{ github.workspace }}/compiler-cache CCACHE_DIR: ${{ github.workspace }}/compiler-cache/ccache CCACHE_BASEDIR: ${{ github.workspace }} - VCPKG_COMMIT_ID: e01906b2ba7e645a76ee021a19de616edc98d29f - VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" + VCPKG_COMMIT_ID: bc3512a509f9d29b37346a7e7e929f9a26e66c7e + GLOG_v: 1 + GLOG_logtostderr: 1 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 || ''); + + # We define the vcpkg binary sources using separate variables for read and + # write operations: + # * Read sources are defined as inline. These can be read by anyone and, + # in particular, pull requests from forks. Unfortunately, we cannot + # define these as action environment variables. See: + # https://github.com/orgs/community/discussions/44322 + # * Write sources are defined as action secret variables. These cannot be + # read by pull requests from forks but only from pull requests from + # within the target repository (i.e., created by a repository owner). + # This protects us from malicious actors accessing our secrets and + # gaining write access to our binary cache. For more information, see: + # https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/ + - name: Setup vcpkg binary cache + shell: pwsh + run: | + # !!!PLEASE!!! be nice and don't use this cache for your own purposes. This is only meant for CI purposes in this repository. + $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" + if ("${{ secrets.VCPKG_BINARY_CACHE_AZBLOB_URL }}") { + # The secrets are only accessible in runs triggered from within the target repository and not forks. + $VCPKG_BINARY_SOURCES += ";x-azblob,${{ secrets.VCPKG_BINARY_CACHE_AZBLOB_URL }},${{ secrets.VCPKG_BINARY_CACHE_AZBLOB_SAS }},write" + } + echo "VCPKG_BINARY_SOURCES=${VCPKG_BINARY_SOURCES}" >> "${env:GITHUB_ENV}" - name: Compiler cache uses: actions/cache@v4 @@ -70,11 +80,9 @@ jobs: 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 @@ -86,9 +94,6 @@ jobs: 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: | @@ -99,6 +104,12 @@ jobs: git reset --hard ${{ env.VCPKG_COMMIT_ID }} ./bootstrap-vcpkg.bat + - name: Install CMake and Ninja + uses: lukka/get-cmake@latest + with: + cmakeVersion: "3.31.0" + ninjaVersion: "1.12.1" + - name: Configure and build shell: pwsh run: | diff --git a/cmake/FindDependencies.cmake b/cmake/FindDependencies.cmake index a59323a1..caa2275c 100644 --- a/cmake/FindDependencies.cmake +++ b/cmake/FindDependencies.cmake @@ -1,7 +1,10 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") find_package(Eigen3 3.4 REQUIRED) -find_package(SuiteSparse COMPONENTS CHOLMOD REQUIRED) +find_package(CHOLMOD QUIET) +if(NOT TARGET SuiteSparse::CHOLMOD) + find_package(SuiteSparse COMPONENTS CHOLMOD REQUIRED) +endif() find_package(Ceres REQUIRED COMPONENTS SuiteSparse) find_package(Boost REQUIRED) diff --git a/scripts/format/clang_format.sh b/scripts/format/c++.sh similarity index 58% rename from scripts/format/clang_format.sh rename to scripts/format/c++.sh index 29710188..07f09f36 100755 --- a/scripts/format/clang_format.sh +++ b/scripts/format/c++.sh @@ -2,28 +2,9 @@ # This script applies clang-format to the whole repository. -# Find clang-format -tools=' - clang-format -' - -clang_format='' -for tool in ${tools}; do - if type -p "${tool}" > /dev/null; then - clang_format=$tool - break - fi -done - -if [ -z "$clang_format" ]; then - echo "Could not locate clang-format" - exit 1 -fi -echo "Found clang-format: $(which ${clang_format})" - # Check version -version_string=$($clang_format --version | sed -E 's/^.*(\d+\.\d+\.\d+-.*).*$/\1/') -expected_version_string='14.0.0' +version_string=$(clang-format --version | sed -E 's/^.*(\d+\.\d+\.\d+-.*).*$/\1/') +expected_version_string='19.1.0' if [[ "$version_string" =~ "$expected_version_string" ]]; then echo "clang-format version '$version_string' matches '$expected_version_string'" else @@ -40,5 +21,4 @@ all_files=$( \ num_files=$(echo $all_files | wc -w) echo "Formatting ${num_files} files" -# Run clang-format -${clang_format} -i $all_files +clang-format -i $all_files