From aed127dc6a8c6356f785ad2791854fb817b52299 Mon Sep 17 00:00:00 2001
From: Ben Boeckel <ben.boeckel@kitware.com>
Date: Wed, 27 Dec 2017 12:00:16 -0500
Subject: [PATCH] diy2: update to the new module system

This also updates the inclusion macro. Warnings that are suppressed
currently should just be fixed upstream instead.
---
 .../Testing/Cxx/TestPResampleToImage.cxx      |  4 +-
 .../TestPResampleToImageCompositeDataSet.cxx  |  4 +-
 Filters/ParallelDIY2/vtkPResampleToImage.cxx  | 16 +++---
 .../ParallelDIY2/vtkPResampleWithDataSet.cxx  | 10 ++--
 ThirdParty/diy2/CMakeLists.txt                | 19 ++++---
 ThirdParty/diy2/module.cmake                  |  7 ---
 ThirdParty/diy2/update.sh                     |  2 +-
 ThirdParty/diy2/vtk.module                    |  5 ++
 ThirdParty/diy2/vtk_diy2.h.in                 | 56 ++-----------------
 9 files changed, 37 insertions(+), 86 deletions(-)
 delete mode 100644 ThirdParty/diy2/module.cmake
 create mode 100644 ThirdParty/diy2/vtk.module

diff --git a/Filters/ParallelDIY2/Testing/Cxx/TestPResampleToImage.cxx b/Filters/ParallelDIY2/Testing/Cxx/TestPResampleToImage.cxx
index 28b0a425e77..5ecf68eef9d 100644
--- a/Filters/ParallelDIY2/Testing/Cxx/TestPResampleToImage.cxx
+++ b/Filters/ParallelDIY2/Testing/Cxx/TestPResampleToImage.cxx
@@ -33,9 +33,7 @@
 #include "vtkSmartPointer.h"
 
 #include "vtk_diy2.h"   // must include this before any diy header
-VTKDIY2_PRE_INCLUDE
-#include VTK_DIY2_HEADER(diy/mpi.hpp)
-VTKDIY2_POST_INCLUDE
+#include VTK_DIY2(diy/mpi.hpp)
 
 
 int TestPResampleToImage(int argc, char *argv[])
diff --git a/Filters/ParallelDIY2/Testing/Cxx/TestPResampleToImageCompositeDataSet.cxx b/Filters/ParallelDIY2/Testing/Cxx/TestPResampleToImageCompositeDataSet.cxx
index 69295d61e06..94cf69c0bac 100644
--- a/Filters/ParallelDIY2/Testing/Cxx/TestPResampleToImageCompositeDataSet.cxx
+++ b/Filters/ParallelDIY2/Testing/Cxx/TestPResampleToImageCompositeDataSet.cxx
@@ -35,9 +35,7 @@
 #include "vtkSmartPointer.h"
 
 #include "vtk_diy2.h"   // must include this before any diy header
-VTKDIY2_PRE_INCLUDE
-#include VTK_DIY2_HEADER(diy/mpi.hpp)
-VTKDIY2_POST_INCLUDE
+#include VTK_DIY2(diy/mpi.hpp)
 
 
 int TestPResampleToImageCompositeDataSet(int argc, char *argv[])
diff --git a/Filters/ParallelDIY2/vtkPResampleToImage.cxx b/Filters/ParallelDIY2/vtkPResampleToImage.cxx
index 8c651366e26..8f6ca27b00f 100644
--- a/Filters/ParallelDIY2/vtkPResampleToImage.cxx
+++ b/Filters/ParallelDIY2/vtkPResampleToImage.cxx
@@ -35,15 +35,13 @@
 #include "vtkUnsignedCharArray.h"
 
 #include "vtk_diy2.h"   // must include this before any diy header
