Skip to content

Commit 65b0b37

Browse files
Merge pull request #10 from jchristopherson/fpm
Add FPM support
2 parents f2af68c + 6e15098 commit 65b0b37

File tree

9 files changed

+215
-62
lines changed

9 files changed

+215
-62
lines changed

.github/workflows/cmake.yml

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,47 @@ name: CMake
22

33
on:
44
push:
5-
branches: [ "master" ]
5+
branches: [ "main" ]
66
pull_request:
7-
branches: [ "master" ]
7+
branches: [ "main" ]
88

99
env:
1010
BUILD_TYPE: Release
1111

1212
jobs:
13-
build:
13+
test:
1414
runs-on: ${{ matrix.os }}
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
fortran_compiler: [gfortran, ifort]
19-
os: [ubuntu-latest, macos-latest] # issue with windows-latest & CMake with CMake not recognizing defined compilers
18+
os: [ubuntu-latest, macos-latest]
19+
toolchain:
20+
- {compiler: gcc, version: 11}
21+
- {compiler: intel-classic, version: '2021.9'}
22+
include:
23+
- os: ubuntu-latest
24+
toolchain: {compiler: intel, version: '2023.2'}
2025

2126
steps:
22-
23-
- name: Setup IFORT
24-
if: contains( matrix.fortran_compiler, 'ifort' )
25-
uses: modflowpy/install-intelfortran-action@v1
26-
27-
- name: Setup GFORTRAN
28-
if: contains( matrix.fortran_compiler, 'gfortran')
29-
uses: awvwgk/setup-fortran@main
30-
id: setup-fortran
31-
with:
32-
compiler: gcc
33-
version: 12
34-
35-
env:
36-
FC: ${{ steps.setup-fortran.outputs.fc }}
37-
CC: ${{ steps.setup-fortran.outputs.cc }}
38-
39-
- uses: actions/checkout@v3
40-
41-
- name: Configure CMake
42-
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_C_COMPILER=${{ env.CC }} -DCMAKE_Fortran_COMPILER=${{ env.FC }} -DBUILD_TESTING=TRUE -DBUILD_C_API=TRUE
27+
- uses: awvwgk/setup-fortran@v1
28+
id: setup-fortran
29+
with:
30+
compiler: ${{ matrix.toolchain.compiler }}
31+
version: ${{ matrix.toolchain.version }}
32+
33+
- run: ${{ env.FC }} --version
34+
env:
35+
FC: ${{ steps.setup-fortran.outputs.fc }}
36+
CC: ${{ steps.setup-fortran.outputs.cc }}
37+
38+
- uses: actions/checkout@v3
4339

44-
- name: Build with CMake
45-
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
40+
- name: Configure CMake
41+
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_Fortran_COMPILER=${{ env.FC }} -DBUILD_TESTING=TRUE
42+
43+
- name: Build with CMake
44+
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
4645

47-
- name: Test with CMake
48-
working-directory: ${{github.workspace}}/build
49-
run: ctest -C ${{env.BUILD_TYPE}}
46+
- name: Test with CMake
47+
working-directory: ${{github.workspace}}/build
48+
run: ctest -C ${{env.BUILD_TYPE}}

