workaround for rhel bug #1749463, cmake bug #18349
authorChristoph Junghans <junghans@votca.org>
Thu, 19 Sep 2019 22:54:41 +0000 (16:54 -0600)
committerMark Abraham <mark.j.abraham@gmail.com>
Sun, 22 Sep 2019 21:55:02 +0000 (23:55 +0200)
MPI_C_COMPILE_FLAGS is a list instead of a string
see: https://gitlab.kitware.com/cmake/cmake/issues/18349
We mainly want to workaround this issue as RHEL 8 triggers it:
https://bugzilla.redhat.com/show_bug.cgi?id=1749463

This issue is fixed in cmake-3.12.3

Change-Id: I14c1c0a4f33f26b128d55baa1b0455f8a463a999

cmake/gmxManageMPI.cmake

index 02db55732d049d95d626ffc6700d524eee7ba7f5..cc58daeafb4e5029e0926cb12f838aa8c8cd8194 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2012,2013,2014,2015,2016, by the GROMACS development team, led by
+# Copyright (c) 2012,2013,2014,2015,2016,2019, by the GROMACS development team, led by
 # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
 # and including many others, as listed in the AUTHORS file in the
 # top-level source directory and at http://www.gromacs.org.
@@ -50,10 +50,22 @@ if(GMX_MPI)
   if(NOT MPI_FOUND)
       find_package(MPI)
       if(MPI_C_FOUND)
-        set(MPI_COMPILE_FLAGS ${MPI_C_COMPILE_FLAGS})
-        set(MPI_LINKER_FLAGS ${MPI_C_LINK_FLAGS})
-        include_directories(SYSTEM ${MPI_C_INCLUDE_PATH})
-        list(APPEND GMX_COMMON_LIBRARIES ${MPI_C_LIBRARIES})
+          # workaround for rhel bug #1749463, cmake bug #18349, fixed in cmake-3.12.3
+          if(CMAKE_VERSION VERSION_LESS "3.12.3")
+              set(MPI_COMPILE_FLAGS)
+              foreach(_MPI_FLAG ${MPI_C_COMPILE_FLAGS})
+                  set(MPI_COMPILE_FLAGS "${MPI_COMPILE_FLAGS} ${_MPI_FLAG}")
+              endforeach()
+              set(MPI_LINKER_FLAGS)
+              foreach(_MPI_FLAG ${MPI_C_LINK_FLAGS})
+                  set(MPI_LINKER_FLAGS "${MPI_LINKER_FLAGS} ${_MPI_FLAG}")
+              endforeach()
+          else()
+              set(MPI_COMPILE_FLAGS ${MPI_C_COMPILE_FLAGS})
+              set(MPI_LINKER_FLAGS ${MPI_C_LINK_FLAGS})
+          endif()
+          include_directories(SYSTEM ${MPI_C_INCLUDE_PATH})
+          list(APPEND GMX_COMMON_LIBRARIES ${MPI_C_LIBRARIES})
       endif()
       set(MPI_FOUND ${MPI_C_FOUND})
   else()