-VTKDIY2_PRE_INCLUDE
-#include VTK_DIY2_HEADER(diy/assigner.hpp)
-#include VTK_DIY2_HEADER(diy/link.hpp)
-#include VTK_DIY2_HEADER(diy/master.hpp)
-#include VTK_DIY2_HEADER(diy/mpi.hpp)
-#include VTK_DIY2_HEADER(diy/reduce.hpp)
-#include VTK_DIY2_HEADER(diy/partners/swap.hpp)
-#include VTK_DIY2_HEADER(diy/decomposition.hpp)
-VTKDIY2_POST_INCLUDE
+#include VTK_DIY2(diy/assigner.hpp)
+#include VTK_DIY2(diy/link.hpp)
+#include VTK_DIY2(diy/master.hpp)
+#include VTK_DIY2(diy/mpi.hpp)
+#include VTK_DIY2(diy/reduce.hpp)
+#include VTK_DIY2(diy/partners/swap.hpp)
+#include VTK_DIY2(diy/decomposition.hpp)
 
 #include <algorithm>
 
diff --git a/Filters/ParallelDIY2/vtkPResampleWithDataSet.cxx b/Filters/ParallelDIY2/vtkPResampleWithDataSet.cxx
index 065306d8267..bb05e8b271a 100644
--- a/Filters/ParallelDIY2/vtkPResampleWithDataSet.cxx
+++ b/Filters/ParallelDIY2/vtkPResampleWithDataSet.cxx
@@ -38,12 +38,10 @@
 #include "vtkUnstructuredGrid.h"
 
 #include "vtk_diy2.h"   // must include this before any diy header
-VTKDIY2_PRE_INCLUDE
-#include VTK_DIY2_HEADER(diy/assigner.hpp)
-#include VTK_DIY2_HEADER(diy/link.hpp)
-#include VTK_DIY2_HEADER(diy/master.hpp)
-#include VTK_DIY2_HEADER(diy/mpi.hpp)
-VTKDIY2_POST_INCLUDE
+#include VTK_DIY2(diy/assigner.hpp)
+#include VTK_DIY2(diy/link.hpp)
+#include VTK_DIY2(diy/master.hpp)
+#include VTK_DIY2(diy/mpi.hpp)
 
 #include <algorithm>
 #include <cmath>
diff --git a/ThirdParty/diy2/CMakeLists.txt b/ThirdParty/diy2/CMakeLists.txt
index 98d6fa32006..c89fff87d62 100644
--- a/ThirdParty/diy2/CMakeLists.txt
+++ b/ThirdParty/diy2/CMakeLists.txt
@@ -1,7 +1,12 @@
-# Diy2 does not work on windows
-if (NOT WIN32)
-  vtk_module_third_party(diy2
-    INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/vtkdiy2/include"
-    NO_LIBRARIES
-    )
-endif()
+vtk_module_third_party_internal(
+  HEADER_ONLY
+  LICENSE_FILES "vtkdiy2/LICENSE.txt"
+                "vtkdiy2/LEGAL.txt"
+  VERSION       "3.5.0")
+
+configure_file(
+  "${CMAKE_CURRENT_SOURCE_DIR}/vtk_diy2.h.in"
+  "${CMAKE_CURRENT_BINARY_DIR}/vtk_diy2.h")
+
+vtk_module_install_headers(
+  FILES "${CMAKE_CURRENT_BINARY_DIR}/vtk_diy2.h")
diff --git a/ThirdParty/diy2/module.cmake b/ThirdParty/diy2/module.cmake
deleted file mode 100644
index fad1c9d22e3..00000000000
--- a/ThirdParty/diy2/module.cmake
+++ /dev/null
@@ -1,7 +0,0 @@
-if (NOT WIN32)
-  vtk_module(vtkdiy2
-    GROUPS
-      MPI
-    EXCLUDE_FROM_WRAPPING
-  )
-endif()
\ No newline at end of file
diff --git a/ThirdParty/diy2/update.sh b/ThirdParty/diy2/update.sh
index fa5907ba78b..ddbadd02eb9 100755
--- a/ThirdParty/diy2/update.sh
+++ b/ThirdParty/diy2/update.sh
@@ -8,7 +8,7 @@ readonly name="diy2"
 readonly ownership="Diy2 Upstream <kwrobot@kitware.com>"
 readonly subtree="ThirdParty/$name/vtk$name"
 readonly repo="https://gitlab.kitware.com/third-party/diy2.git"
