Skip to content

Commit

Permalink
Merge pull request #18 from jchristopherson/FPM
Browse files Browse the repository at this point in the history
FPM
  • Loading branch information
jchristopherson authored Nov 22, 2023
2 parents c9b741d + 1dd251f commit 78471d4
Show file tree
Hide file tree
Showing 26 changed files with 943 additions and 216 deletions.
129 changes: 129 additions & 0 deletions .github/workflows/fpm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
name: fpm

on: [push, pull_request]

jobs:
gcc-build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-11]
gcc_v: [10] # Version of GFortran we want to use.
include:
- os: ubuntu-latest
os-arch: linux-x86_64

- os: macos-11
os-arch: macos-x86_64

env:
FC: gfortran
GCC_V: ${{ matrix.gcc_v }}

steps:
- name: Checkout code
uses: actions/checkout@v1

- name: Install GFortran macOS
if: contains(matrix.os, 'macos')
run: |
ln -s /usr/local/bin/gfortran-${GCC_V} /usr/local/bin/gfortran
which gfortran-${GCC_V}
which gfortran
- name: Install GFortran Linux
if: contains(matrix.os, 'ubuntu')
run: |
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${GCC_V} 100 \
--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${GCC_V} \
--slave /usr/bin/gcov gcov /usr/bin/gcov-${GCC_V}
- name: Install fpm
uses: fortran-lang/setup-fpm@v3
with:
fpm-version: 'v0.8.2'

- name: Build LINALG
run: |
gfortran --version
fpm build
- name: Run tests
run: |
gfortran --version
fpm test
msys2-build:
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}

steps:
- uses: actions/checkout@v2
- uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: true
path-type: inherit
install: |
mingw-w64-x86_64-gcc-fortran
mingw-w64-x86_64-fpm
mingw-w64-x86_64-openblas
mingw-w64-x86_64-lapack
- name: fpm build
run: |
gfortran --version
fpm --version
fpm build
- name: fpm test
run: |
fpm test
intel-build:
runs-on: ubuntu-latest
strategy:
fail-fast: false

env:
FPM_FC: ifort
FC: ifort

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Add Intel repository (Linux)
run: |
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
rm GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
sudo apt-get update
- name: Install Intel oneAPI compiler (Linux)
run: |
sudo apt-get install intel-oneapi-compiler-fortran
- name: Setup Intel oneAPI environment
run: |
source /opt/intel/oneapi/setvars.sh
printenv >> $GITHUB_ENV
- name: Install fpm
uses: fortran-lang/setup-fpm@v3
with:
fpm-version: 'v0.8.2'

- name: fpm build
run: |
ifort --version
fpm --version
fpm build --profile debug --flag "-warn nointerfaces"
- name: fpm test
run: |
fpm test --profile debug --flag "-warn nointerfaces"
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.24)
project(
linalg
LANGUAGES Fortran C
VERSION 1.7.2
VERSION 1.7.3
)

# Get helper macros and functions
Expand All @@ -18,7 +18,6 @@ add_subdirectory(configure)
# Deal with the dependencies
find_package(BLAS)
find_package(LAPACK)
find_package(ferror 1.4.0 QUIET)
add_subdirectory(dependencies)

# Source
Expand Down Expand Up @@ -48,6 +47,7 @@ message(STATUS "Build tests: ${BUILD_TESTING}")
if (BUILD_TESTING)
enable_testing()
add_subdirectory(tests)
add_subdirectory(tests_c)
endif()

# Examples
Expand Down
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ A linear algebra library that provides a user-friendly interface to several BLAS

