Skip to content

Commit

Permalink
Merge pull request #17 from jchristopherson/fpm
Browse files Browse the repository at this point in the history
Added FPM support
  • Loading branch information
jchristopherson authored Sep 15, 2023
2 parents 9d3170e + c102834 commit 619e769
Show file tree
Hide file tree
Showing 21 changed files with 425 additions and 10,467 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: CMake

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

env:
BUILD_TYPE: Release

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
toolchain:
- {compiler: gcc, version: 11}
- {compiler: intel-classic, version: '2021.9'}
include:
- os: ubuntu-latest
toolchain: {compiler: intel, version: '2023.2'}

steps:
- uses: awvwgk/setup-fortran@v1
id: setup-fortran
with:
compiler: ${{ matrix.toolchain.compiler }}
version: ${{ matrix.toolchain.version }}

- run: ${{ env.FC }} --version
env:
FC: ${{ steps.setup-fortran.outputs.fc }}
CC: ${{ steps.setup-fortran.outputs.cc }}

- uses: actions/checkout@v3

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_Fortran_COMPILER=${{ env.FC }} -DBUILD_TESTING=TRUE

- name: Build with CMake
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

- name: Test with CMake
working-directory: ${{github.workspace}}/build
run: ctest -C ${{env.BUILD_TYPE}}
127 changes: 127 additions & 0 deletions .github/workflows/fpm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
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 FERROR
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
- 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"
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ add_fortran_library(
link_library(${PROJECT_NAME} ${ferror_LIBRARY} ${ferror_INCLUDE_DIR})
link_library(${PROJECT_NAME} ${iso_varying_string_LIBRARY} ${iso_varying_string_INCLUDE_DIR})
link_library(${PROJECT_NAME} ${collections_LIBRARY} ${collections_INCLUDE_DIR})
link_library(${PROJECT_NAME} ${geompack_LIBRARY} ${geompack_INCLUDE_DIR})

# Installation
# add_subdirectory(install)
Expand All @@ -43,3 +44,14 @@ if (BUILD_FPLOT_EXAMPLES)
# Build the examples
add_subdirectory(examples)
endif()

# ------------------------------------------------------------------------------
# TESTING
# ------------------------------------------------------------------------------
option(BUILD_TESTING "Build tests")
include(CTest)
message(STATUS "Build tests: ${BUILD_TESTING}")
if (BUILD_TESTING)
enable_testing()
add_subdirectory(test)
endif()
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# fplot
A Fortran library providing a convenient interface for plotting with Gnuplot.


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

## Gnuplot
This library is tailored to write script files for Gnuplot. As such, Gnuplot is required to make use of the output of this library. Gnuplot can be found [here](http://www.gnuplot.info/).

Expand Down Expand Up @@ -336,10 +341,20 @@ This is the plot resulting from the above program.
![](images/polar_example_1.png?raw=true)

## Building FPLOT
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 FPLOT library can be used within your FPM project by adding the following to your fpm.toml file.
```
[dependencies]
fplot = { git = "https://github.com/jchristopherson/fplot" }
## External Libraries
The FPLOT library depends upon the following libraries.
- [FERROR](https://github.com/jchristopherson/ferror)
- [COLLECTIONS](https://github.com/jchristopherson/collections)
- [ISO_VARYING_STRING](https://gitlab.com/everythingfunctional/iso_varying_string)
- [GEOMPACK](https://github.com/jchristopherson/geompack)
7 changes: 6 additions & 1 deletion dependencies/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@ set(iso_varying_string_INCLUDE_DIR ${iso_varying_string_INCLUDE_DIR} PARENT_SCOP
# Get COLLECTIONS
add_subdirectory(collections)
set(collections_LIBRARY ${collections_LIBRARY} PARENT_SCOPE)
set(collections_INCLUDE_DIR ${collections_INCLUDE_DIR} PARENT_SCOPE)
set(collections_INCLUDE_DIR ${collections_INCLUDE_DIR} PARENT_SCOPE)

# Get GEOMPACK
add_subdirectory(geompack)
set(geompack_LIBRARY ${geompack_LIBRARY} PARENT_SCOPE)
set(geompack_INCLUDE_DIR ${geompack_INCLUDE_DIR} PARENT_SCOPE)
30 changes: 30 additions & 0 deletions dependencies/geompack/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Get the macros and functions we'll need
include("${PROJECT_SOURCE_DIR}/cmake/helper.cmake")
include(FetchContent)

# Fetch the proper content
FetchContent_Declare(
geompack
GIT_REPOSITORY "https://github.com/jchristopherson/geompack"
GIT_TAG main
)

FetchContent_MakeAvailable(geompack)

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

set(geompack_INCLUDE_DIR ${geompack_BINARY_DIR}/include)
set(geompack_INCLUDE_DIR ${geompack_INCLUDE_DIR} PARENT_SCOPE)

# Make a parent-scope variable for the library
set(geompack_LIBRARY geompack)
set(geompack_LIBRARY ${geompack_LIBRARY} PARENT_SCOPE)
30 changes: 30 additions & 0 deletions fpm.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name = "fplot"
version = "1.6.2"
license = "GPL-3.0"
author = "Jason Christopherson"
maintainer = "Jason Christopherson"
copyright = "Copyright 2017-2023, Jason Christopherson"
description = "A Fortran library providing a convenient interface for plotting with Gnuplot."
homepage = "https://github.com/jchristopherson/fplot"

[library]
source-dir = "src"

[dependencies]
ferror = { git = "https://github.com/jchristopherson/ferror" }
collections = { git = "https://github.com/jchristopherson/collections" }
iso_varying_string = { git = "https://gitlab.com/everythingfunctional/iso_varying_string" }
geompack = { git = "https://github.com/jchristopherson/geompack" }

[install]
library = true

[build]
auto-executables = false
auto-examples = false
auto-tests = false

[[test]]
name = "fplot_test"
source-dir = "test"
main = "fplot_test.f90"
2 changes: 0 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ set(FPLOT_SOURCES
${dir}/fplot_vector_field_plot_data.f90
${dir}/fplot_plot_polar.f90
${dir}/fplot_filled_plot_data.f90
${dir}/geompack.f
${dir}/tripack.f
${dir}/fplot_string_builder.f90
${dir}/fplot_string_builder_implementation.f90
${dir}/fplot_triangulations_delaunay_2d.f90
Expand Down
Loading

0 comments on commit 619e769

Please sign in to comment.