.github/workflows/fpm.yml

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
name: fpm
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
gcc-build:
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
fail-fast: false
10+
matrix:
11+
os: [ubuntu-latest, macos-11]
12+
gcc_v: [10] # Version of GFortran we want to use.
13+
include:
14+
- os: ubuntu-latest
15+
os-arch: linux-x86_64
16+
17+
- os: macos-11
18+
os-arch: macos-x86_64
19+
20+
env:
21+
FC: gfortran
22+
GCC_V: ${{ matrix.gcc_v }}
23+
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v1
27+
28+
- name: Install GFortran macOS
29+
if: contains(matrix.os, 'macos')
30+
run: |
31+
ln -s /usr/local/bin/gfortran-${GCC_V} /usr/local/bin/gfortran
32+
which gfortran-${GCC_V}
33+
which gfortran
34+
35+
- name: Install GFortran Linux
36+
if: contains(matrix.os, 'ubuntu')
37+
run: |
38+
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${GCC_V} 100 \
39+
--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${GCC_V} \
40+
--slave /usr/bin/gcov gcov /usr/bin/gcov-${GCC_V}
41+
42+
- name: Install fpm
43+
uses: fortran-lang/setup-fpm@v3
44+
with:
45+
fpm-version: 'v0.8.2'
46+
47+
- name: Build FERROR
48+
run: |
49+
gfortran --version
50+
fpm build
51+
52+
- name: Run tests
53+
run: |
54+
gfortran --version
55+
fpm test
56+
57+
msys2-build:
58+
runs-on: windows-latest
59+
defaults:
60+
run:
61+
shell: msys2 {0}
62+
63+
steps:
64+
- uses: actions/checkout@v2
65+
- uses: msys2/setup-msys2@v2
66+
with:
67+
msystem: MINGW64
68+
update: true
69+
path-type: inherit
70+
install: |
71+
mingw-w64-x86_64-gcc-fortran
72+
mingw-w64-x86_64-fpm
73+
74+
- name: fpm build
75+
run: |
76+
gfortran --version
77+
fpm --version
78+
fpm build
79+
80+
- name: fpm test
81+
run: |
82+
fpm test
83+
84+
intel-build:
85+
runs-on: ubuntu-latest
86+
strategy:
87+
fail-fast: false
88+
89+
env:
90+
FPM_FC: ifort
91+
FC: ifort
92+
93+
steps:
94+
- name: Checkout code
95+
uses: actions/checkout@v3
96+
97+
- name: Add Intel repository (Linux)
98+
run: |
99+
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
100+
sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
101+
rm GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
102+
echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
103+
sudo apt-get update
104+
105+
- name: Install Intel oneAPI compiler (Linux)
106+
run: |
107+
sudo apt-get install intel-oneapi-compiler-fortran
108+
109+
- name: Setup Intel oneAPI environment
110+
run: |
111+
source /opt/intel/oneapi/setvars.sh
112+
printenv >> $GITHUB_ENV
113+
114+
- name: Install fpm
115+
uses: fortran-lang/setup-fpm@v3
116+
with:
117+
fpm-version: 'v0.8.2'
118+
119+
- name: fpm build
120+
run: |
121+
ifort --version
122+
fpm --version
123+
fpm build --profile debug --flag "-warn nointerfaces"
124+
125+
- name: fpm test
126+
run: |
127+
fpm test --profile debug --flag "-warn nointerfaces"

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ project(
55
LANGUAGES
66
C
77
Fortran
8-
VERSION "1.4.1"
8+
VERSION "1.4.2"
99
)
1010

1111
# Get the macros and functions we'll need

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ A library to assist with error handling in Fortran projects.
33

