From 8c1b77e48f2984f7a11434959e37d08514521595 Mon Sep 17 00:00:00 2001
From: Christoph Junghans <junghans@votca.org>
Date: Sun, 9 Sep 2018 07:04:09 -0600
Subject: [PATCH] cmake: workaround for cmake bug#18349

---
 CMakeLists.txt | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8f384f423b..f84095b5f4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -286,7 +286,10 @@ endif(WITH_VALGRIND_INSTRUMENTATION)
 #######################################################################
 
 find_package(MPI REQUIRED)
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MPI_COMPILE_FLAGS}")
+# Workaround for https://gitlab.kitware.com/cmake/cmake/issues/18349
+foreach(_MPI_FLAG ${MPI_COMPILE_FLAGS})
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_MPI_FLAG}")
+endforeach()
 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${MPI_LINK_FLAGS}")
 include_directories(SYSTEM ${MPI_INCLUDE_PATH})
 list(APPEND LIBRARIES ${MPI_LIBRARIES})
