-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
369 additions
and
82 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,63 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
workflow_dispatch: | ||
|
||
env: | ||
BUILD_DIR: _build | ||
INSTALL_DIR: _install | ||
EXPORT_BUILD_DIR: _build_export | ||
|
||
jobs: | ||
|
||
cmake_build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
|
||
- name: Check-out code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Intel oneAPI | ||
uses: rscohn2/setup-oneapi@v0 | ||
with: | ||
components: ifx | ||
|
||
- name: Set compiler environment | ||
run: echo "FC=ifx" >> ${GITHUB_ENV} | ||
|
||
- name: Setup CMake | ||
uses: jwlawson/[email protected] | ||
|
||
- name: Setup Ninja | ||
uses: ashutoshvarma/[email protected] | ||
|
||
- name: Build Fortuno | ||
run: | | ||
source /opt/intel/oneapi/setvars.sh | ||
cmake -B ${BUILD_DIR} -G Ninja -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} | ||
cmake --build ${BUILD_DIR} | ||
cmake --install ${BUILD_DIR} | ||
- name: Test CMake export | ||
run: | | ||
source /opt/intel/oneapi/setvars.sh | ||
CMAKE_PREFIX_PATH=${INSTALL_DIR} cmake -B ${EXPORT_BUILD_DIR} -G Ninja test/export | ||
cmake --build ${EXPORT_BUILD_DIR} | ||
${EXPORT_BUILD_DIR}/testapp | ||
- name: Test PkgConfig export | ||
run: | | ||
source /opt/intel/oneapi/setvars.sh | ||
export LD_LIBRARY_PATH="${INSTALL_DIR}/lib:${LD_LIBRARY_PATH}" | ||
export PKG_CONFIG_PATH="${INSTALL_DIR}/lib/pkgconfig:${PKG_CONFIG_PATH}" | ||
cflags="$(pkg-config --cflags fortuno)" | ||
lflags="$(pkg-config --libs fortuno)" | ||
ifx ${cflags} ${lflags} -o testapp test/export/testapp.f90 | ||
./testapp | ||
rm ./testapp |
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,151 @@ | ||
#[=================================================================================================[ | ||
# Basic project definition # | ||
]=================================================================================================] | ||
|
||
cmake_minimum_required(VERSION 3.22...3.28) | ||
|
||
list(APPEND CMAKE_MESSAGE_CONTEXT Fortuno) | ||
project( | ||
Fortuno | ||
VERSION 0.1.0 | ||
DESCRIPTION "Extensible unit testing framework for Fortran" | ||
HOMEPAGE_URL "https://github.com/fortuno-repos/fortuno" | ||
LANGUAGES Fortran | ||
) | ||
|
||
|
||
#[=================================================================================================[ | ||
# Options # | ||
]=================================================================================================] | ||
|
||
include(FeatureSummary) | ||
|
||
option(FORTUNO_BUILD_SHARED_LIBS "Fortuno: Build as shared library" ${PROJECT_IS_TOP_LEVEL}) | ||
|
||
option(FORTUNO_BUILD_TESTS "Fortuno: Build test suite" ${PROJECT_IS_TOP_LEVEL}) | ||
|
||
option(FORTUNO_BUILD_EXAMPLES "Fortuno: Build example apps" ${PROJECT_IS_TOP_LEVEL}) | ||
|
||
option(FORTUNO_INSTALL "Fortuno: Install project" ${PROJECT_IS_TOP_LEVEL}) | ||
|
||
set( | ||
FORTUNO_INSTALL_MODULEDIR "modules" CACHE STRING | ||
"Sub-directory to install the Fortran module files into (relative to CMAKE_INSTALL_LIBDIR)" | ||
) | ||
|
||
#[=================================================================================================[ | ||
# Project configuration # | ||
]=================================================================================================] | ||
|
||
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) | ||
include(FortunoHelpers) | ||
|
||
if (FORTUNO_INSTALL) | ||
include(CMakePackageConfigHelpers) | ||
include(GNUInstallDirs) | ||
endif () | ||
|
||
fortuno_setup_build_type("RelWithDebInfo") | ||
set(BUILD_SHARED_LIBS ${FORTUNO_BUILD_SHARED_LIBS}) | ||
|
||
# Report configuration | ||
feature_summary( | ||
FILENAME ${CMAKE_CURRENT_BINARY_DIR}/Fortuno.info | ||
VAR Fortuno_Info | ||
DESCRIPTION "Fortuno features and external libraries" | ||
FATAL_ON_MISSING_REQUIRED_PACKAGES | ||
WHAT ALL | ||
) | ||
message(STATUS ${Fortuno_Info}) | ||
|
||
|
||
#[=================================================================================================[ | ||
# Main definition # | ||
]=================================================================================================] | ||
|
||
add_library(Fortuno) | ||
set_target_properties( | ||
Fortuno PROPERTIES | ||
VERSION ${PROJECT_VERSION} | ||
# SOVERSION ${PROJECT_VERSION_MAJOR} | ||
SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} | ||
EXPORT_NAME Fortuno | ||
OUTPUT_NAME fortuno | ||
) | ||
add_library(Fortuno::Fortuno ALIAS Fortuno) | ||
|
||
add_subdirectory(src) | ||
if (FORTUNO_BUILD_EXAMPLES) | ||
add_subdirectory(example) | ||
endif () | ||
|
||
|
||
#[=================================================================================================[ | ||
# Install or Export # | ||
]=================================================================================================] | ||
|
||
if (FORTUNO_INSTALL) | ||
|
||
# pkg-config files | ||
configure_file(cmake/fortuno.pc.in fortuno.pc @ONLY) | ||
install( | ||
FILES ${CMAKE_CURRENT_BINARY_DIR}/fortuno.pc | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig | ||
COMPONENT Fortuno_development | ||
) | ||
|
||
# cmake export files | ||
write_basic_package_version_file( | ||
${CMAKE_CURRENT_BINARY_DIR}/FortunoConfigVersion.cmake | ||
VERSION ${PROJECT_VERSION} | ||
# COMPATIBILITY SameMajorVersion | ||
COMPATIBILITY SameMinorVersion | ||
) | ||
configure_package_config_file( | ||
cmake/FortunoConfig.cmake.in | ||
${CMAKE_CURRENT_BINARY_DIR}/FortunoConfig.cmake | ||
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Fortuno | ||
) | ||
install( | ||
FILES ${CMAKE_CURRENT_BINARY_DIR}/FortunoConfigVersion.cmake | ||
${CMAKE_CURRENT_BINARY_DIR}/FortunoConfig.cmake | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Fortuno | ||
COMPONENT Fortuno_development | ||
) | ||
|
||
export( | ||
EXPORT FortunoTargets | ||
FILE FortunoTargets.cmake | ||
NAMESPACE Fortuno:: | ||
) | ||
install( | ||
EXPORT FortunoTargets | ||
FILE FortunoTargets.cmake | ||
NAMESPACE Fortuno:: | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Fortuno | ||
COMPONENT Fortuno_development | ||
) | ||
endif () | ||
|
||
|
||
# Make project available for FetchContent | ||
if (NOT PROJECT_IS_TOP_LEVEL) | ||
# Propagate variables | ||
if (CMAKE_VERSION VERSION_LESS 3.25) | ||
# TODO: Remove when required minimum cmake version is >= 3.25 | ||
set(Fortuno_VERSION ${Fortuno_VERSION} PARENT_SCOPE) | ||
set(Fortuno_VERSION_MAJOR ${Fortuno_VERSION_MAJOR} PARENT_SCOPE) | ||
set(Fortuno_VERSION_MINOR ${Fortuno_VERSION_MINOR} PARENT_SCOPE) | ||
set(Fortuno_VERSION_PATCH ${Fortuno_VERSION_PATCH} PARENT_SCOPE) | ||
set(Fortuno_VERSION_TWEAK ${Fortuno_VERSION_TWEAK} PARENT_SCOPE) | ||
else () | ||
return( | ||
PROPAGATE | ||
Fortuno_VERSION | ||
Fortuno_VERSION_MAJOR | ||
Fortuno_VERSION_MINOR | ||
Fortuno_VERSION_PATCH | ||
Fortuno_VERSION_TWEAK | ||
) | ||
endif () | ||
endif () |
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,3 @@ | ||
@PACKAGE_INIT@ | ||
|
||
include(${CMAKE_CURRENT_LIST_DIR}/FortunoTargets.cmake) |
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,20 @@ | ||
# Sets up the build type. | ||
function (fortuno_setup_build_type default_build_type) | ||
|
||
get_property(_multiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) | ||
if(_multiConfig) | ||
message(STATUS "Build type multi-config (build type selected at the build step)") | ||
else() | ||
if(NOT CMAKE_BUILD_TYPE) | ||
message(STATUS "Build type ${default_build_type} (default single-config)") | ||
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Build type" FORCE) | ||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY HELPSTRING "Choose the type of build") | ||
set_property( | ||
CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "RelWithDebInfo" | ||
) | ||
else() | ||
message(STATUS "Fortuno: build type: ${CMAKE_BUILD_TYPE} (manually selected single-config)") | ||
endif() | ||
endif() | ||
|
||
endfunction() |
Empty file.
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,6 @@ | ||
Name: @PROJECT_NAME@ | ||
Description: @PROJECT_DESCRIPTION@ | ||
Version: @PROJECT_VERSION@ | ||
|
||
Libs: -L@CMAKE_INSTALL_FULL_LIBDIR@ -lfortuno | ||
Cflags: -I@CMAKE_INSTALL_FULL_LIBDIR@/@FORTUNO_INSTALL_MODULEDIR@ |
This file was deleted.
Oops, something went wrong.
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,24 @@ | ||
list(APPEND CMAKE_MESSAGE_CONTEXT Example) | ||
|
||
add_library(Fortuno_example_mylib) | ||
set_target_properties( | ||
Fortuno_example_mylib PROPERTIES | ||
OUTPUT_NAME mylib | ||
) | ||
target_sources( | ||
Fortuno_example_mylib PRIVATE | ||
mylib.f90 | ||
) | ||
|
||
add_executable(Fortuno_example_testapp) | ||
set_target_properties( | ||
Fortuno_example_testapp PROPERTIES | ||
OUTPUT_NAME testapp | ||
) | ||
target_sources( | ||
Fortuno_example_testapp PRIVATE | ||
fixtured_tests.f90 | ||
simple_tests.f90 | ||
testapp.f90 | ||
) | ||
target_link_libraries(Fortuno_example_testapp PRIVATE Fortuno_example_mylib Fortuno::Fortuno) |
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,43 @@ | ||
target_sources( | ||
Fortuno PRIVATE | ||
fortuno.f90 | ||
) | ||
add_subdirectory(fortuno) | ||
|
||
# Store generated mod-files in a separate folder | ||
set(moduledir "${CMAKE_CURRENT_BINARY_DIR}/mods") | ||
set_target_properties( | ||
Fortuno PROPERTIES | ||
Fortran_MODULE_DIRECTORY "${moduledir}" | ||
) | ||
|
||
# Add mod-file directory to include search path for targets depending on the library | ||
target_include_directories( | ||
Fortuno PUBLIC | ||
$<BUILD_INTERFACE:${moduledir}> | ||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_LIBDIR}/${FORTUNO_INSTALL_MODULEDIR}> | ||
) | ||
|
||
# ifx (as of version 2024.0.2) crashes when optimization is turned on | ||
if (${CMAKE_Fortran_COMPILER_ID} STREQUAL "IntelLLVM") | ||
target_compile_options(Fortuno PRIVATE "-O0") | ||
endif () | ||
|
||
if (FORTUNO_INSTALL) | ||
install( | ||
TARGETS Fortuno | ||
EXPORT FortunoTargets | ||
LIBRARY | ||
DESTINATION "${CMAKE_INSTALL_LIBDIR}" | ||
COMPONENT Fortuno_runtime | ||
NAMELINK_COMPONENT Fortuno_development | ||
PUBLIC_HEADER | ||
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" | ||
COMPONENT Fortuno_development | ||
) | ||
install( | ||
DIRECTORY "${moduledir}/" | ||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/${FORTUNO_INSTALL_MODULEDIR}" | ||
COMPONENT Fortuno_development | ||
) | ||
endif () |
Oops, something went wrong.