## Status
![Build Status](https://github.com/jchristopherson/linalg/actions/workflows/cmake.yml/badge.svg)
[![Actions Status](https://github.com/jchristopherson/linalg/workflows/fpm/badge.svg)](https://github.com/jchristopherson/linalg/actions)

## Example 1
This example solves a normally defined system of 3 equations of 3 unknowns.
Expand Down Expand Up @@ -183,7 +184,17 @@ Mode 3: (923.5669 Hz)
The documentation can be found [here](https://jchristopherson.github.io/linalg/).

## Building LINALG
This library can be built using CMake. For instructions see [Running CMake](https://cmake.org/runningcmake/).
[CMake](https://cmake.org/)This library can be built using CMake. For instructions see [Running CMake](https://cmake.org/runningcmake/).

[FPM](https://github.com/fortran-lang/fpm) can also be used to build this library using the provided fpm.toml.
```txt
fpm build
```
The LINALG library can be used within your FPM project by adding the following to your fpm.toml file.
```toml
[dependencies]
linalg = { git = "https://github.com/jchristopherson/linalg" }
```

## External Libraries
Here is a list of external code libraries utilized by this library.
Expand Down
59 changes: 22 additions & 37 deletions dependencies/ferror/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,33 @@
include("${PROJECT_SOURCE_DIR}/cmake/helper.cmake")
include(FetchContent)

# If found, use the installed version; else, import the library
if (${ferror_FOUND})
# Inform the user of what's going on
message(STATUS "FERROR (${ferror_VERSION}) library found.")
# Fetch the proper content
FetchContent_Declare(
ferror
GIT_REPOSITORY "https://github.com/jchristopherson/ferror"
)

# Get the mod file location
get_target_property(ferror_INCLUDE_DIR ferror INTERFACE_INCLUDE_DIRECTORIES)
else()
# Inform the user of what's going on
message(STATUS "FERROR library not found. Downloading appropriate repository.")

# Fetch the proper content
FetchContent_Declare(
ferror
GIT_REPOSITORY "https://github.com/jchristopherson/ferror"
OVERRIDE_FIND_PACKAGE
)
FetchContent_MakeAvailable(ferror)

FetchContent_MakeAvailable(ferror)

if (WIN32)
if (${BUILD_SHARED_LIBS})
add_custom_command(
TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:ferror>
$<TARGET_FILE_DIR:${PROJECT_NAME}
)
endif()
if (WIN32)
if (BUILD_SHARED_LIBS)
add_custom_command(
TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:ferror>
$<TARGET_FILE_DIR:${PROJECT_NAME}
)
endif()

set(ferror_INCLUDE_DIR ${ferror_BINARY_DIR}/include)
configure_file(
"${ferror_SOURCE_DIR}/include/ferror.h"
"${ferror_INCLUDE_DIR}/ferror.h"
COPYONLY
)
endif()

set(ferror_INCLUDE_DIR ${ferror_BINARY_DIR}/include)
set(ferror_INCLUDE_DIR ${ferror_INCLUDE_DIR} PARENT_SCOPE)
configure_file(
"${ferror_SOURCE_DIR}/include/ferror.h"
"${ferror_INCLUDE_DIR}/ferror.h"
COPYONLY
)

# Make a parent-scope variable for the library
set(ferror_LIBRARY ferror)
set(ferror_LIBRARY ${ferror_LIBRARY} PARENT_SCOPE)

# Make a parent-scope variable locating the include directory for ferror
set(ferror_INCLUDE_DIR ${ferror_INCLUDE_DIR} PARENT_SCOPE)
2 changes: 1 addition & 1 deletion docs/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ PROJECT_NAME = linalg
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 1.7.2
PROJECT_NUMBER = 1.7.3

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
35 changes: 35 additions & 0 deletions fpm.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name = "linalg"
version = "1.7.3"
license = "GPL-3.0"
author = "Jason Christopherson"
maintainer = "Jason Christopherson"
copyright = "Copyright 2017-2023, Jason Christopherson"
description = "A linear algebra library that provides a user-friendly interface to several BLAS and LAPACK routines."
homepage = "https://github.com/jchristopherson/linalg"

[library]
source-dir = "src"

[fortran]
source-form = "default"
implicit-external = true

[dependencies]
ferror = { git = "https://github.com/jchristopherson/ferror" }

[dev-dependencies]
fortran_test_helper = { git = "https://github.com/jchristopherson/fortran_test_helper" }

[install]
library = true

[build]
link = ["blas", "lapack"]
auto-executables = false
auto-examples = false
auto-tests = false

[[test]]
name = "linalg_test"
source-dir = "tests"
main = "linalg_test.f90"
3 changes: 3 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ set(LINALG_SOURCES
${dir}/linalg_solve.f90
${dir}/linalg_sorting.f90
${dir}/linalg_basic.f90
${dir}/blas.f90
${dir}/lapack.f90
${dir}/qrupdate.f90
)
if (${BUILD_C_API})
set(LINALG_C_SOURCES
Expand Down
Loading

0 comments on commit 78471d4

Please sign in to comment.