44
## Status
55
![Build Status](https://github.com/jchristopherson/ferror/actions/workflows/cmake.yml/badge.svg)
6+
[![Actions Status](https://github.com/jchristopherson/ferror/workflows/fpm/badge.svg)](https://github.com/jchristopherson/ferror/actions)
67

78
## Usage
89

cmake/helper.cmake

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ function(install_library lib_name lib_install_dir bin_install_dir mod_dir instal
4141
RUNTIME DESTINATION ${bin_install_dir}
4242
LIBRARY DESTINATION ${lib_install_dir}
4343
ARCHIVE DESTINATION ${lib_install_dir}
44+
INCLUDES DESTINATION ${install_dir}/include
4445
)
4546
install(
4647
DIRECTORY ${mod_dir}
@@ -56,13 +57,19 @@ function(install_documentation doc_dir install_dir)
5657
)
5758
endfunction()
5859

60+
# Links the supplied library
61+
function(link_library targ lib include_dir)
62+
target_link_libraries(${targ} ${lib})
63+
target_include_directories(${targ} PUBLIC $<BUILD_INTERFACE:${include_dir}>)
64+
endfunction()
65+
5966
# ------------------------------------------------------------------------------
6067
# Helpful Macros
6168
macro(print_all_variables)
62-
message(STATUS "---------- CURRENTLY DEFIND VARIABLES -----------")
69+
message(STATUS "---------- CURRENTLY DEFINED VARIABLES -----------")
6370
get_cmake_property(varNames VARIABLES)
6471
foreach(varName ${varNames})
6572
message(STATUS ${varName} = ${${varName}})
6673
endforeach()
6774
message(STATUS "---------- END ----------")
68-
endmacro()
75+
endmacro()

docs/Doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ PROJECT_NAME = ferror
4848
# could be handy for archiving the generated documentation or if some version
4949
# control system is used.
5050

51-
PROJECT_NUMBER = 1.4.1
51+
PROJECT_NUMBER = 1.4.2
5252

5353
# Using the PROJECT_BRIEF tag one can provide an optional one line description
5454
# for a project that appears at the top of each page and should give viewer a

fpm.toml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name = "ferror"
2+
version = "1.4.2"
3+
license = "GPL-3.0"
4+
author = "Jason Christopherson"
5+
maintainer = "Jason Christopherson"
6+
copyright = "Copyright 2017-2023, Jason Christopherson"
7+
description = "A library to assist with error handling in Fortran projects."
8+
homepage = "https://github.com/jchristopherson/ferror"
9+
10+
[library]
11+
source-dir = "src"
12+
13+
[[test]]
14+
name = "ferror_test"
15+
source-dir = "test"
16+
main = "ferror_test.f90"
17+
18+
[install]
19+
library = true
20+
21+
[build]
22+
auto-executables = false
23+
auto-examples = false
24+
auto-tests = false
25+
26+
[preprocess]
27+
[preprocess.cpp]

test/CMakeLists.txt

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,23 @@
1-
macro(create_test testname codename)
2-
add_executable(${testname} ${codename})
3-
target_link_libraries(${testname} ferror)
4-
target_include_directories(${testname} PUBLIC ${PROJECT_BINARY_DIR}/include)
5-
add_test(
6-
NAME ${testname}
7-
WORKING_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
8-
COMMAND $<TARGET_FILE:${testname}>
9-
)
10-
endmacro()
11-
12-
macro(create_c_test testname codename)
13-
add_executable(${testname} ${codename})
14-
target_link_libraries(${testname} ferror)
15-
add_test(
16-
NAME ${testname}
17-
WORKING_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
18-
COMMAND $<TARGET_FILE:${testname}>
19-
)
20-
endmacro()
1+
include("${PROJECT_SOURCE_DIR}/cmake/helper.cmake")
212

22-
include_directories(
23-
${CMAKE_CURRENT_SOURCE_DIR}
24-
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
3+
add_executable(ferror_test ferror_test.f90)
4+
link_library(ferror_test ${PROJECT_NAME} ${PROJECT_INCLUDE_DIR})
5+
add_test(
6+
NAME ferror_test
7+
WORKING_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
8+
COMMAND $<TARGET_FILE:ferror_test>
259
)
2610

27-
create_test(ferror_test ferror_test.f90)
28-
2911
if (${BUILD_C_API})
30-
create_test(ferror_test_c ferror_test_c.c)
31-
endif()
12+
include_directories(
13+
${CMAKE_CURRENT_SOURCE_DIR}
14+
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
15+
)
16+
add_executable(ferror_test_c C/ferror_test_c.c)
17+
link_library(ferror_test_c ${PROJECT_NAME} ${PROJECT_INCLUDE_DIR})
18+
add_test(
19+
NAME ferror_test_c
20+
WORKING_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
21+
COMMAND $<TARGET_FILE:ferror_test_c>
22+
)
23+
endif()

0 commit comments

Comments
 (0)