From: M. Eric Irrgang Date: Wed, 30 Sep 2020 20:29:24 +0000 (+0300) Subject: Let gmxapi installation record the GROMACS library MPI configuration. X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=commitdiff_plain;h=8d0a136ca580a330683d5376185c89c643f62454;p=alexxy%2Fgromacs.git Let gmxapi installation record the GROMACS library MPI configuration. Add a `MPI` property to the Gromacs::gmxapi CMake target. Add "gmx_mpi_type" to gmxconfig.json Refs #2961 --- diff --git a/api/gmxapi/CMakeLists.txt b/api/gmxapi/CMakeLists.txt index fa145fceef..a72b7f8996 100644 --- a/api/gmxapi/CMakeLists.txt +++ b/api/gmxapi/CMakeLists.txt @@ -61,6 +61,26 @@ set_target_properties(gmxapi PROPERTIES VERSION_PATCH ${GMXAPI_PATCH} RELEASE ${GMXAPI_RELEASE}) + +if (GMX_LIB_MPI) + # GROMACS is built against an MPI library. + # Clarification should be possible with resolution of #3672. + set(_gmx_mpi_type "library") +elseif(GMX_THREAD_MPI) + # GROMACS is built with its internal thread-MPI implementation. + set(_gmx_mpi_type "tmpi") +else() + # GROMACS is built without MPI or thread-MPI. + set(_gmx_mpi_type "none") +endif () +define_property(TARGET PROPERTY MPI + BRIEF_DOCS "MPI capability of the GROMACS library." + FULL_DOCS "Values of 'library', 'tmpi', or 'none' indicate the configure-time options of the GROMACS + library build.") +set_target_properties(gmxapi PROPERTIES + MPI ${_gmx_mpi_type}) +unset(_gmx_mpi_type) + ########################## # Define public interface. # diff --git a/api/gmxapi/cpp/CMakeLists.txt b/api/gmxapi/cpp/CMakeLists.txt index 8c6fc2992d..52d88c54dc 100644 --- a/api/gmxapi/cpp/CMakeLists.txt +++ b/api/gmxapi/cpp/CMakeLists.txt @@ -110,11 +110,13 @@ add_library(Gromacs::gmxapi ALIAS gmxapi ) include(CMakePackageConfigHelpers) +get_target_property(_mpi Gromacs::gmxapi MPI) configure_package_config_file( cmake/gmxapi-config.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/cmake/gmxapi-config.cmake" INSTALL_DESTINATION share/cmake/gmxapi/ ) +unset(_mpi) get_target_property(GMXAPI_RELEASE gmxapi RELEASE) write_basic_package_version_file( ${CMAKE_CURRENT_BINARY_DIR}/cmake/gmxapi-config-version.cmake diff --git a/api/gmxapi/cpp/cmake/gmxapi-config.cmake.in b/api/gmxapi/cpp/cmake/gmxapi-config.cmake.in index cf4e0f9e28..fcb7de77e1 100644 --- a/api/gmxapi/cpp/cmake/gmxapi-config.cmake.in +++ b/api/gmxapi/cpp/cmake/gmxapi-config.cmake.in @@ -4,3 +4,4 @@ set(gmxapi_VERSION @GMXAPI_RELEASE@) # https://cmake.org/cmake/help/v3.4/module/CMakePackageConfigHelpers.html#command:configure_package_config_file include("${CMAKE_CURRENT_LIST_DIR}/gmxapi.cmake") check_required_components(gmxapi) +set_property(TARGET Gromacs::gmxapi PROPERTY MPI "@_mpi@") diff --git a/python_packaging/src/CMakeLists.txt b/python_packaging/src/CMakeLists.txt index f94434d9bb..fb9dbd2f21 100644 --- a/python_packaging/src/CMakeLists.txt +++ b/python_packaging/src/CMakeLists.txt @@ -152,6 +152,22 @@ if(GMXAPI_MASTER_PROJECT) HINTS "$ENV{GROMACS_DIR}" ) endif() + +# Get details of GROMACS installation needed by the Python package at run time. + +# Get the MPI capability. +get_target_property(_gmx_mpi Gromacs::gmxapi MPI) +if (${_gmx_mpi} STREQUAL "library") + set(_gmx_mpi_type "\"library\"") +elseif(${_gmx_mpi} STREQUAL "tmpi") + set(_gmx_mpi_type "\"tmpi\"") +elseif(${_gmx_mpi} STREQUAL "none") + set(_gmx_mpi_type "null") +else() + message(FATAL_ERROR "Unrecognized gmxapi MPI value: ${_gmx_mpi}") +endif () +unset(_gmx_mpi) +# Get the path of the command line entry point and binary install directory. if (NOT TARGET Gromacs::gmx) message(FATAL_ERROR "GROMACS command line tool not found.") endif () @@ -173,6 +189,7 @@ endif () configure_file(gmxapi/gmxconfig.json.in ${GMXAPI_PYTHON_STAGING_DIR}/gmxapi/gmxconfig.json) unset(_gmx_executable) unset(_gmx_bindir) +unset(_gmx_mpi_type) # scikit-build sets SKBUILD when running Python packaging tools through setup.py # (e.g. with pip) diff --git a/python_packaging/src/gmxapi/gmxconfig.json.in b/python_packaging/src/gmxapi/gmxconfig.json.in index 0925cf33aa..e56f0de11f 100644 --- a/python_packaging/src/gmxapi/gmxconfig.json.in +++ b/python_packaging/src/gmxapi/gmxconfig.json.in @@ -1,4 +1,5 @@ { "gmx_executable": "@_gmx_executable@", - "gmx_bindir": "@_gmx_bindir@" + "gmx_bindir": "@_gmx_bindir@", + "gmx_mpi_type": @_gmx_mpi_type@ }