From d0bcebdc02ec53812d95018f22bbc6f71a89ce86 Mon Sep 17 00:00:00 2001
From: Chuck Atkins <chuck.atkins@kitware.com>
Date: Wed, 19 Apr 2017 13:09:16 -0400
Subject: [PATCH] Use ADIOSConfig.h header instead of -D flags

---
 CMakeLists.txt                              |  3 +
 cmake/GenerateADIOSConfig.cmake             | 66 +++++++++++++++++++++
 source/ADIOS.cpp                            | 14 ++---
 source/ADIOS.h                              |  7 ++-
 source/ADIOSTypes.h                         |  2 +
 source/ADIOS_MPI.h                          |  6 +-
 source/CMakeLists.txt                       | 11 ++--
 source/adios2.h.in                          |  1 +
 source/capsule/heap/STLVector.h             |  1 +
 source/capsule/shmem/ShmSystemV.h           |  1 +
 source/core/Attribute.h                     |  2 +
 source/core/Capsule.h                       |  2 +
 source/core/Engine.h                        | 20 +++----
 source/core/IOChrono.h                      |  3 +-
 source/core/Method.h                        |  5 +-
 source/core/Selection.h                     |  2 +
 source/core/SelectionBoundingBox.h          |  3 +-
 source/core/SelectionPoints.h               |  3 +-
 source/core/Support.h                       |  2 +
 source/core/Timer.h                         |  3 +-
 source/core/Transform.h                     |  2 +
 source/core/Transport.h                     |  5 +-
 source/core/Variable.h                      |  5 +-
 source/core/VariableBase.h                  |  7 ++-
 source/core/VariableCompound.h              |  3 +-
 source/core/adiosFunctions.cpp              |  4 +-
 source/core/adiosFunctions.h                |  5 +-
 source/core/adiosTemplates.h                |  2 +
 source/core/capsuleTemplates.h              |  3 +-
 source/engine/adios1/ADIOS1Reader.h         |  9 +--
 source/engine/adios1/ADIOS1Writer.h         |  1 +
 source/engine/bp/BPFileReader.h             |  2 +-
 source/engine/bp/BPFileWriter.h             |  2 +-
 source/engine/dataman/DataManReader.h       |  3 +-
 source/engine/dataman/DataManWriter.h       |  3 +-
 source/engine/hdf5/HDF5WriterP.cpp          |  4 +-
 source/engine/hdf5/HDF5WriterP.h            |  6 +-
 source/mpidummy.h                           |  2 +
 source/transform/BZip2.h                    |  1 +
 source/transport/file/FStream.h             |  1 +
 source/transport/file/FileDescriptor.h      |  1 +
 source/transport/file/FilePointer.h         |  1 +
 source/transport/file/MPI_File.h            |  3 +-
 source/transport/wan/MdtmMan.h              |  2 +-
 source/utilities/format/bp1/BP1.h           |  1 +
 source/utilities/format/bp1/BP1Aggregator.h |  1 +
 source/utilities/format/bp1/BP1Base.h       |  2 +-
 source/utilities/format/bp1/BP1Structs.h    |  1 +
 source/utilities/format/bp1/BP1Writer.h     |  2 +-
 source/utilities/realtime/dataman/DataMan.h |  1 +
 50 files changed, 169 insertions(+), 73 deletions(-)
 create mode 100644 cmake/GenerateADIOSConfig.cmake

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c0d1a2064..842a4187b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -78,6 +78,9 @@ option(ADIOS_USE_HDF5 "Enable support for the HDF5 engine" OFF)
 # platform supports it.
 set(ADIOS_USE_DataMan ${SHARED_LIBS_SUPPORTED})
 
+include(GenerateADIOSConfig)
+GenerateADIOSConfig(MPI BZip2 ADIOS1 HDF5 DataMan)
+
 #------------------------------------------------------------------------------#
 # Third party libraries
 #------------------------------------------------------------------------------#
