diff --git a/CHANGELOG.md b/CHANGELOG.md index da9cd5a0..5409e870 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Deprecated +## [3.41.0] - 2024-02-20 + +### Fixed + +- Quoted generator expression arguments (see #308) + +### Added + +- Added new `DetermineMPIStack.cmake` file that will detect the MPI Stack being used + - The allowed stacks are `openmpi`, `mpich`, `intel`, `mvapich`, `mpt` which will + be set in the `MPI_STACK` variable + - Can be overridden by setting `MPI_STACK` to one of the allowed values via `-DMPI_STACK=...` + - Will also set `MPI_STACK_VERSION` to the version of the stack being used + - NOTE: This is the version of the *stack* not the version of MPI supported by the stack + ## [3.40.0] - 2024-02-06 ### Changed diff --git a/esma.cmake b/esma.cmake index 6debfc16..e4da9570 100644 --- a/esma.cmake +++ b/esma.cmake @@ -62,6 +62,7 @@ include(math_libraries) include(FindBaselibs) include(DetermineSite) find_package(GitInfo) +include(DetermineMPIStack) ### ESMA Support ### diff --git a/esma_support/esma_fortran_generator_list.cmake b/esma_support/esma_fortran_generator_list.cmake index 24744ecd..20b095e1 100644 --- a/esma_support/esma_fortran_generator_list.cmake +++ b/esma_support/esma_fortran_generator_list.cmake @@ -3,6 +3,6 @@ macro (esma_fortran_generator_list target multioption) string (REPLACE " " ";" flags ${multioption}) foreach(item ${flags}) - target_compile_options (${target} PRIVATE $<$:${item}>) + target_compile_options (${target} PRIVATE "$<$:${item}>") endforeach () endmacro () diff --git a/external_libraries/DetermineMPIStack.cmake b/external_libraries/DetermineMPIStack.cmake new file mode 100644 index 00000000..e9ab0f00 --- /dev/null +++ b/external_libraries/DetermineMPIStack.cmake @@ -0,0 +1,60 @@ +# This code will try and determine the MPI stack being used and set the MPI_STACK variable + +include(CMakePrintHelpers) + +set(ALLOWED_MPI_STACKS "intelmpi;mvapich;mpt;mpich;openmpi") + +if (MPI_STACK) + if (NOT MPI_STACK IN_LIST ALLOWED_MPI_STACKS) + message(FATAL_ERROR "MPI_STACK must be one of the following: ${ALLOWED_MPI_STACKS}") + else() + set(MPI_STACK_TYPE "User Specified") + message(WARNING "MPI_STACK is user specified. Please ensure that the specified MPI stack is compatible with the build. NOTE: MPI_STACK_VERSION is not being set.") + endif() +else () + message(STATUS "MPI_STACK not specified. Attempting to autodetect MPI stack...") + message(DEBUG "MPI_Fortran_LIBRARY_VERSION_STRING: ${MPI_Fortran_LIBRARY_VERSION_STRING}") + + string(REPLACE " " ";" MPI_Fortran_LIBRARY_VERSION_LIST ${MPI_Fortran_LIBRARY_VERSION_STRING}) + message(DEBUG "MPI_Fortran_LIBRARY_VERSION_LIST: ${MPI_Fortran_LIBRARY_VERSION_LIST}") + list(GET MPI_Fortran_LIBRARY_VERSION_LIST 0 MPI_Fortran_LIBRARY_VERSION_FIRSTWORD) + message(DEBUG "MPI_Fortran_LIBRARY_VERSION_FIRSTWORD: ${MPI_Fortran_LIBRARY_VERSION_FIRSTWORD}") + + if(MPI_Fortran_LIBRARY_VERSION_STRING MATCHES "Intel") + set(MPI_STACK intelmpi) + list(GET MPI_Fortran_LIBRARY_VERSION_LIST 3 MPI_STACK_VERSION) + elseif(MPI_Fortran_LIBRARY_VERSION_STRING MATCHES "MVAPICH") + set(MPI_STACK mvapich) + # MVAPICH output for MPI_Fortran_LIBRARY_VERSION_STRING is complex and multi-line. + # So we need to extract the first line from that multi-line string. + string(REGEX REPLACE "\n.*" "" MPI_Fortran_LIBRARY_VERSION_STRING_FIRST_LINE ${MPI_Fortran_LIBRARY_VERSION_STRING}) + # Now we need to grab the last word from the first line of the string + string(REGEX MATCH "[^ ]+$" MPI_STACK_VERSION ${MPI_Fortran_LIBRARY_VERSION_STRING_FIRST_LINE}) + # Now we need to remove any colons, spaces, tabs, etc., but keep dots and letters. + string(REGEX REPLACE "[^a-zA-Z0-9.]" "" MPI_STACK_VERSION ${MPI_STACK_VERSION}) + elseif(MPI_Fortran_LIBRARY_VERSION_STRING MATCHES "MPT") + set(MPI_STACK mpt) + list(GET MPI_Fortran_LIBRARY_VERSION_LIST 2 MPI_STACK_VERSION) + elseif(MPI_Fortran_LIBRARY_VERSION_STRING MATCHES "MPICH") + set(MPI_STACK mpich) + # MPICH output for MPI_Fortran_LIBRARY_VERSION_STRING is complex and multi-line. + # So we need to extract the first line from that multi-line string. + string(REGEX REPLACE "\n.*" "" MPI_Fortran_LIBRARY_VERSION_STRING_FIRST_LINE ${MPI_Fortran_LIBRARY_VERSION_STRING}) + # Now we need to grab the last word from the first line of the string + string(REGEX MATCH "[^ ]+$" MPI_STACK_VERSION ${MPI_Fortran_LIBRARY_VERSION_STRING_FIRST_LINE}) + # Now we need to remove any colons, spaces, tabs, etc., but keep dots and letters. + string(REGEX REPLACE "[^a-zA-Z0-9.]" "" MPI_STACK_VERSION ${MPI_STACK_VERSION}) + elseif(MPI_Fortran_LIBRARY_VERSION_STRING MATCHES "Open MPI") + set(MPI_STACK openmpi) + list(GET MPI_Fortran_LIBRARY_VERSION_LIST 2 DETECTED_MPI_STACK_VERSION_STRING_WITH_COMMA) + string(REPLACE "," "" DETECTED_MPI_STACK_VERSION_STRING_WITH_V ${DETECTED_MPI_STACK_VERSION_STRING_WITH_COMMA}) + string(REPLACE "v" "" MPI_STACK_VERSION ${DETECTED_MPI_STACK_VERSION_STRING_WITH_V}) + else() + message (FATAL_ERROR "ERROR: MPI_STACK autodetection failed. Must specify a value for MPI_STACK with cmake ... -DMPI_STACK=. The acceptable values are: intelmpi, mvapich, mpt, mpich, openmpi") + endif() + set(MPI_STACK_TYPE "Autodetected") +endif() + +set(MPI_STACK "${MPI_STACK}" CACHE STRING "MPI_STACK Value") +set(MPI_STACK_VERSION "${MPI_STACK_VERSION}" CACHE STRING "MPI_STACK_VERSION Value") +message(STATUS "Using ${MPI_STACK_TYPE} MPI_STACK: ${MPI_STACK}. Version: ${MPI_STACK_VERSION}")