Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
23d2af4
Move towards working compilation
Feb 8, 2021
f9ddde4
Ignore IntelliJ project and cmake-build directories
Feb 8, 2021
423ed5d
correct .f90 -> .F90
Feb 8, 2021
5e5f7dd
Removed compiler warnings - no way to avoid them, and added preproces…
AlexBuccheri Feb 8, 2021
bfd9e94
Deal with compiler warnings in release mode
AlexBuccheri Feb 8, 2021
f6fbf45
return prior to evaluating - minimises overhead
AlexBuccheri Feb 8, 2021
2f3dbf3
Preprocessor settings (missing from last 2 commits)
AlexBuccheri Feb 9, 2021
54585d8
Fully fleshed out CMake
AlexBuccheri Feb 20, 2021
8135e4c
Changed DEBUG back to USE_ASSERT
AlexBuccheri Feb 20, 2021
346df90
Started writing first test - note issues with initialising the MPI en…
AlexBuccheri Feb 20, 2021
ae8da13
Add unit tests once library compilation is tested
AlexBuccheri Feb 20, 2021
992d778
Fixed bug in choice of library name
AlexBuccheri Feb 20, 2021
d488e97
Add getter
AlexBuccheri Feb 20, 2021
eaa7f17
Fixed bugs
AlexBuccheri Feb 20, 2021
4c22536
Project description
AlexBuccheri Feb 20, 2021
181e558
More project description
AlexBuccheri Feb 20, 2021
7452b24
Update
AlexBuccheri Feb 20, 2021
3dc4d20
init-finalise and corresponding tests (note, the tests require more s…
AlexBuccheri Feb 20, 2021
78acdb0
Changed strategy for testing. program is not finding the subroutine i…
AlexBuccheri Feb 20, 2021
623d728
Test builds and runs a dummy assert, however it is not correctly set …
AlexBuccheri Feb 21, 2021
4c11c37
Refactored to use setup, teardown and autogenerate test drivers for o…
AlexBuccheri Feb 21, 2021
d7c5f80
Cleaned up init test
AlexBuccheri Feb 21, 2021
29a0052
Started making init and finalise work for both f08 and f90 mpi bindin…
AlexBuccheri Feb 21, 2021
172a5df
Added important TODO that indicates how to clean things up
AlexBuccheri Feb 21, 2021
6139c9d
Really fleshed out wrapped get_comm and duplicate_comm routines. Beha…
AlexBuccheri Feb 22, 2021
568ac25
Complete overhaul of routines to use setters and getters, and to hide…
AlexBuccheri Feb 27, 2021
dc655ba
Cleaned up docs. Not tested build
AlexBuccheri Feb 27, 2021
6af5ffb
Remove non-existent file from src/CMakeLists.txt
Mar 10, 2021
a7d1cba
Add CMake arguments to README for testing (Zofu) and documentation
Mar 10, 2021
a2b6b51
Added files missing from version control
AlexBuccheri Mar 11, 2021
44142a8
Merge branch 'fix_proposed_structure' of https://github.com/AlexBucch…
AlexBuccheri Mar 11, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,25 @@
#.gitignore for MPILib20

# Basic patterns
# ----------------------------------------------------------
# Entry Ignores
# ----------------------------------------------------------
# target/ folder named target (due to the trailing /) recursively
# target file or folder named target recursively
# /target file or folder named target in the top-most directory (due to the leading /)
# /target/ folder named target in the top-most directory (leading and trailing /)
# *.class every file or folder ending with .class recursively

# Mac custom attributes file
.DS_Store
.DS_Store

# IntelliJ
.idea/
cmake-build-*/

# VS Code
/.vscode
/build

# Documentation is generated by the build system
/documentation
135 changes: 98 additions & 37 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
cmake_minimum_required(VERSION 3.13)

project(mpilib20 VERSION 0.1.0
DESCRIPTION "Modern API and bindings for MPI"
LANGUAGES Fortran)
DESCRIPTION "Modern API and bindings for MPI. A Buccheri and M Williams"
LANGUAGES Fortran)

set(PROJECT_URL "https://github.com/AlexBuccheri/mpilib20")

# Name of library
set(TARGET mpilib20)

# CMake module directory
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})

# Defines build type
Expand All @@ -20,65 +18,128 @@ include(cmake/CompilerFlags.cmake)
# Compiler warnings
include(cmake/CompilerWarnings.cmake)

# Find MPI. Assigned to LIBS
# --------------------------
# External dependencies
# --------------------------
set(LIBS "")

# Find MPI
include(cmake/mpi.cmake)

# TODO(Alex)
# Add Doxygen and Ford support
# Add Ctest support
# Add unit testing support
# Create pkg-config
# TODO Add Find openMP implementation in omp.cmake
include(cmake/omp.cmake)

