Let gmxapi installation record the GROMACS library MPI configuration.
authorM. Eric Irrgang <ericirrgang@gmail.com>
Wed, 30 Sep 2020 20:29:24 +0000 (23:29 +0300)
committerPaul Bauer <paul.bauer.q@gmail.com>
Fri, 2 Oct 2020 13:17:55 +0000 (13:17 +0000)
Add a `MPI` property to the Gromacs::gmxapi CMake target.

Add "gmx_mpi_type" to gmxconfig.json

Refs #2961

api/gmxapi/CMakeLists.txt
api/gmxapi/cpp/CMakeLists.txt
api/gmxapi/cpp/cmake/gmxapi-config.cmake.in
python_packaging/src/CMakeLists.txt
python_packaging/src/gmxapi/gmxconfig.json.in

index fa145fceef4e821874c60e2ba294e24ab4198557..a72b7f89965dbfb075115cbcad0e7fae147998be 100644 (file)
@@ -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.
 #
index 8c6fc2992d19d703ec1eb87848d9fbba589ca0ec..52d88c54dce11188c1ce70191028b440be493085 100644 (file)
@@ -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
index cf4e0f9e2852b662a73acfd12c11c86335f64628..fcb7de77e103d4ca06183f2ba758d71aae34fd70 100644 (file)
@@ -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@")
index f94434d9bb5ea531bd007e3bc0379e006e4e13c8..fb9dbd2f215649befc11b1ab0f0203502e5ae3cd 100644 (file)
@@ -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)
index 0925cf33aa27c39714e676a2a9dbb5969cf9d97e..e56f0de11fd46d77e9b4ed142b629d0cb7e9dc7f 100644 (file)
@@ -1,4 +1,5 @@
 {
     "gmx_executable": "@_gmx_executable@",
-    "gmx_bindir": "@_gmx_bindir@"
+    "gmx_bindir": "@_gmx_bindir@",
+    "gmx_mpi_type": @_gmx_mpi_type@
 }