Compilers and builds
Install a supported Fortran compiler with matching C and C++ compilers on Ubuntu, macOS or Windows. Select compiler and fpm versions, add Conda packages and build with fpm, CMake or Meson.
Supported compilers
| Runner | compiler |
|---|---|
| Ubuntu |
gfortran, ifx,
lfortran, flang,
flang-new, nvfortran,
aocc, aomp
|
| macOS | gfortran, lfortran |
| Windows |
gfortran, ifx,
lfortran, flang,
flang-new
|
Compiler toolchains
Each Fortran compiler is paired with the following C and C++ compilers.
| Runner | Fortran | C | C++ |
|---|---|---|---|
| Ubuntu | GNU Fortran | GNU C | GNU C++ |
| Ubuntu | Intel Fortran | Intel oneAPI DPC++/C++ | Intel oneAPI DPC++/C++ |
| Ubuntu | LFortran | Clang | Clang |
| Ubuntu | LLVM Flang | Clang | Clang |
| Ubuntu | NVIDIA HPC SDK Fortran | NVIDIA HPC SDK C | NVIDIA HPC SDK C++ |
| Ubuntu | AOCC (Flang) | AOCC (Clang) | AOCC (Clang) |
| Ubuntu | AOMP (Flang) | AOMP (Clang) | AOMP (Clang) |
| macOS | GNU Fortran | GNU C | GNU C++ |
| macOS | LFortran | Clang | Clang |
| Windows | GNU Fortran | GNU C | GNU C++ |
| Windows | Intel Fortran | Intel oneAPI DPC++/C++ | Intel oneAPI DPC++/C++ |
| Windows | LFortran | Clang | Clang |
| Windows | LLVM Flang | Clang | Clang |
Inputs
| Input | Default | Value |
|---|---|---|
compiler |
empty |
gfortran, ifx,
lfortran, flang,
flang-new, nvfortran,
aocc, aomp
|
compiler-version |
empty | Version, latest, or empty |
platform |
empty |
Empty uses the runner OS;
ubuntu-latest,
windows-latest,
macos-latest
|
extra-packages |
empty | Space- or comma-separated Conda packages |
fpm-version |
empty | Version, latest, or empty |
checkout-repo |
true |
true or false |
Permissions
Compiler setup reads Actions job metadata and checks out the repository by default.
permissions:
actions: read
contents: read
Exported environment
FC, CC, CXX,
FPM_FC, FPM_CC,
FPM_CXX,
CMAKE_Fortran_COMPILER,
CMAKE_C_COMPILER,
CMAKE_CXX_COMPILER
fpm
fpm is installed by default.
test_fpm:
name: ${{ matrix.os }}_${{ matrix.compiler }}_fpm
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- {os: ubuntu-latest, compiler: gfortran, compiler-version: "", fpm-version: "", extra-packages: ""}
steps:
- name: setup-fortran-conda
uses: gha3mi/setup-fortran-conda@latest
with:
compiler: ${{ matrix.compiler }}
compiler-version: ${{ matrix.compiler-version }}
fpm-version: ${{ matrix.fpm-version }}
extra-packages: ${{ matrix.extra-packages }}
- name: fpm test
run: fpm test --compiler "${{ env.FPM_FC }}" --profile release --verbose
CMake
CMake, Ninja and
pkg-config are installed by default.
test_cmake:
name: ${{ matrix.os }}_${{ matrix.compiler }}_cmake
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- {os: ubuntu-latest, compiler: gfortran, compiler-version: "", extra-packages: ""}
steps:
- name: setup-fortran-conda
uses: gha3mi/setup-fortran-conda@latest
with:
compiler: ${{ matrix.compiler }}
compiler-version: ${{ matrix.compiler-version }}
extra-packages: ${{ matrix.extra-packages }}
- name: CMake test
run: |
cmake -S . -B build -G Ninja -DCMAKE_Fortran_COMPILER="${{ env.CMAKE_Fortran_COMPILER }}"
cmake --build build --verbose
ctest --test-dir build --output-on-failure -VV
Meson
Meson, Ninja and
pkg-config are installed by default.
test_meson:
name: ${{ matrix.os }}_${{ matrix.compiler }}_meson
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- {os: ubuntu-latest, compiler: gfortran, compiler-version: "", extra-packages: ""}
steps:
- name: setup-fortran-conda
uses: gha3mi/setup-fortran-conda@latest
with:
compiler: ${{ matrix.compiler }}
compiler-version: ${{ matrix.compiler-version }}
extra-packages: ${{ matrix.extra-packages }}
- name: Meson test
run: |
meson setup build --buildtype release --backend=ninja
meson compile -C build --verbose
meson test -C build --verbose