-readonly tag="for/vtk-20180924-g3298ccb3"
+readonly tag="for/vtk-20181008-3.5.0"
 readonly paths="
 .gitattributes
 CMakeLists.vtk.txt
diff --git a/ThirdParty/diy2/vtk.module b/ThirdParty/diy2/vtk.module
new file mode 100644
index 00000000000..f2a49f4c5ca
--- /dev/null
+++ b/ThirdParty/diy2/vtk.module
@@ -0,0 +1,5 @@
+NAME
+  VTK::diy2
+LIBRARY_NAME
+  vtkdiy2
+THIRD_PARTY
diff --git a/ThirdParty/diy2/vtk_diy2.h.in b/ThirdParty/diy2/vtk_diy2.h.in
index 8ae0c7b5902..e947386dc55 100644
--- a/ThirdParty/diy2/vtk_diy2.h.in
+++ b/ThirdParty/diy2/vtk_diy2.h.in
@@ -12,61 +12,17 @@
      PURPOSE.  See the above copyright notice for more information.
 
 =========================================================================*/
-// .NAME vtk_diy2
-// .SECTION Description
-
 #ifndef vtk_diy2_h
 #define vtk_diy2_h
 
-#cmakedefine VTK_USE_SYSTEM_DIY2
-
-#define VTK_DIY2_QUOTE_HEADER_NAME(str) #str
+/* Use the diy2 library configured for VTK.  */
+#cmakedefine01 VTK_MODULE_USE_EXTERNAL_vtkdiy2
 
-
-#ifndef VTK_USE_SYSTEM_DIY2
-#  define VTK_DIY2_HEADER(header) VTK_DIY2_QUOTE_HEADER_NAME(header)
-#  define diy vtkdiy2 // mangle namespace diy
+#if VTK_MODULE_USE_EXTERNAL_vtkdiy2
+#  define VTK_DIY2(header) <header>
 #else
-#  define VTK_DIY2_HEADER(header) #header
-#endif
-
-// disable warnings
-#if defined(_MSC_VER)
-
-#  define VTKDIY2_WARNING_PRAGMAS
-
-#  define VTKDIY2_WARNINGS_PUSH __pragma(warning(push))
-#  define VTKDIY2_WARNINGS_POP  __pragma(warning(pop))
-
-#elif defined(__GNUC__) && !defined(__INTEL_COMPILER) && !defined(__PGI) // for GCC and Clang only
-
-// Older versions of GCC don't support the push/pop pragmas and some dont
-// recognize the suppressed warnings
-#  if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
-#    define VTKDIY2_WARNING_PRAGMAS \
-       _Pragma("GCC diagnostic ignored \"-Wshadow\"") \
-       _Pragma("GCC diagnostic ignored \"-Wunused-parameter\"") \
-       _Pragma("GCC diagnostic ignored \"-Wunused-result\"")
-
-#    define VTKDIY2_WARNINGS_PUSH _Pragma("GCC diagnostic push")
-#    define VTKDIY2_WARNINGS_POP  _Pragma("GCC diagnostic pop")
-#  else // Older GCC / Clang
-#    define VTKDIY2_WARNING_PRAGMAS
-#    define VTKDIY2_WARNINGS_PUSH
-#    define VTKDIY2_WARNINGS_POP
-#  endif
-
-#else // all other compilers
-#  define VTKDIY2_WARNING_PRAGMAS
-#  define VTKDIY2_WARNINGS_PUSH
-#  define VTKDIY2_WARNINGS_POP
+#  define VTK_DIY2(header) <vtkdiy2/include/header>
+#  define diy vtkdiy2 // mangle namespace diy
 #endif
 
-#define VTKDIY2_PRE_INCLUDE \
-   VTKDIY2_WARNINGS_PUSH \
-   VTKDIY2_WARNING_PRAGMAS
-
-#define VTKDIY2_POST_INCLUDE \
-   VTKDIY2_WARNINGS_POP
-
 #endif
-- 
GitLab