diff --git a/cmake/GenerateADIOSConfig.cmake b/cmake/GenerateADIOSConfig.cmake
new file mode 100644
index 000000000..41b5b5ef6
--- /dev/null
+++ b/cmake/GenerateADIOSConfig.cmake
@@ -0,0 +1,66 @@
+#------------------------------------------------------------------------------#
+# Distributed under the OSI-approved Apache License, Version 2.0.  See
+# accompanying file Copyright.txt for details.
+#------------------------------------------------------------------------------#
+
+function(GenerateADIOSConfig)
+
+  file(WRITE ${ADIOS_BINARY_DIR}/ADIOSConfig.h
+"/*
+ * Distributed under the OSI-approved Apache License, Version 2.0.  See
+ * accompanying file Copyright.txt for details.
+ */
+
+#ifndef ADIOSCONFIG_H_
+#define ADIOSCONFIG_H_
+
+/* ADIOS Version Information */
+#define ADIOS2_VERSION_MAJOR ${ADIOS_VERSION_MAJOR}
+#define ADIOS2_VERSION_MINOR ${ADIOS_VERSION_MINOR}
+#define ADIOS2_VERSION_PATCH ${ADIOS_VERSION_PATCH}
+#define ADIOS2_VERSION       ${ADIOS_VERSION}
+" )
+
+  file(APPEND ${ADIOS_BINARY_DIR}/ADIOSConfig.h "
+/*
+ * ADIOS Build Information:
+ * 
+ * Compiler:
+" )
+  foreach(L IN ITEMS C CXX Fortran)
+    if(NOT CMAKE_${L}_COMPILER)
+      continue()
+    endif()
+    file(APPEND ${ADIOS_BINARY_DIR}/ADIOSConfig.h
+      " *   ${L}: ${CMAKE_${L}_COMPILER}\n"
+    )
+    if(CMAKE_${L}_COMPILER_WRAPPER)
+      file(APPEND ${ADIOS_BINARY_DIR}/ADIOSConfig.h
+        " *    Wrapper: ${CMAKE_${L}_COMPILER_WRAPPER}\n"
+      )
+    endif()
+    file(APPEND ${ADIOS_BINARY_DIR}/ADIOSConfig.h
+      " *    Id: ${CMAKE_${L}_COMPILER_ID} ${CMAKE_${L}_COMPILER_VERSION}\n"
+    )
+  endforeach()
+  file(APPEND ${ADIOS_BINARY_DIR}/ADIOSConfig.h " */\n")
+
+  foreach(OPT IN LISTS ARGN)
+    string(TOUPPER ${OPT} OPT_UPPER)
+    file(APPEND ${ADIOS_BINARY_DIR}/ADIOSConfig.h
+      "\n/* CMake Option: ADIOS_USE_${OPT}=${ADIOS_USE_${OPT}} */\n"
+    )
+    if(ADIOS_USE_${OPT})
+      file(APPEND ${ADIOS_BINARY_DIR}/ADIOSConfig.h
+        "#define ADIOS2_HAVE_${OPT_UPPER} 1\n"
+      )
+    else()
+      file(APPEND ${ADIOS_BINARY_DIR}/ADIOSConfig.h
+        "#undef ADIOS2_HAVE_${OPT_UPPER}\n"
+      )
+    endif()
+  endforeach()
+  file(APPEND ${ADIOS_BINARY_DIR}/ADIOSConfig.h
+    "\n#endif /* ADIOSCONFIG_H_ */\n"
+  )
+endfunction()
diff --git a/source/ADIOS.cpp b/source/ADIOS.cpp
index a6748445d..19e0e54cf 100644
--- a/source/ADIOS.cpp
+++ b/source/ADIOS.cpp
@@ -26,17 +26,17 @@
 #include "engine/bp/BPFileReader.h"
 #include "engine/bp/BPFileWriter.h"
 
-#ifdef ADIOS_HAVE_DATAMAN // external dependencies
+#ifdef ADIOS2_HAVE_DATAMAN // external dependencies
 #include "engine/dataman/DataManReader.h"
 #include "engine/dataman/DataManWriter.h"
 #endif
 
-#ifdef ADIOS_HAVE_ADIOS1 // external dependencies
+#ifdef ADIOS2_HAVE_ADIOS1 // external dependencies
 #include "engine/adios1/ADIOS1Reader.h"
 #include "engine/adios1/ADIOS1Writer.h"
 #endif
 
-#ifdef ADIOS_HAVE_HDF5 // external dependencies
+#ifdef ADIOS2_HAVE_HDF5 // external dependencies
 #include "engine/hdf5/HDF5ReaderP.h"
 #include "engine/hdf5/HDF5WriterP.h"
 #endif
@@ -154,7 +154,7 @@ std::shared_ptr<Engine> ADIOS::Open(const std::string &name,
     }
     else if (type == "DataManWriter")
     {
-#ifdef ADIOS_HAVE_DATAMAN
+#ifdef ADIOS2_HAVE_DATAMAN
         return std::make_shared<DataManWriter>(*this, name, accessMode, mpiComm,
                                                method);
 #else
@@ -165,7 +165,7 @@ std::shared_ptr<Engine> ADIOS::Open(const std::string &name,
     }
     else if (type == "DataManReader")
     {
-#ifdef ADIOS_HAVE_DATAMAN
+#ifdef ADIOS2_HAVE_DATAMAN
         return std::make_shared<DataManReader>(*this, name, accessMode, mpiComm,
                                                method);
 #else
@@ -176,7 +176,7 @@ std::shared_ptr<Engine> ADIOS::Open(const std::string &name,
     }
     else if (type == "ADIOS1Writer")
     {
-#ifdef ADIOS_HAVE_ADIOS1
+#ifdef ADIOS2_HAVE_ADIOS1
         return std::make_shared<ADIOS1Writer>(*this, name, accessMode, mpiComm,
                                               method);
 #else
@@ -193,7 +193,7 @@ std::shared_ptr<Engine> ADIOS::Open(const std::string &name,
     }
     else if (type == "HDF5Writer") // -junmin
     {
-#ifdef ADIOS_HAVE_HDF5
+#ifdef ADIOS2_HAVE_HDF5
         return std::make_shared<HDF5Writer>(*this, name, accessMode, mpiComm,
                                             method);
 #else
diff --git a/source/ADIOS.h b/source/ADIOS.h
index e6d0b8caa..8b7ac1e11 100644
--- a/source/ADIOS.h
+++ b/source/ADIOS.h
@@ -2,9 +2,10 @@
  * Distributed under the OSI-approved Apache License, Version 2.0.  See
  * accompanying file Copyright.txt for details.
  *
- * ADIOS.\ *
+ * ADIOS.h
  *  Created on: Oct 3, 2016
- *      Author: wfg`123 */
+ *      Author: wfg
+ */
 
 #ifndef ADIOS_H_
 #define ADIOS_H_
@@ -19,9 +20,9 @@
 #include <vector>
 /// \endcond
 
+#include "ADIOSConfig.h"
 #include "ADIOSMacros.h"
 #include "ADIOS_MPI.h"
-
 #include "ADIOSTypes.h"
 #include "core/Method.h"
 #include "core/Support.h"
diff --git a/source/ADIOSTypes.h b/source/ADIOSTypes.h
index 585a7f680..a2d52421b 100644
--- a/source/ADIOSTypes.h
+++ b/source/ADIOSTypes.h
@@ -16,6 +16,8 @@
 #include <cstdint>
 #include <type_traits>
 
+#include "ADIOSConfig.h"
+
 namespace adios
 {
 
diff --git a/source/ADIOS_MPI.h b/source/ADIOS_MPI.h
index 1a310f04f..83b5a212c 100644
--- a/source/ADIOS_MPI.h
+++ b/source/ADIOS_MPI.h
@@ -6,10 +6,10 @@
 #ifndef ADIOS_MPI_H_
 #define ADIOS_MPI_H_
 
-#ifdef ADIOS_HAVE_MPI
-#define OMPI_SKIP_MPICXX 1 // workaround for OpenMPI forcing C++ bindings
+#include "ADIOSConfig.h"
+
+#ifdef ADIOS2_HAVE_MPI
 #include <mpi.h>
-#undef OMPI_SKIP_MPICXX
 #else
 #include "mpidummy.h"
 #endif
diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
index e138a98cd..67d28164f 100644
--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -49,21 +49,18 @@ if(ADIOS_USE_DataMan)
     utilities/realtime/dataman/DataManBase.cpp
     utilities/realtime/dataman/DataMan.cpp
   )
-  target_compile_definitions(adios2 PRIVATE ADIOS_HAVE_DATAMAN)
   target_link_libraries(adios2 PRIVATE ${CMAKE_DL_LIBS})
 endif()
   
 if(ADIOS_USE_BZip2)
   find_package(BZip2 REQUIRED)
   target_sources(adios2 PRIVATE transform/BZip2.cpp)
-  target_compile_definitions(adios2 PRIVATE ADIOS_HAVE_BZIP2)
   target_link_libraries(adios2 PRIVATE BZip2::BZip2)
 endif()
 
 if(ADIOS_USE_MPI)
   find_package(MPI COMPONENTS C REQUIRED)
   target_include_directories(adios2 PUBLIC ${MPI_C_INCLUDE_PATH})
-  target_compile_definitions(adios2 PUBLIC ADIOS_HAVE_MPI)
   target_link_libraries(adios2 PUBLIC ${MPI_C_LIBRARIES})
 else()
   target_sources(adios2 PRIVATE mpidummy.cpp)
@@ -80,7 +77,6 @@ if(ADIOS_USE_ADIOS1)
     engine/adios1/ADIOS1Reader.cpp
     engine/adios1/ADIOS1Writer.cpp
   )
-  target_compile_definitions(adios2 PRIVATE ADIOS_HAVE_ADIOS1)
   target_link_libraries(adios2 PRIVATE adios1::adios)
 endif()
 
@@ -103,16 +99,17 @@ if(ADIOS_USE_HDF5)
     engine/hdf5/HDF5ReaderP.cpp
     engine/hdf5/HDF5WriterP.cpp
   )
-  target_compile_definitions(adios2 PRIVATE ADIOS_HAVE_HDF5)
   target_link_libraries(adios2 PRIVATE ${HDF5_C_LIBRARIES})
 endif()
 
 # Main header when using the build directory
 set(ADIOS_INCLUDE_DIR "${ADIOS_SOURCE_DIR}/source")
+set(ADIOS_CONFIG_DIR "${ADIOS_BINARY_DIR}")
 configure_file(adios2.h.in ${ADIOS_BINARY_DIR}/adios2.h)
 
 # Header installation
 set(ADIOS_INCLUDE_DIR "adios2")
+set(ADIOS_CONFIG_DIR "adios2")
 configure_file(adios2.h.in ${ADIOS_BINARY_DIR}/adios2.install.h)
 install(
   FILES ${ADIOS_BINARY_DIR}/adios2.install.h
@@ -120,7 +117,9 @@ install(
   RENAME adios2.h
 )
 install(
-  FILES ADIOS.h ADIOS.inl ADIOSMacros.h ADIOS_MPI.h ADIOSTypes.h mpidummy.h
+  FILES
+    ADIOS.h ADIOS.inl ADIOSMacros.h ADIOS_MPI.h ADIOSTypes.h mpidummy.h
+    ${ADIOS_BINARY_DIR}/ADIOSConfig.h
   DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/adios2
 )
 install(
diff --git a/source/adios2.h.in b/source/adios2.h.in
index 6a0a8674b..6c2a580d8 100644
--- a/source/adios2.h.in
+++ b/source/adios2.h.in
@@ -6,6 +6,7 @@
 #ifndef ADIOS2_H_
 #define ADIOS2_H_
 
+#include "@ADIOS_CONFIG_DIR@/ADIOSConfig.h"
 #include "@ADIOS_INCLUDE_DIR@/ADIOS.h"
 #include "@ADIOS_INCLUDE_DIR@/ADIOSTypes.h"
 #include "@ADIOS_INCLUDE_DIR@/core/Method.h"
diff --git a/source/capsule/heap/STLVector.h b/source/capsule/heap/STLVector.h
index 18c7f348d..019e92a59 100644
--- a/source/capsule/heap/STLVector.h
+++ b/source/capsule/heap/STLVector.h
@@ -15,6 +15,7 @@
 #include <vector>
 /// \endcond
 
+#include "ADIOSConfig.h"
 #include "core/Capsule.h"
 
 namespace adios
diff --git a/source/capsule/shmem/ShmSystemV.h b/source/capsule/shmem/ShmSystemV.h
index 2e3a14c5b..cceac2266 100644
--- a/source/capsule/shmem/ShmSystemV.h
+++ b/source/capsule/shmem/ShmSystemV.h
@@ -5,6 +5,7 @@
 #include <sys/ipc.h>
 #include <sys/types.h>
 
+#include "ADIOSConfig.h"
 #include "core/Capsule.h"
 
 namespace adios
diff --git a/source/core/Attribute.h b/source/core/Attribute.h
index d1384d228..fea3b0bed 100644
--- a/source/core/Attribute.h
+++ b/source/core/Attribute.h
@@ -15,6 +15,8 @@
 #include <string>
 /// \endcond
 
+#include "ADIOSConfig.h"
+
 namespace adios
 {
 
diff --git a/source/core/Capsule.h b/source/core/Capsule.h
index 609aab847..896ddbaf4 100644
--- a/source/core/Capsule.h
+++ b/source/core/Capsule.h
@@ -15,6 +15,8 @@
 #include <string>
 /// \endcond
 
+#include "ADIOSConfig.h"
+
 namespace adios
 {
 
diff --git a/source/core/Engine.h b/source/core/Engine.h
index 1b1e547be..6d9bc8c20 100644
--- a/source/core/Engine.h
+++ b/source/core/Engine.h
@@ -21,16 +21,16 @@
 #include <vector>
 /// \endcond
 
-#include "../ADIOS_MPI.h"
-
-#include "../ADIOS.h"
-#include "../ADIOSTypes.h"
-#include "Capsule.h"
-#include "Method.h"
-#include "Transform.h"
-#include "Transport.h"
-#include "Variable.h"
-#include "VariableCompound.h"
+#include "ADIOSConfig.h"
+#include "ADIOS_MPI.h"
+#include "ADIOS.h"
+#include "ADIOSTypes.h"
+#include "core/Capsule.h"
+#include "core/Method.h"
+#include "core/Transform.h"
+#include "core/Transport.h"
+#include "core/Variable.h"
+#include "core/VariableCompound.h"
 
 namespace adios
 {
diff --git a/source/core/IOChrono.h b/source/core/IOChrono.h
index da668822b..489c214aa 100644
--- a/source/core/IOChrono.h
+++ b/source/core/IOChrono.h
@@ -15,7 +15,8 @@
 #include <vector>
 /// \endcond
 
-#include "Timer.h"
+#include "ADIOSConfig.h"
+#include "core/Timer.h"
 
 namespace adios
 {
diff --git a/source/core/Method.h b/source/core/Method.h
index 27efc64ed..9c415e9d6 100644
--- a/source/core/Method.h
+++ b/source/core/Method.h
@@ -17,8 +17,9 @@
 #include <vector>
 /// \endcond
 
-#include "../ADIOSTypes.h"
-#include "adiosFunctions.h"
+#include "ADIOSConfig.h"
+#include "ADIOSTypes.h"
+#include "core/adiosFunctions.h"
 
 namespace adios
 {
diff --git a/source/core/Selection.h b/source/core/Selection.h
index 187ea0eda..e6c8ac2ff 100644
--- a/source/core/Selection.h
+++ b/source/core/Selection.h
@@ -33,6 +33,8 @@
 #ifndef __ADIOS_SELECTION_H__
 #define __ADIOS_SELECTION_H__
 
+#include "ADIOSConfig.h"
+
 namespace adios
 {
 
diff --git a/source/core/SelectionBoundingBox.h b/source/core/SelectionBoundingBox.h
index fb991720c..f9fec44d2 100644
--- a/source/core/SelectionBoundingBox.h
+++ b/source/core/SelectionBoundingBox.h
@@ -12,7 +12,8 @@
 
 #include <vector>
 
-#include "Selection.h"
+#include "ADIOSConfig.h"
+#include "core/Selection.h"
 
 namespace adios
 {
diff --git a/source/core/SelectionPoints.h b/source/core/SelectionPoints.h
index 981460290..f0da44f3b 100644
--- a/source/core/SelectionPoints.h
+++ b/source/core/SelectionPoints.h
@@ -12,7 +12,8 @@
 
 #include <vector>
 
-#include "Selection.h"
+#include "ADIOSConfig.h"
+#include "core/Selection.h"
 
 namespace adios
 {
diff --git a/source/core/Support.h b/source/core/Support.h
index 6284f52cb..51efeb1b2 100644
--- a/source/core/Support.h
+++ b/source/core/Support.h
@@ -17,6 +17,8 @@
 #include <string>
 /// \endcond
 
+#include "ADIOSConfig.h"
+
 namespace adios
 {
 
diff --git a/source/core/Timer.h b/source/core/Timer.h
index 62b7b8cfe..6c371fa27 100644
--- a/source/core/Timer.h
+++ b/source/core/Timer.h
@@ -16,7 +16,8 @@
 #include <string>
 /// \endcond
 
-#include "Support.h"
+#include "ADIOSConfig.h"
+#include "core/Support.h"
 
 namespace adios
 {
diff --git a/source/core/Transform.h b/source/core/Transform.h
index c133c146d..d98bbd975 100644
--- a/source/core/Transform.h
+++ b/source/core/Transform.h
@@ -16,6 +16,8 @@
 #include <vector>
 /// \endcond
 
+#include "ADIOSConfig.h"
+
 namespace adios
 {
 
diff --git a/source/core/Transport.h b/source/core/Transport.h
index 4d90414ca..ae55dc71f 100644
--- a/source/core/Transport.h
+++ b/source/core/Transport.h
@@ -16,8 +16,9 @@
 #include <vector>
 /// \endcond
 
-#include "../ADIOS_MPI.h"
-#include "IOChrono.h"
+#include "ADIOSConfig.h"
+#include "ADIOS_MPI.h"
+#include "core/IOChrono.h"
 
 namespace adios
 {
diff --git a/source/core/Variable.h b/source/core/Variable.h
index be5fc5675..30abdff35 100644
--- a/source/core/Variable.h
+++ b/source/core/Variable.h
@@ -18,8 +18,9 @@
 #include <vector>
 /// \endcond
 
-#include "Transform.h"
-#include "VariableBase.h"
+#include "ADIOSConfig.h"
+#include "core/Transform.h"
+#include "core/VariableBase.h"
 
 namespace adios
 {
diff --git a/source/core/VariableBase.h b/source/core/VariableBase.h
index e05afd69a..6f84e6003 100644
--- a/source/core/VariableBase.h
+++ b/source/core/VariableBase.h
@@ -19,9 +19,10 @@
 #include <vector>
 /// \endcond
 
-#include "SelectionBoundingBox.h"
-#include "adiosFunctions.h"
-#include "adiosTemplates.h"
+#include "ADIOSConfig.h"
+#include "core/SelectionBoundingBox.h"
+#include "core/adiosFunctions.h"
+#include "core/adiosTemplates.h"
 
 namespace adios
 {
diff --git a/source/core/VariableCompound.h b/source/core/VariableCompound.h
index 9f3ceeebe..4df5344d3 100644
--- a/source/core/VariableCompound.h
+++ b/source/core/VariableCompound.h
@@ -11,7 +11,8 @@
 #ifndef VARIABLECOMPOUND_H_
 #define VARIABLECOMPOUND_H_
 
-#include "VariableBase.h"
+#include "ADIOSConfig.h"
+#include "core/VariableBase.h"
 
 namespace adios
 {
diff --git a/source/core/adiosFunctions.cpp b/source/core/adiosFunctions.cpp
index d2a84b45f..965967852 100644
--- a/source/core/adiosFunctions.cpp
+++ b/source/core/adiosFunctions.cpp
@@ -26,7 +26,7 @@
 #include "core/Support.h"
 #include "core/adiosFunctions.h"
 
-#ifdef ADIOS_HAVE_BZIP2
+#ifdef ADIOS2_HAVE_BZIP2
 #include "transform/BZip2.h"
 #endif
 
@@ -539,7 +539,7 @@ void SetTransformsHelper(const std::vector<std::string> &transformNames,
         {
             if (transformMethod == "bzip2")
             {
-#ifdef ADIOS_HAVE_BZIP2
+#ifdef ADIOS2_HAVE_BZIP2
                 transforms.push_back(
                     std::make_shared<adios::transform::BZip2>());
 #endif
diff --git a/source/core/adiosFunctions.h b/source/core/adiosFunctions.h
index 6b76c96cc..963563347 100644
--- a/source/core/adiosFunctions.h
+++ b/source/core/adiosFunctions.h
@@ -19,8 +19,9 @@
 #include <vector>
 /// \endcond
 
-#include "../ADIOS_MPI.h"
-#include "Transform.h"
+#include "ADIOSConfig.h"
+#include "ADIOS_MPI.h"
+#include "core/Transform.h"
 
 namespace adios
 {
diff --git a/source/core/adiosTemplates.h b/source/core/adiosTemplates.h
index 5640c5387..90c8b66b9 100644
--- a/source/core/adiosTemplates.h
+++ b/source/core/adiosTemplates.h
@@ -21,6 +21,8 @@
 #include <vector>
 /// \endcond
 
+#include "ADIOSConfig.h"
+
 namespace adios
 {
 /**
diff --git a/source/core/capsuleTemplates.h b/source/core/capsuleTemplates.h
index 5208b184c..f88a3aaca 100644
--- a/source/core/capsuleTemplates.h
+++ b/source/core/capsuleTemplates.h
@@ -17,7 +17,8 @@
 #include <vector>
 /// \endcond
 
-#include "Transport.h"
+#include "ADIOSConfig.h"
+#include "core/Transport.h"
 
 namespace adios
 {
diff --git a/source/engine/adios1/ADIOS1Reader.h b/source/engine/adios1/ADIOS1Reader.h
index baf55f416..aa8059d7a 100644
--- a/source/engine/adios1/ADIOS1Reader.h
+++ b/source/engine/adios1/ADIOS1Reader.h
@@ -15,21 +15,14 @@
 
 #include <iostream> //this must go away
 
+#include "ADIOSConfig.h"
 #include "core/Engine.h"
-
-// supported capsules
 #include "capsule/heap/STLVector.h"
 
 namespace adios
 {
 
-#ifndef ADIOS_HAVE_MPI
-#define _NOMPI 1
-#endif
 #include "adios_read_v2.h" // this is adios 1.x header file
-#ifndef ADIOS_HAVE_MPI
-#undef _NOMPI
-#endif
 
 class ADIOS1Reader : public Engine
 {
diff --git a/source/engine/adios1/ADIOS1Writer.h b/source/engine/adios1/ADIOS1Writer.h
index c13eee782..407605d37 100644
--- a/source/engine/adios1/ADIOS1Writer.h
+++ b/source/engine/adios1/ADIOS1Writer.h
@@ -13,6 +13,7 @@
 #ifndef ADIOS1WRITER_H_
 #define ADIOS1WRITER_H_
 
+#include "ADIOSConfig.h"
 #include "core/Engine.h"
 
 namespace adios
diff --git a/source/engine/bp/BPFileReader.h b/source/engine/bp/BPFileReader.h
index 538be9fc3..4142e724b 100644
--- a/source/engine/bp/BPFileReader.h
+++ b/source/engine/bp/BPFileReader.h
@@ -13,8 +13,8 @@
 
 #include <iostream> //this must go away
 
+#include "ADIOSConfig.h"
 #include "core/Engine.h"
-
 #include "capsule/heap/STLVector.h"
 
 namespace adios
diff --git a/source/engine/bp/BPFileWriter.h b/source/engine/bp/BPFileWriter.h
index 6ab88afa7..5e338f043 100644
--- a/source/engine/bp/BPFileWriter.h
+++ b/source/engine/bp/BPFileWriter.h
@@ -11,8 +11,8 @@
 #ifndef BPFILEWRITER_H_
 #define BPFILEWRITER_H_
 
+#include "ADIOSConfig.h"
 #include "core/Engine.h"
-
 #include "capsule/heap/STLVector.h"
 #include "utilities/format/bp1/BP1.h"
 
diff --git a/source/engine/dataman/DataManReader.h b/source/engine/dataman/DataManReader.h
index a74adcf64..a163890d3 100644
--- a/source/engine/dataman/DataManReader.h
+++ b/source/engine/dataman/DataManReader.h
@@ -13,11 +13,10 @@
 
 #include <iostream> //std::cout << Needs to go
 
+#include "ADIOSConfig.h"
 #include "core/Engine.h"
 #include "utilities/format/bp1/BP1Writer.h"
 #include "utilities/realtime/dataman/DataMan.h"
-
-// supported capsules
 #include "capsule/heap/STLVector.h"
 
 namespace adios
diff --git a/source/engine/dataman/DataManWriter.h b/source/engine/dataman/DataManWriter.h
index ba28a5861..2e1b4c220 100644
--- a/source/engine/dataman/DataManWriter.h
+++ b/source/engine/dataman/DataManWriter.h
@@ -14,11 +14,10 @@
 #include <iostream> //std::cout must be removed, only used for hello example
 #include <unistd.h> //sleep must be removed
 
+#include "ADIOSConfig.h"
 #include "core/Engine.h"
 #include "utilities/format/bp1/BP1Writer.h"
 #include "utilities/realtime/dataman/DataMan.h"
-
-// supported capsules
 #include "capsule/heap/STLVector.h"
 
 namespace adios
diff --git a/source/engine/hdf5/HDF5WriterP.cpp b/source/engine/hdf5/HDF5WriterP.cpp
index 40837346d..cec8d43a4 100644
--- a/source/engine/hdf5/HDF5WriterP.cpp
+++ b/source/engine/hdf5/HDF5WriterP.cpp
@@ -78,7 +78,7 @@ void HDF5Writer::Init()
 
     _plist_id = H5Pcreate(H5P_FILE_ACCESS);
 
-#ifdef ADIOS_HAVE_MPI
+#ifdef ADIOS2_HAVE_MPI
     H5Pset_fapl_mpio(_plist_id, m_MPIComm, MPI_INFO_NULL);
 #endif
 
@@ -342,7 +342,7 @@ void HDF5Writer::UseHDFWrite(Variable<T> &variable, const T *values,
     //  Create property list for collective dataset write.
 
     _plist_id = H5Pcreate(H5P_DATASET_XFER);
-#ifdef ADIOS_HAVE_MPI
+#ifdef ADIOS2_HAVE_MPI
     H5Pset_dxpl_mpio(_plist_id, H5FD_MPIO_COLLECTIVE);
 #endif
     herr_t status;
diff --git a/source/engine/hdf5/HDF5WriterP.h b/source/engine/hdf5/HDF5WriterP.h
index 64fc6031c..9975fe526 100644
--- a/source/engine/hdf5/HDF5WriterP.h
+++ b/source/engine/hdf5/HDF5WriterP.h
@@ -12,13 +12,11 @@
 #ifndef HDF5_WRITER_P_H_
 #define HDF5_WRITER_P_H_
 
+#include "ADIOSConfig.h"
+#include "ADIOS_MPI.h"
 #include "core/Engine.h"
-
-// supported capsules
 #include "capsule/heap/STLVector.h"
 
-#include "ADIOS_MPI.h"
-
 #include <hdf5.h>
 
 namespace adios
diff --git a/source/mpidummy.h b/source/mpidummy.h
index 86122ede8..3803925bc 100644
--- a/source/mpidummy.h
+++ b/source/mpidummy.h
@@ -19,6 +19,8 @@
 #include <sys/types.h>
 /// \endcond
 
+#include "ADIOSConfig.h"
+
 namespace adios
 {
 
diff --git a/source/transform/BZip2.h b/source/transform/BZip2.h
index 57f7cf25d..bf2110880 100644
--- a/source/transform/BZip2.h
+++ b/source/transform/BZip2.h
@@ -11,6 +11,7 @@
 #ifndef BZIP2_H_
 #define BZIP2_H_
 
+#include "ADIOSConfig.h"
 #include "core/Transform.h"
 
 namespace adios
diff --git a/source/transport/file/FStream.h b/source/transport/file/FStream.h
index 79c6737c4..4bfe0111d 100644
--- a/source/transport/file/FStream.h
+++ b/source/transport/file/FStream.h
@@ -15,6 +15,7 @@
 #include <fstream>
 /// \endcond
 
+#include "ADIOSConfig.h"
 #include "core/Transport.h"
 
 namespace adios
diff --git a/source/transport/file/FileDescriptor.h b/source/transport/file/FileDescriptor.h
index 812bdcadb..f326f6ddd 100644
--- a/source/transport/file/FileDescriptor.h
+++ b/source/transport/file/FileDescriptor.h
@@ -11,6 +11,7 @@
 #ifndef FILEDESCRIPTOR_H_
 #define FILEDESCRIPTOR_H_
 
+#include "ADIOSConfig.h"
 #include "core/Transport.h"
 
 namespace adios
diff --git a/source/transport/file/FilePointer.h b/source/transport/file/FilePointer.h
index 0967e400b..28cd2f911 100644
--- a/source/transport/file/FilePointer.h
+++ b/source/transport/file/FilePointer.h
@@ -15,6 +15,7 @@
 #include <stdio.h> // FILE*
 /// \endcond
 
+#include "ADIOSConfig.h"
 #include "core/Transport.h"
 
 namespace adios
diff --git a/source/transport/file/MPI_File.h b/source/transport/file/MPI_File.h
index 445df8200..5cfdd16d6 100644
--- a/source/transport/file/MPI_File.h
+++ b/source/transport/file/MPI_File.h
@@ -11,9 +11,8 @@
 #ifndef MPI_FILE_H_
 #define MPI_FILE_H_
 
-/// \cond EXCLUDE_FROM_DOXYGEN
+#include "ADIOSConfig.h"
 #include "ADIOS_MPI.h"
-/// \endcond
 
 namespace adios
 {
diff --git a/source/transport/wan/MdtmMan.h b/source/transport/wan/MdtmMan.h
index 78f0f92b8..6f718bc36 100644
--- a/source/transport/wan/MdtmMan.h
+++ b/source/transport/wan/MdtmMan.h
@@ -11,9 +11,9 @@
 #ifndef MDTMMAN_H_
 #define MDTMMAN_H_
 
+#include "ADIOSConfig.h"
 #include "core/Transport.h"
 #include "external/json.hpp"
-
 #include "utilities/realtime/dataman/DataManBase.h"
 
 namespace adios
diff --git a/source/utilities/format/bp1/BP1.h b/source/utilities/format/bp1/BP1.h
index d1b394088..ed447f8e4 100644
--- a/source/utilities/format/bp1/BP1.h
+++ b/source/utilities/format/bp1/BP1.h
@@ -11,6 +11,7 @@
 #ifndef BP1_H_
 #define BP1_H_
 
+#include "ADIOSConfig.h"
 #include "utilities/format/bp1/BP1Aggregator.h"
 #include "utilities/format/bp1/BP1Structs.h"
 #include "utilities/format/bp1/BP1Writer.h"
diff --git a/source/utilities/format/bp1/BP1Aggregator.h b/source/utilities/format/bp1/BP1Aggregator.h
index 8682ba62b..23d2736a5 100644
--- a/source/utilities/format/bp1/BP1Aggregator.h
+++ b/source/utilities/format/bp1/BP1Aggregator.h
@@ -15,6 +15,7 @@
 #include <string>
 /// \endcond
 
+#include "ADIOSConfig.h"
 #include "ADIOS_MPI.h"
 
 namespace adios
diff --git a/source/utilities/format/bp1/BP1Base.h b/source/utilities/format/bp1/BP1Base.h
index bb5173103..7f709e4b0 100644
--- a/source/utilities/format/bp1/BP1Base.h
+++ b/source/utilities/format/bp1/BP1Base.h
@@ -18,7 +18,7 @@
 #include <vector>
 /// \endcond
 
-//#include <queue>  //std::priority_queue to be added later
+#include "ADIOSConfig.h"
 #include "ADIOS_MPI.h"
 #include "core/Transport.h"
 
diff --git a/source/utilities/format/bp1/BP1Structs.h b/source/utilities/format/bp1/BP1Structs.h
index 77f22feb8..ce2721288 100644
--- a/source/utilities/format/bp1/BP1Structs.h
+++ b/source/utilities/format/bp1/BP1Structs.h
@@ -18,6 +18,7 @@
 #include <vector>
 /// \endcond
 
+#include "ADIOSConfig.h"
 #include "core/IOChrono.h"
 
 namespace adios
diff --git a/source/utilities/format/bp1/BP1Writer.h b/source/utilities/format/bp1/BP1Writer.h
index b8876c7f3..aff0b9890 100644
--- a/source/utilities/format/bp1/BP1Writer.h
+++ b/source/utilities/format/bp1/BP1Writer.h
@@ -17,11 +17,11 @@
 #include <cstring>   //std::memcpy
 /// \endcond
 
+#include "ADIOSConfig.h"
 #include "ADIOSMacros.h"
 #include "ADIOSTypes.h"
 #include "utilities/format/bp1/BP1Base.h"
 #include "utilities/format/bp1/BP1Structs.h"
-
 #include "capsule/heap/STLVector.h"
 #include "core/Variable.h"
 #include "core/adiosFunctions.h"
diff --git a/source/utilities/realtime/dataman/DataMan.h b/source/utilities/realtime/dataman/DataMan.h
index 59640e933..5ce0fc3a2 100644
--- a/source/utilities/realtime/dataman/DataMan.h
+++ b/source/utilities/realtime/dataman/DataMan.h
@@ -11,6 +11,7 @@
 #ifndef DATAMANAGER_H_
 #define DATAMANAGER_H_
 
+#include "ADIOSConfig.h"
 #include "utilities/realtime/dataman/DataManBase.h"
 
 namespace adios
-- 
GitLab