Skip to content

Commit 19d557c

Browse files
committed
ci,setup template
1 parent bda3460 commit 19d557c

File tree

13 files changed

+175
-229
lines changed

13 files changed

+175
-229
lines changed

.github/workflows/ci_linux.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

.github/workflows/ci_linux_meson.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.

.github/workflows/ci_macos.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.

.github/workflows/ci_macos_meson.yml

Lines changed: 0 additions & 43 deletions
This file was deleted.

.github/workflows/ci_windows_meson.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: ci_windows
1+
name: cmake
22

33
on:
44
push:
@@ -7,14 +7,16 @@ on:
77
- "**.F90"
88
- "**.cmake"
99
- "**/CMakeLists.txt"
10-
- ".github/workflows/ci_windows.yml"
11-
10+
- ".github/workflows/cmake.yml"
1211

1312

1413
jobs:
1514

16-
windows:
17-
runs-on: windows-latest
15+
linux:
16+
runs-on: ${{ matrix.os }}
17+
strategy:
18+
matrix:
19+
os: [ubuntu-latest, windows-latest, macos-latest]
1820
steps:
1921
- uses: actions/checkout@v2
2022

.github/workflows/meson.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: meson
2+
3+
on:
4+
push:
5+
paths:
6+
- "**/meson.build"
7+
- ".github/workflows/meson.yml"
8+
9+
10+
jobs:
11+
12+
linux:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
- uses: actions/setup-python@v2
17+
with:
18+
python-version: '3.x'
19+
20+
- run: pip install meson ninja
21+
22+
- run: meson setup build
23+
env:
24+
FC: gfortran-9
25+
CC: gcc-9
26+
CXX: g++-9
27+
28+
- run: meson compile -C build
29+
30+
- run: meson test -C build -v
31+
32+
macos:
33+
runs-on: macos-latest
34+
steps:
35+
- uses: actions/checkout@v2
36+
- uses: actions/setup-python@v2
37+
with:
38+
python-version: '3.x'
39+
40+
- run: pip install meson ninja
41+
42+
- run: meson setup build
43+
env:
44+
FC: gfortran-9
45+
CC: gcc-9
46+
CXX: g++-9
47+
48+
- run: meson compile -C build
49+
50+
- run: meson test -C build -v
51+
52+
windows:
53+
runs-on: windows-latest
54+
steps:
55+
- uses: actions/checkout@v2
56+
- uses: actions/setup-python@v2
57+
with:
58+
python-version: '3.x'
59+
60+
- run: pip install meson ninja
61+
62+
- run: meson setup build
63+
64+
- run: meson compile -C build
65+
66+
- run: meson test -C build -v

CMakeLists.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
cmake_minimum_required(VERSION 3.15) # implicit CMP0094
1+
cmake_minimum_required(VERSION 3.15)
22

3-
if(NOT CMAKE_BUILD_TYPE)
4-
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "default build type")
5-
endif()
3+
include(cmake/policy.cmake)
4+
include(cmake/compiler_find.cmake)
65

76
project(Fortran2018Examples
87
LANGUAGES C Fortran
98
DESCRIPTION "Example of using modern Fortran syntax"
109
VERSION 1.3.2)
1110

12-
enable_testing()
13-
14-
set(CTEST_TEST_TIMEOUT 10) # default timeout [seconds]
11+
include(CTest)
12+
if(NOT DEFINED ${PROJECT_NAME}_BUILD_TESTING)
13+
set(${PROJECT_NAME}_BUILD_TESTING ${BUILD_TESTING})
14+
endif()
1515

1616
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/)
1717

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# Fortran 2018 Examples
22

3-
![Actions Status](https://github.com/scivision/fortran2018-examples/workflows/ci_linux/badge.svg)
4-
![Actions Status](https://github.com/scivision/fortran2018-examples/workflows/ci_windows/badge.svg)
5-
![Actions Status](https://github.com/scivision/fortran2018-examples/workflows/ci_macos/badge.svg)
3+
![Actions Status](https://github.com/scivision/fortran2018-examples/workflows/cmake/badge.svg)
4+
![Actions Status](https://github.com/scivision/fortran2018-examples/workflows/meson/badge.svg)
65

76
Easy examples of scientific computing with modern, powerful, easy Fortran 2018 standard.
87
Fortran 2018 began as the TS18508 extension, formerly known as Fortran 2015.

cmake/compiler_find.cmake

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# this must be include() before CMakeLists.txt project()
2+
3+
if(NOT CMAKE_BUILD_TYPE)
4+
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Debug or Release")
5+
endif()
6+
7+
set(CMAKE_CONFIGURATION_TYPES "Release;RelWithDebInfo;Debug" CACHE STRING "Build type selections" FORCE)
8+
9+
# Help CMake find matching compilers, especially needed for MacOS
10+
11+
if(NOT DEFINED ENV{FC})
12+
find_program(FC NAMES ifort gfortran gfortran-11 gfortran-10 gfortran-9 gfortran-8 gfortran-7)
13+
if(FC)
14+
set(ENV{FC} ${FC})
15+
endif()
16+
endif()
17+
18+
if(NOT DEFINED ENV{FC} OR DEFINED ENV{CC})
19+
return()
20+
endif()
21+
# ensure FC exists as a executable program
22+
find_program(FC NAMES $ENV{FC})
23+
24+
if(NOT FC)
25+
return()
26+
endif()
27+
28+
# remember, Apple has "/usr/bin/gcc" which is really clang
29+
# the technique below is NECESSARY to work on Mac and not find the wrong GCC
30+
get_filename_component(_dir ${FC} DIRECTORY)
31+
32+
# use same compiler for C and Fortran, which CMake might not do itself
33+
if(FC MATCHES ".*ifort")
34+
if(WIN32)
35+
set(_name icl)
36+
else()
37+
set(_name icc)
38+
endif()
39+
elseif(FC MATCHES ".*gfortran")
40+
set(_name gcc gcc-11 gcc-10 gcc-9 gcc-8 gcc-7)
41+
endif()
42+
43+
find_program(CC NAMES ${_name}
44+
HINTS ${_dir}
45+
NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
46+
47+
if(CC)
48+
set(ENV{CC} ${CC})
49+
endif()

0 commit comments

Comments
 (0)