# Python 3, required for generating Zofu test drivers
# We may not use that though
include(cmake/python3.cmake)

# Zofu unit testing framework
include(cmake/FindZofu.cmake)

# Ford or doxygen documentation parsers
include(cmake/Documentation.cmake)

# --------------------------
# Library build
# --------------------------
# Set output folders for exe, libs and modules
set(CMAKE_Fortran_MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/modules)
set(CMAKE_Fortran_BIN_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
set(CMAKE_Fortran_MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/modules)
set(CMAKE_Fortran_LIB_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
set(default_install_prefix "${PROJECT_BINARY_DIR}/mpilib20_library")


# Create static and shared libraries
add_subdirectory(src)
add_library(${TARGET} SHARED ${SOURCE_CODE})
add_library(${TARGET}-static STATIC ${SOURCE_CODE})

# TODO(Alex) Make VERSION and SOVERSION variables
set_target_properties(${TARGET}
# Shared library
add_library(mpilib20 SHARED ${SOURCE_CODE})
set_target_properties(mpilib20
PROPERTIES
VERSION 1 SOVERSION 0
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_Fortran_LIB_DIRECTORY})
target_link_libraries(${TARGET} ${LIBS})
VERSION 1 SOVERSION 0
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_Fortran_LIB_DIRECTORY})
target_link_libraries(mpilib20 ${LIBS})

# Optional static library
option(BUILD_STATIC "Build static version of the library" OFF)

if(BUILD_STATIC)
add_library(mpilib20-static STATIC ${SOURCE_CODE})
set_target_properties(mpilib20-static
PROPERTIES
VERSION 1
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_Fortran_LIB_DIRECTORY})
target_link_libraries(mpilib20-static ${LIBS})
endif()

set_target_properties(${TARGET}-static
PROPERTIES
VERSION 1
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_Fortran_LIB_DIRECTORY})
target_link_libraries(${TARGET}-static ${LIBS})
# TODO(Alex)
# Set fortran preprocessor variables specific to the library target.
# This should just be done explicitly here so there's no question of doing it
# before the target exists
# Should also considrer if the library build commands should be put into a module
# - question of how modular CMake should be
include(cmake/PreprocessorSettings.cmake)

#TODO
if(NOT MPI08)
message(FATAL_ERROR "Library will not run with MPI08=off because getters and setters need to be used in the existing routines")
endif()

# --------------------------
# Library installation
# --------------------------
set(default_install_prefix ${PROJECT_BINARY_DIR}/mpilib20_library)

# Install libraries and modules
# Not sure when this is required: include(GNUInstallDirs)

if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX ${default_install_prefix} CACHE STRING
"Choose the installation directory; by default it installs in ${default_install_prefix}."
FORCE)
endif()

# No need to specify "${CMAKE_INSTALL_PREFIX}/lib",
# install() will concatenate CMAKE_INSTALL_PREFIX and lib
install(TARGETS ${TARGET} ${TARGET}-static
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
# ${CMAKE_INSTALL_PREFIX} is implict in install DESTINATION lib
install(TARGETS mpilib20 LIBRARY DESTINATION lib)

if(BUILD_STATIC)
install(TARGETS mpilib20-static ARCHIVE DESTINATION lib)
endif()

# If one specifies "${CMAKE_INSTALL_PREFIX}/include" instead of include
# the module install directory will erroneously be CMAKE_INSTALL_PREFIX/include/modules
# No need to use GLOB
# Module installation location
install(DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}
DESTINATION include)

# TODO(Alex)
# Create pkg-config

# --------------------------
# Unit tests
# --------------------------

# TODO(Alex) should only build tests if zofu is found OR unit tests are enabled

#TODO(Alex) How does one use ctest with MPI applications?
# add test needs arguments: https://stackoverflow.com/questions/19278510/cmake-ctest-add-test-command-appends-extra-quotes-to-my-command-parameters

# TODO(Alex) Investigate this
# https://cmake.org/cmake/help/latest/command/ctest_test.html#command:ctest_test

#TODO(Alex) This should get reverted to the module approach
# Have 1 test driver per module (so no need to use my python script)
# Have set-up and tear down to call our mpi_env%init and finalize
# Note, Zofu will need extending at some point to optionally accept a communicator
# i.e. test%init(communicator)

enable_testing()

# Functions for generating unit test executables
include(cmake/unit_test_functions.cmake)

# Create a directory in the build folder to place generated test drivers
set(TEST_DRIVER_DIR ${PROJECT_BINARY_DIR}/test_drivers)
file(MAKE_DIRECTORY ${TEST_DRIVER_DIR})

# A list containing all module tests.
set(unit_tests "test_init.f90")

foreach(test_module ${unit_tests})
create_unit_test_executable_per_module(ENABLE_MPI SUBDIR src/tests UNIT_TEST ${test_module})
endforeach()


Loading