Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 48 additions & 25 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ jobs:

env:
QT_SELECT: qt6
SCCACHE_GHA_ENABLED: "true"
SCCACHE_CACHE_SIZE: "2G"
CCACHE_SLOPPINESS: pch_defines,time_macros
CCACHE_DEPEND: "true"
CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_COMPILERCHECK: content
CCACHE_MAXSIZE: 2G

steps:
- uses: actions/checkout@v1
Expand All @@ -31,8 +34,12 @@ jobs:
sudo apt-get update
sudo apt-get install clang qt6-base-dev libglvnd-dev zlib1g-dev libfftw3-dev ninja-build python3-numpy libpng-dev mesa-vulkan-drivers

- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.9
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ${{ github.workflow }}-${{ github.job }}
max-size: 2G
verbose: 1

- name: Get CMake
uses: lukka/get-cmake@latest
Expand Down Expand Up @@ -85,8 +92,11 @@ jobs:

env:
QT_SELECT: qt6
SCCACHE_GHA_ENABLED: "true"
SCCACHE_CACHE_SIZE: "2G"
CCACHE_SLOPPINESS: pch_defines,time_macros
CCACHE_DEPEND: "true"
CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_COMPILERCHECK: content
CCACHE_MAXSIZE: 2G

steps:
- uses: actions/checkout@v1
Expand All @@ -98,8 +108,12 @@ jobs:
sudo apt-get update
sudo apt-get install g++-9 qt6-base-dev libglvnd-dev zlib1g-dev libfftw3-dev ninja-build python3-numpy libpng-dev mesa-vulkan-drivers

- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.9
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ${{ github.workflow }}-${{ github.job }}
max-size: 2G
verbose: 1

- name: Get CMake
uses: lukka/get-cmake@latest
Expand Down Expand Up @@ -142,8 +156,11 @@ jobs:
runs-on: macos-latest

env:
SCCACHE_GHA_ENABLED: "true"
SCCACHE_CACHE_SIZE: "2G"
CCACHE_SLOPPINESS: pch_defines,time_macros
CCACHE_DEPEND: "true"
CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_COMPILERCHECK: content
CCACHE_MAXSIZE: 2G

steps:
- uses: actions/checkout@v1
Expand All @@ -156,8 +173,12 @@ jobs:
brew link --force qt
brew install numpy

- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.9
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ${{ github.workflow }}-${{ github.job }}
max-size: 2G
verbose: 1

- name: Get CMake
uses: lukka/get-cmake@latest
Expand All @@ -177,7 +198,6 @@ jobs:
-D CMAKE_FIND_FRAMEWORK=LAST
-D MRTRIX_BUILD_TESTS=ON
-D MRTRIX_STL_DEBUGGING=ON
-D MRTRIX_USE_PCH=OFF
-D MRTRIX_WARNINGS_AS_ERRORS=ON

- name: build
Expand Down Expand Up @@ -212,9 +232,12 @@ jobs:
env:
CHERE_INVOKING: enabled_from_arguments
MINGW_PACKAGE_PREFIX: mingw-w64-ucrt-x86_64
SCCACHE_GHA_ENABLED: "true"
SCCACHE_CACHE_SIZE: "2G"
SCCACHE_DIR: ${{ github.workspace }}/.sccache
CCACHE_SLOPPINESS: pch_defines,time_macros
CCACHE_DEPEND: "true"
CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_COMPILERCHECK: content
CCACHE_MAXSIZE: 2G
CCACHE_DIR: ${{ github.workspace }}/.ccache

steps:
- uses: actions/checkout@v1
Expand All @@ -229,6 +252,7 @@ jobs:
git
python
${{env.MINGW_PACKAGE_PREFIX}}-bc
${{env.MINGW_PACKAGE_PREFIX}}-ccache
${{env.MINGW_PACKAGE_PREFIX}}-cmake
${{env.MINGW_PACKAGE_PREFIX}}-diffutils
${{env.MINGW_PACKAGE_PREFIX}}-fftw
Expand All @@ -241,13 +265,13 @@ jobs:
${{env.MINGW_PACKAGE_PREFIX}}-qt6-svg
${{env.MINGW_PACKAGE_PREFIX}}-zlib

- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.9

- name: export sccache to msys2 shell
run: |
export SCCACHE_UNIX_PATH=$(cygpath -u "$SCCACHE_PATH")
echo "SCCACHE_UNIX_PATH=$SCCACHE_UNIX_PATH" >> $GITHUB_ENV
- name: Restore ccache
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/.ccache
key: ${{ github.workflow }}-windows-ccache-${{ github.run_id }}
restore-keys: |
${{ github.workflow }}-windows-ccache-

- name: configure
run: >
Expand All @@ -258,8 +282,7 @@ jobs:
-D MRTRIX_BUILD_TESTS=ON
-D MRTRIX_STL_DEBUGGING=ON
-D MRTRIX_WARNINGS_AS_ERRORS=ON
-D MRTRIX_ENABLE_GPU=OFF
-D CMAKE_CXX_COMPILER_LAUNCHER=${{env.SCCACHE_UNIX_PATH}} .
-D MRTRIX_ENABLE_GPU=OFF .

- name: build
run: cmake --build build -- -k 0
Expand Down
15 changes: 11 additions & 4 deletions .github/workflows/weekly_sanitizers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ jobs:
runs-on: ubuntu-latest

env:
SCCACHE_GHA_ENABLED: "true"
SCCACHE_CACHE_SIZE: "2G"
CCACHE_SLOPPINESS: pch_defines,time_macros
CCACHE_DEPEND: "true"
CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_COMPILERCHECK: content
CCACHE_MAXSIZE: 2G

strategy:
fail-fast: false
Expand All @@ -30,8 +33,12 @@ jobs:
sudo apt-get update
sudo apt-get install clang llvm qt6-base-dev libglvnd-dev libeigen3-dev zlib1g-dev libfftw3-dev libpng-dev ninja-build python3-numpy

- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.9
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ${{ github.workflow }}-${{ github.job }}-${{ matrix.sanitizer }}
max-size: 2G
verbose: 1

- name: Get CMake
uses: lukka/get-cmake@latest
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ You can address all *MRtrix3*-related queries there, using your GitHub or Google
$ cmake --build build
$ cmake --install build

It's **highly** recommended, that you use [Ninja](https://ninja-build.org/) and a compiler caching tool like [ccache](https://ccache.dev/) or [sccache](https://github.com/mozilla/sccache) to speed up compilation time. You can install these tools using your package manager (e.g. `apt install ninja-build ccache` or `brew install ninja ccache`). Then, add `-GNinja` to the third step above or set the environment variable `CMAKE_GENERATOR` variable to `Ninja`.
It's **highly** recommended, that you use [Ninja](https://ninja-build.org/) and a compiler caching tool like [ccache](https://ccache.dev/) to speed up compilation time. You can install these tools using your package manager (e.g. `apt install ninja-build ccache` or `brew install ninja ccache`). Then, add `-GNinja` to the third step above or set the environment variable `CMAKE_GENERATOR` variable to `Ninja`.

NOTE: by default MRtrix3 will build using Qt 6, but if you wish to use Qt 5
you can specify this by passing `-DMRTRIX_USE_QT5=ON` when configuring the build.
Expand Down
4 changes: 3 additions & 1 deletion cmake/CompilerCache.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ function(use_compiler_cache)
)
endif()

find_program(CACHE_BINARY NAMES ${CACHE_OPTION_VALUES})
# Honour the requested tool only, so selection is deterministic and a stray
# sccache on a runner image can never be picked in preference to ccache.
find_program(CACHE_BINARY NAMES ${CACHE_OPTION})

@daljit46 daljit46 Jul 5, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed this when writing this code, but I think CACHE_BINARY here should use NO_CACHE because if the developer changes CACHE_OPTION, this also needs updating.

if(CACHE_BINARY)
message(STATUS "${CACHE_BINARY} found and enabled")
set(CMAKE_CXX_COMPILER_LAUNCHER
Expand Down
Loading