-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from vil02/add_ci
- Loading branch information
Showing
6 changed files
with
105 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--- | ||
name: ci | ||
|
||
'on': | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
env: | ||
build_path: ${{github.workspace}}/build | ||
|
||
jobs: | ||
build_and_test: | ||
runs-on: ${{matrix.os}} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-22.04, ubuntu-24.04] | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Display versions | ||
run: | | ||
gfortran --version | ||
cmake --version | ||
- name: Create Build Directory | ||
run: cmake -E make_directory ${{env.build_path}} | ||
|
||
- name: Configure CMake | ||
working-directory: ${{env.build_path}} | ||
run: cmake ../ | ||
|
||
- name: Build | ||
working-directory: ${{env.build_path}} | ||
run: cmake --build . | ||
|
||
- name: Test | ||
working-directory: ${{env.build_path}} | ||
run: ctest | ||
|
||
- name: Run examples | ||
working-directory: ${{env.build_path}} | ||
run: make run_all_examples | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,3 +33,4 @@ | |
|
||
.idea/ | ||
|
||
/build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
project(FortranProject LANGUAGES Fortran) | ||
|
||
add_compile_options(-Wall -Wextra -Wpedantic) | ||
|
||
function(add_fortran_sources DIR SOURCES) | ||
file(GLOB_RECURSE NEW_SOURCES "${DIR}/*.f90") | ||
list(APPEND ${SOURCES} ${NEW_SOURCES}) | ||
set(${SOURCES} ${${SOURCES}} PARENT_SCOPE) | ||
endfunction() | ||
|
||
set(MODULE_SOURCES) | ||
add_fortran_sources(${CMAKE_SOURCE_DIR}/modules MODULE_SOURCES) | ||
|
||
add_library(modules STATIC ${MODULE_SOURCES}) | ||
|
||
function(create_unique_name FILE_NAME OUTPUT_NAME) | ||
file(RELATIVE_PATH REL_PATH "${CMAKE_SOURCE_DIR}" "${FILE_NAME}") | ||
get_filename_component(CUR_EXT "${REL_PATH}" LAST_EXT) | ||
string(REPLACE "/" "_" UNIQUE_NAME "${REL_PATH}") | ||
string(REPLACE "${CUR_EXT}" "" UNIQUE_NAME "${UNIQUE_NAME}") | ||
set(${OUTPUT_NAME} ${UNIQUE_NAME} PARENT_SCOPE) | ||
endfunction() | ||
|
||
|
||
file(GLOB_RECURSE TEST_FILES "${CMAKE_SOURCE_DIR}/tests/*.f90") | ||
|
||
foreach(TEST_FILE ${TEST_FILES}) | ||
create_unique_name(${TEST_FILE} TEST_NAME) | ||
add_executable(${TEST_NAME} ${TEST_FILE}) | ||
target_link_libraries(${TEST_NAME} modules) | ||
add_test(NAME ${TEST_NAME} COMMAND ${TEST_NAME}) | ||
endforeach() | ||
|
||
file(GLOB_RECURSE EXAMPLE_FILES "${CMAKE_SOURCE_DIR}/examples/*.f90") | ||
|
||
foreach(EXAMPLE_FILE ${EXAMPLE_FILES}) | ||
create_unique_name(${EXAMPLE_FILE} EXAMPLE_NAME) | ||
add_executable(${EXAMPLE_NAME} ${EXAMPLE_FILE}) | ||
target_link_libraries(${EXAMPLE_NAME} modules) | ||
list(APPEND EXAMPLE_NAME_LIST run_${EXAMPLE_NAME}) | ||
add_custom_target(run_${EXAMPLE_NAME} | ||
COMMAND ${EXAMPLE_NAME} | ||
DEPENDS ${EXAMPLE_NAME} | ||
COMMENT "Running example: ${EXAMPLE_NAME}") | ||
endforeach() | ||
|
||
enable_testing() | ||
|
||
add_custom_target(run_all_examples DEPENDS ${EXAMPLE_NAME_LIST}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters