From 27549d8ef553b70d6ff0ae3d87d52f1775bd5e45 Mon Sep 17 00:00:00 2001
From: Chuck Atkins <chuck.atkins@kitware.com>
Date: Tue, 18 Apr 2017 21:35:41 -0400
Subject: [PATCH] Finished header migration and added install rules

---
 CMakeLists.txt                                |  7 ----
 include/adios2.h                              | 21 ----------
 {include => source}/ADIOS.h                   |  0
 {include => source}/ADIOS.inl                 |  0
 {include => source}/ADIOSMacros.h             |  0
 {include => source}/ADIOSTypes.h              |  0
 {include => source}/ADIOS_MPI.h               |  0
 source/CMakeLists.txt                         | 40 ++++++++++++++++---
 source/adios2.h.in                            | 15 +++++++
 {include => source}/core/Attribute.h          |  0
 {include => source}/core/Capsule.h            |  0
 {include => source}/core/Engine.h             |  0
 {include => source}/core/IOChrono.h           |  0
 {include => source}/core/Method.h             |  0
 {include => source}/core/Selection.h          |  0
 .../core/SelectionBoundingBox.h               |  0
 {include => source}/core/SelectionPoints.h    |  0
 {include => source}/core/Support.h            |  0
 {include => source}/core/Timer.h              |  0
 {include => source}/core/Transform.h          |  0
 {include => source}/core/Transport.h          |  0
 {include => source}/core/Variable.h           |  0
 {include => source}/core/VariableBase.h       |  0
 {include => source}/core/VariableCompound.h   |  0
 {include => source}/core/adiosFunctions.h     |  0
 {include => source}/core/adiosTemplates.h     |  0
 {include => source}/core/capsuleTemplates.h   |  0
 source/engine/adios1/ADIOS1Reader.cpp         |  2 +-
 source/engine/bp/BPFileReader.cpp             |  2 +-
 source/engine/dataman/DataManReader.cpp       |  2 +-
 {include => source}/mpidummy.h                |  0
 31 files changed, 52 insertions(+), 37 deletions(-)
 delete mode 100644 include/adios2.h
 rename {include => source}/ADIOS.h (100%)
 rename {include => source}/ADIOS.inl (100%)
 rename {include => source}/ADIOSMacros.h (100%)
 rename {include => source}/ADIOSTypes.h (100%)
 rename {include => source}/ADIOS_MPI.h (100%)
 create mode 100644 source/adios2.h.in
 rename {include => source}/core/Attribute.h (100%)
 rename {include => source}/core/Capsule.h (100%)
 rename {include => source}/core/Engine.h (100%)
 rename {include => source}/core/IOChrono.h (100%)
 rename {include => source}/core/Method.h (100%)
 rename {include => source}/core/Selection.h (100%)
 rename {include => source}/core/SelectionBoundingBox.h (100%)
 rename {include => source}/core/SelectionPoints.h (100%)
 rename {include => source}/core/Support.h (100%)
 rename {include => source}/core/Timer.h (100%)
 rename {include => source}/core/Transform.h (100%)
 rename {include => source}/core/Transport.h (100%)
 rename {include => source}/core/Variable.h (100%)
 rename {include => source}/core/VariableBase.h (100%)
 rename {include => source}/core/VariableCompound.h (100%)
 rename {include => source}/core/adiosFunctions.h (100%)
 rename {include => source}/core/adiosTemplates.h (100%)
 rename {include => source}/core/capsuleTemplates.h (100%)
 rename {include => source}/mpidummy.h (100%)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0fbada375..c0d1a2064 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -92,13 +92,6 @@ add_subdirectory(thirdparty)
 #------------------------------------------------------------------------------#
 add_subdirectory(source)
 
-#------------------------------------------------------------------------------#
-# Installation
-#------------------------------------------------------------------------------#
-install(DIRECTORY include/
-  DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
-  FILES_MATCHING PATTERN "*.h"
-)
 #------------------------------------------------------------------------------#
 # Examples
 #------------------------------------------------------------------------------#
diff --git a/include/adios2.h b/include/adios2.h
deleted file mode 100644
index f1e7d56c4..000000000
--- a/include/adios2.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Distributed under the OSI-approved Apache License, Version 2.0.  See
- * accompanying file Copyright.txt for details.
- *
- * ADIOS_CPP.h
- *
- *  Created on: Jan 9, 2017
- *      Author: wfg
- */
-
-#ifndef ADIOS_CPP_H_
-#define ADIOS_CPP_H_
-
-#include "ADIOS.h"
-#include "ADIOSTypes.h"
-#include "core/Method.h"
-
-#include "core/Engine.h"
-#include "core/Transform.h"
-
-#endif /* ADIOS_CPP_H_ */
diff --git a/include/ADIOS.h b/source/ADIOS.h
similarity index 100%
rename from include/ADIOS.h
rename to source/ADIOS.h
diff --git a/include/ADIOS.inl b/source/ADIOS.inl
similarity index 100%
rename from include/ADIOS.inl
rename to source/ADIOS.inl
diff --git a/include/ADIOSMacros.h b/source/ADIOSMacros.h
similarity index 100%
rename from include/ADIOSMacros.h
rename to source/ADIOSMacros.h
diff --git a/include/ADIOSTypes.h b/source/ADIOSTypes.h
similarity index 100%
rename from include/ADIOSTypes.h
rename to source/ADIOSTypes.h
diff --git a/include/ADIOS_MPI.h b/source/ADIOS_MPI.h
similarity index 100%
rename from include/ADIOS_MPI.h
rename to source/ADIOS_MPI.h
diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
index 8195f8e24..b9481731c 100644
--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -5,7 +5,6 @@
   
 add_library(adios2
   ADIOS.cpp ADIOS.tcc
-  #ADIOS_C.cpp
   
   capsule/heap/STLVector.cpp
   capsule/shmem/ShmSystemV.cpp
@@ -36,7 +35,9 @@ add_library(adios2
   utilities/format/bp1/BP1Writer.tcc
 )
 target_include_directories(adios2
-  PUBLIC ${ADIOS_SOURCE_DIR}/include
+  PUBLIC
+    $<BUILD_INTERFACE:${ADIOS_BINARY_DIR}>
+    $<INSTALL_INTERFACE:include>
   PRIVATE ${ADIOS_SOURCE_DIR}/source
 )
   
@@ -51,7 +52,6 @@ if(ADIOS_USE_DataMan)
   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)
@@ -60,7 +60,6 @@ if(ADIOS_USE_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})
@@ -88,9 +87,15 @@ endif()
 if(ADIOS_USE_HDF5)
   find_package(HDF5 REQUIRED)
   if(ADIOS_USE_MPI AND (NOT HDF5_IS_PARALLEL))
-    message(FATAL_ERROR "A sequential version of HDF5 was detected but the parallel version of ADIOS is being built, which requires a parallel HDF5.")
+    message(FATAL_ERROR
+      "A sequential version of HDF5 was detected but the parallel version "
+      "of ADIOS is being built, which requires a parallel HDF5."
+    )
   elseif((NOT ADIOS_USE_MPI) AND HDF5_IS_PARALLEL)
-    message(FATAL_ERROR "A parallel version of HDF5 was detected but the sequential version of ADIOS is being built, which requires a sequential HDF5.")
+    message(FATAL_ERROR
+      "A parallel version of HDF5 was detected but the sequential version "
+      "of ADIOS is being built, which requires a sequential HDF5."
+    )
   endif()
 
   target_include_directories(adios2 PRIVATE ${HDF5_INCLUDE_DIRS})
@@ -101,3 +106,26 @@ if(ADIOS_USE_HDF5)
   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")
+configure_file(adios2.h.in ${ADIOS_BINARY_DIR}/adios2.h)
+
+# Header installation
+set(ADIOS_INCLUDE_DIR "adios2")
+configure_file(adios2.h.in ${ADIOS_BINARY_DIR}/adios2.install.h)
+install(
+  FILES ${ADIOS_BINARY_DIR}/adios2.install.h
+  DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
+  RENAME adios2.h
+)
+install(
+  FILES
+    ADIOS.h ADIOSMacros.h ADIOS_MPI.h ADIOSTypes.h mpidummy.h
+  DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/adios2
+)
+install(
+  DIRECTORY core
+  DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/adios2
+  FILES_MATCHING PATTERN "*.h" PATTERN "*.inl"
+)
diff --git a/source/adios2.h.in b/source/adios2.h.in
new file mode 100644
index 000000000..6a0a8674b
--- /dev/null
+++ b/source/adios2.h.in
@@ -0,0 +1,15 @@
+/*
+ * Distributed under the OSI-approved Apache License, Version 2.0.  See
+ * accompanying file Copyright.txt for details.
+ */
+
+#ifndef ADIOS2_H_
+#define ADIOS2_H_
+
+#include "@ADIOS_INCLUDE_DIR@/ADIOS.h"
+#include "@ADIOS_INCLUDE_DIR@/ADIOSTypes.h"
+#include "@ADIOS_INCLUDE_DIR@/core/Method.h"
+#include "@ADIOS_INCLUDE_DIR@/core/Engine.h"
+#include "@ADIOS_INCLUDE_DIR@/core/Transform.h"
+
+#endif /* ADIOS2_H_ */
diff --git a/include/core/Attribute.h b/source/core/Attribute.h
similarity index 100%
rename from include/core/Attribute.h
rename to source/core/Attribute.h
diff --git a/include/core/Capsule.h b/source/core/Capsule.h
similarity index 100%
rename from include/core/Capsule.h
rename to source/core/Capsule.h
diff --git a/include/core/Engine.h b/source/core/Engine.h
similarity index 100%
rename from include/core/Engine.h
rename to source/core/Engine.h
diff --git a/include/core/IOChrono.h b/source/core/IOChrono.h
similarity index 100%
rename from include/core/IOChrono.h
rename to source/core/IOChrono.h
diff --git a/include/core/Method.h b/source/core/Method.h
similarity index 100%
rename from include/core/Method.h
rename to source/core/Method.h
diff --git a/include/core/Selection.h b/source/core/Selection.h
similarity index 100%
rename from include/core/Selection.h
rename to source/core/Selection.h
diff --git a/include/core/SelectionBoundingBox.h b/source/core/SelectionBoundingBox.h
similarity index 100%
rename from include/core/SelectionBoundingBox.h
rename to source/core/SelectionBoundingBox.h
diff --git a/include/core/SelectionPoints.h b/source/core/SelectionPoints.h
similarity index 100%
rename from include/core/SelectionPoints.h
rename to source/core/SelectionPoints.h
diff --git a/include/core/Support.h b/source/core/Support.h
similarity index 100%
rename from include/core/Support.h
rename to source/core/Support.h
diff --git a/include/core/Timer.h b/source/core/Timer.h
similarity index 100%
rename from include/core/Timer.h
rename to source/core/Timer.h
diff --git a/include/core/Transform.h b/source/core/Transform.h
similarity index 100%
rename from include/core/Transform.h
rename to source/core/Transform.h
diff --git a/include/core/Transport.h b/source/core/Transport.h
similarity index 100%
rename from include/core/Transport.h
rename to source/core/Transport.h
diff --git a/include/core/Variable.h b/source/core/Variable.h
similarity index 100%
rename from include/core/Variable.h
rename to source/core/Variable.h
diff --git a/include/core/VariableBase.h b/source/core/VariableBase.h
similarity index 100%
rename from include/core/VariableBase.h
rename to source/core/VariableBase.h
diff --git a/include/core/VariableCompound.h b/source/core/VariableCompound.h
similarity index 100%
rename from include/core/VariableCompound.h
rename to source/core/VariableCompound.h
diff --git a/include/core/adiosFunctions.h b/source/core/adiosFunctions.h
similarity index 100%
rename from include/core/adiosFunctions.h
rename to source/core/adiosFunctions.h
diff --git a/include/core/adiosTemplates.h b/source/core/adiosTemplates.h
similarity index 100%
rename from include/core/adiosTemplates.h
rename to source/core/adiosTemplates.h
diff --git a/include/core/capsuleTemplates.h b/source/core/capsuleTemplates.h
similarity index 100%
rename from include/core/capsuleTemplates.h
rename to source/core/capsuleTemplates.h
diff --git a/source/engine/adios1/ADIOS1Reader.cpp b/source/engine/adios1/ADIOS1Reader.cpp
index f7dff53eb..376927bc0 100644
--- a/source/engine/adios1/ADIOS1Reader.cpp
+++ b/source/engine/adios1/ADIOS1Reader.cpp
@@ -9,7 +9,7 @@
  */
 
 #include "core/Support.h"
-#include "core/adiosFunctions.h"      // CSVToVector
+#include "core/adiosFunctions.h"           // CSVToVector
 #include "transport/file/FStream.h"        // uses C++ fstream
 #include "transport/file/FileDescriptor.h" // uses POSIX
 #include "transport/file/FilePointer.h"    // uses C FILE*
diff --git a/source/engine/bp/BPFileReader.cpp b/source/engine/bp/BPFileReader.cpp
index 20666551e..265ab95bf 100644
--- a/source/engine/bp/BPFileReader.cpp
+++ b/source/engine/bp/BPFileReader.cpp
@@ -11,7 +11,7 @@
 #include "BPFileReader.h"
 
 #include "core/Support.h"
-#include "core/adiosFunctions.h"      // CSVToVector
+#include "core/adiosFunctions.h"           // CSVToVector
 #include "transport/file/FStream.h"        // uses C++ fstream
 #include "transport/file/FileDescriptor.h" // uses POSIX
 #include "transport/file/FilePointer.h"    // uses C FILE*
diff --git a/source/engine/dataman/DataManReader.cpp b/source/engine/dataman/DataManReader.cpp
index dc936720b..32cfdb967 100644
--- a/source/engine/dataman/DataManReader.cpp
+++ b/source/engine/dataman/DataManReader.cpp
@@ -11,8 +11,8 @@
 #include "DataManReader.h"
 
 #include "core/Support.h"
-#include "external/json.hpp"
 #include "core/adiosFunctions.h" //CSVToVector
+#include "external/json.hpp"
 
 // supported transports
 #include "transport/file/FStream.h"        // uses C++ fstream
diff --git a/include/mpidummy.h b/source/mpidummy.h
similarity index 100%
rename from include/mpidummy.h
rename to source/mpidummy.h
-- 
GitLab