From 696810f449bf505d5904d824815684285133498b Mon Sep 17 00:00:00 2001
From: Chuck Atkins <chuck.atkins@kitware.com>
Date: Wed, 14 Jun 2017 17:08:57 -0400
Subject: [PATCH] CMake: Allow auto-detection of default options

---
 CMakeLists.txt                                |  50 ++++-----
 bindings/CMakeLists.txt                       |   2 +-
 bindings/python/CMakeLists.txt                |   2 +-
 ...ADIOSConfig.cmake => ADIOSFunctions.cmake} |  21 +++-
 cmake/DetectOptions.cmake                     | 104 ++++++++++++++++++
 examples/basics/globalArray/CMakeLists.txt    |   8 +-
 examples/basics/joinedArray/CMakeLists.txt    |   8 +-
 examples/basics/localArray/CMakeLists.txt     |   8 +-
 examples/basics/values/CMakeLists.txt         |   8 +-
 examples/experimental/CMakeLists.txt          |   2 +-
 .../experimental/multistep/CMakeLists.txt     |  11 +-
 examples/heatTransfer/CMakeLists.txt          |   2 +-
 examples/heatTransfer/read/CMakeLists.txt     |   4 +-
 examples/heatTransfer/write/CMakeLists.txt    |  10 +-
 examples/hello/CMakeLists.txt                 |   6 +-
 examples/hello/adios1Writer/CMakeLists.txt    |   2 +-
 examples/hello/bpFlushWriter/CMakeLists.txt   |   2 +-
 examples/hello/bpTimeWriter/CMakeLists.txt    |   2 +-
 examples/hello/bpWriter/CMakeLists.txt        |   2 +-
 examples/hello/datamanReader/CMakeLists.txt   |   2 +-
 examples/hello/datamanWriter/CMakeLists.txt   |   2 +-
 examples/hello/hdf5Writer/CMakeLists.txt      |   2 +-
 source/CMakeLists.txt                         |   2 +-
 source/adios2/ADIOSConfig.h.in                |   8 +-
 source/adios2/CMakeLists.txt                  |  22 ++--
 source/dataman/CMakeLists.txt                 |  13 ++-
 testing/adios2/engine/CMakeLists.txt          |   8 +-
 testing/adios2/engine/adios1/CMakeLists.txt   |   2 +-
 testing/adios2/engine/bp/CMakeLists.txt       |   2 +-
 thirdparty/CMakeLists.txt                     |   2 +-
 30 files changed, 213 insertions(+), 106 deletions(-)
 rename cmake/{GenerateADIOSConfig.cmake => ADIOSFunctions.cmake} (50%)
 create mode 100644 cmake/DetectOptions.cmake

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b277e4d33..6dde11a35 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -37,6 +37,7 @@ endif()
 #------------------------------------------------------------------------------#
 # Top level options
 #------------------------------------------------------------------------------#
+include(ADIOSFunctions)
 
 # Default to a debug build if not specified
 if(NOT CMAKE_BUILD_TYPE)
@@ -54,33 +55,30 @@ get_property(SHARED_LIBS_SUPPORTED GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS)
 cmake_dependent_option(ADIOS_BUILD_SHARED_LIBS
   "Whether or not to build shared libraries" ON
   "SHARED_LIBS_SUPPORTED" OFF)
-if(SHARED_LIBS_SUPPORTED)
-  cmake_dependent_option(ADIOS_ENABLE_PIC
-    "Build with Position Independent Code" ON
-    "NOT ADIOS_BUILD_SHARED_LIBS" ON)
-endif()
+cmake_dependent_option(ADIOS_ENABLE_PIC
+  "Build with Position Independent Code" ON
+  "SHARED_LIBS_SUPPORTED" OFF)
 set(BUILD_SHARED_LIBS ${ADIOS_BUILD_SHARED_LIBS})
 
 if(ADIOS_ENABLE_PIC)
   set(CMAKE_POSITION_INDEPENDENT_CODE ON)
 endif()
 
-option(ADIOS_USE_MPI "Enable the MPI version of ADIOS" OFF)
-if(ADIOS_USE_MPI)
+adios_option(BZip2   "Enable support for BZip2 transforms" AUTO)
+adios_option(ZFP     "Enable support for ZFP transforms" AUTO)
+adios_option(MPI     "Enable support for MPI" AUTO)
+adios_option(DataMan "Enable support for DataMan" AUTO)
+adios_option(ZeroMQ  "Enable support for ZeroMQ" AUTO)
+adios_option(HDF5    "Enable support for the HDF5 engine" AUTO)
+adios_option(ADIOS1  "Enable support for the ADIOS 1 engine" AUTO)
+adios_option(Python  "Enable support for Python bindings" AUTO)
+include(${ADIOS_SOURCE_DIR}/cmake/DetectOptions.cmake)
+
+if(ADIOS_HAVE_MPI)
   # Workaround for OpenMPI forcing the link of C++ bindings
   add_definitions(-DOMPI_SKIP_MPICXX)
 endif()
-option(ADIOS_USE_BZip2 "Enable support for BZip2 transforms" OFF)
-option(ADIOS_USE_ZFP "Enable support for ZFP transforms" OFF)
-option(ADIOS_USE_ADIOS1 "Enable support for the ADIOS 1 engine" OFF)
-option(ADIOS_USE_HDF5 "Enable support for the HDF5 engine" OFF)
-option(ADIOS_USE_Python "Enable support for Python bindings" OFF)
-
-# DataMan is not a user-settable option.  It will always be enabled if the
-# platform supports it.
-set(ADIOS_USE_DataMan ${SHARED_LIBS_SUPPORTED})
 
-include(GenerateADIOSConfig)
 GenerateADIOSConfig(MPI ZFP BZip2 ADIOS1 HDF5 DataMan Python)
 install(
   FILES ${ADIOS_BINARY_DIR}/adios2/ADIOSConfig.h
@@ -141,13 +139,13 @@ else()
 endif()
 message("    Build Type:   ${CMAKE_BUILD_TYPE}")
 message("    Testing: ${BUILD_TESTING}")
-message("    MPI:     ${ADIOS_USE_MPI}")
-message("    BZip2:   ${ADIOS_USE_BZip2}")
-message("    ZFP:     ${ADIOS_USE_ZFP}")
-message("    ADIOS1:  ${ADIOS_USE_ADIOS1}")
-message("    DataMan: ${ADIOS_USE_DataMan}")
-message("      ZeroMQ:  ${ADIOS_USE_DataMan_ZeroMQ}")
-message("      ZFP:     ${ADIOS_USE_DataMan_ZFP}")
-message("    HDF5:    ${ADIOS_USE_HDF5}")
-message("    Python:  ${ADIOS_USE_Python}")
+message("    Build Options:")
+foreach(opt BZip2 ZFP MPI DataMan ZeroMQ HDF5 ADIOS1 Python)
+  message_pad("      ${opt}" 13 label)
+  if(${ADIOS_HAVE_${opt}})
+    message("${label}: ON")
+  else()
+    message("${label}: OFF")
+  endif()
+endforeach()
 message("")
diff --git a/bindings/CMakeLists.txt b/bindings/CMakeLists.txt
index 1299ac394..525ffce4e 100644
--- a/bindings/CMakeLists.txt
+++ b/bindings/CMakeLists.txt
@@ -1,3 +1,3 @@
-if(ADIOS_USE_Python)
+if(ADIOS_HAVE_Python)
   add_subdirectory(python)
 endif()
diff --git a/bindings/python/CMakeLists.txt b/bindings/python/CMakeLists.txt
index 491ca2714..dfbe163dd 100644
--- a/bindings/python/CMakeLists.txt
+++ b/bindings/python/CMakeLists.txt
@@ -18,7 +18,7 @@ pybind11_add_module(adios2py MODULE
   VariablePy.cpp
 )
 target_link_libraries(adios2py PRIVATE adios2)
-if(ADIOS_USE_MPI)
+if(ADIOS_HAVE_MPI)
   find_package(PythonModule REQUIRED COMPONENTS mpi4py mpi4py/mpi4py.h)
   target_link_libraries(adios2py PRIVATE PythonModule::mpi4py)
 endif()
diff --git a/cmake/GenerateADIOSConfig.cmake b/cmake/ADIOSFunctions.cmake
similarity index 50%
rename from cmake/GenerateADIOSConfig.cmake
rename to cmake/ADIOSFunctions.cmake
index d976a3eb2..7791e47d3 100644
--- a/cmake/GenerateADIOSConfig.cmake
+++ b/cmake/ADIOSFunctions.cmake
@@ -6,7 +6,7 @@
 function(GenerateADIOSConfig)
   foreach(OPT IN LISTS ARGN)
     string(TOUPPER ${OPT} OPT_UPPER)
-    if(ADIOS_USE_${OPT})
+    if(ADIOS_HAVE_${OPT})
       set(ADIOS2_HAVE_${OPT_UPPER} 1)
     else()
       set(ADIOS2_HAVE_${OPT_UPPER})
@@ -18,3 +18,22 @@ function(GenerateADIOSConfig)
     ${ADIOS_BINARY_DIR}/adios2/ADIOSConfig.h
   )
 endfunction()
+
+function(adios_option name description default)
+  set(ADIOS_USE_${name} ${default} CACHE STRING "${description}")
+  set_property(CACHE ADIOS_USE_${name} PROPERTY
+    STRINGS "ON;TRUE;AUTO;OFF;FALSE"
+  )
+endfunction()
+
+function(message_pad msg out_len out_msg)
+  string(LENGTH "${msg}" msg_len)
+  if(NOT (msg_len LESS out_len))
+    set(${out_msg} "${msg}" PARENT_SCOPE)
+  else()
+    math(EXPR pad_len "${out_len} - ${msg_len}")
+    string(RANDOM LENGTH ${pad_len} pad)
+    string(REGEX REPLACE "." " " pad "${pad}")
+    set(${out_msg} "${msg}${pad}" PARENT_SCOPE)
+  endif()
+endfunction()
diff --git a/cmake/DetectOptions.cmake b/cmake/DetectOptions.cmake
new file mode 100644
index 000000000..fd02ef97f
--- /dev/null
+++ b/cmake/DetectOptions.cmake
@@ -0,0 +1,104 @@
+#------------------------------------------------------------------------------#
+# Distributed under the OSI-approved Apache License, Version 2.0.  See
+# accompanying file Copyright.txt for details.
+#------------------------------------------------------------------------------#
+
+# This file contains the option and dependency logic.  The configuration
+# options are designed to be tertiary: ON, OFF, or AUTO.  If AUTO, we try to
+# determine if dependencies are available and enable the option if we find
+# them, otherwise we disable it.  If explicitly ON then a failure to find
+# dependencies is an error,
+
+# BZip2
+if(ADIOS_USE_BZip2 STREQUAL AUTO)
+  find_package(BZip2)
+  if(BZIP2_FOUND)
+    set(ADIOS_HAVE_BZip2 TRUE)
+  endif()
+elseif(ADIOS_USE_BZip2)
+  set(ADIOS_HAVE_BZip2 TRUE)
+endif()
+
+# ZFP
+if(ADIOS_USE_ZFP STREQUAL AUTO)
+  find_package(ZFP)
+  if(ZFP_FOUND)
+    set(ADIOS_HAVE_ZFP TRUE)
+  endif()
+elseif(ADIOS_USE_ZFP)
+  set(ADIOS_HAVE_ZFP TRUE)
+endif()
+
+# MPI
+if(ADIOS_USE_MPI STREQUAL AUTO)
+  find_package(MPI COMPONENTS C)
+  if(MPI_FOUND)
+    set(ADIOS_HAVE_MPI TRUE)
+  endif()
+elseif(ADIOS_USE_MPI)
+  set(ADIOS_HAVE_MPI TRUE)
+endif()
+
+# DataMan
+if(ADIOS_USE_DataMan STREQUAL AUTO)
+  if(SHARED_LIBS_SUPPORTED AND NOT MSVC)
+    set(ADIOS_HAVE_DataMan TRUE)
+  endif()
+elseif(ADIOS_USE_DataMan)
+  set(ADIOS_HAVE_DataMan TRUE)
+endif()
+
+# ZeroMQ
+if(ADIOS_USE_ZeroMQ STREQUAL AUTO)
+  find_package(ZeroMQ)
+  if(ZeroMQ_FOUND)
+    set(ADIOS_HAVE_ZeroMQ TRUE)
+  endif()
+elseif(ADIOS_USE_ZeroMQ)
+  set(ADIOS_HAVE_ZeroMQ TRUE)
+endif()
+
+# HDF5
+if(ADIOS_USE_HDF5 STREQUAL AUTO)
+  find_package(HDF5 COMPONENTS C)
+  if(HDF5_FOUND AND
+     ((ADIOS_HAVE_MPI AND HDF5_IS_PARALLEL) OR
+      NOT (ADIOS_HAVE_MPI OR HDF5_IS_PARALLEL)))
+    set(ADIOS_HAVE_HDF5 TRUE)
+  endif()
+elseif(ADIOS_USE_HDF5)
+  set(ADIOS_HAVE_HDF5 TRUE)
+endif()
+
+# ADIOS1
+if(ADIOS_USE_ADIOS1 STREQUAL AUTO)
+  if(NOT ADIOS_HAVE_MPI)
+    set(adios1_args COMPONENTS sequential)
+  endif()
+  find_package(ADIOS1 1.12.0 ${adios1_args})
+  unset(adios1_args)
+  if(ADIOS1_FOUND)
+    set(ADIOS_HAVE_ADIOS1 TRUE)
+  endif()
+elseif(ADIOS_USE_ADIOS1)
+  set(ADIOS_HAVE_ADIOS1 TRUE)
+endif()
+
+# Python
+if(ADIOS_USE_Python STREQUAL AUTO)
+  if(BUILD_SHARED_LIBS)
+    find_package(PythonLibs)
+    if(PYTHONLIBS_FOUND)
+      if(ADIOS_HAVE_MPI)
+        find_package(PythonModule COMPONENTS mpi4py mpi4py/mpi4py.h)
+        if(PythonModule_mpi4py_FOUND)
+          set(ADIOS_HAVE_Python TRUE)
+        endif()
+      else()
+        set(ADIOS_HAVE_Python TRUE)
+      endif()
+    endif()
+  endif()
+elseif(ADIOS_USE_Python)
+  set(ADIOS_HAVE_Python TRUE)
+endif()
diff --git a/examples/basics/globalArray/CMakeLists.txt b/examples/basics/globalArray/CMakeLists.txt
index 7a0af15e3..db0517543 100644
--- a/examples/basics/globalArray/CMakeLists.txt
+++ b/examples/basics/globalArray/CMakeLists.txt
@@ -4,14 +4,10 @@
 #------------------------------------------------------------------------------#
 
 add_executable(globalArray_write globalArray_write.cpp)
+target_link_libraries(globalArray_write adios2)
 
-if(ADIOS_USE_MPI)
+if(ADIOS_HAVE_MPI)
   find_package(MPI COMPONENTS C REQUIRED)
-
   target_include_directories(globalArray_write PRIVATE ${MPI_C_INCLUDE_PATH})
   target_link_libraries(globalArray_write ${MPI_C_LIBRARIES})
-
 endif()
-
-target_link_libraries(globalArray_write adios2)
-
diff --git a/examples/basics/joinedArray/CMakeLists.txt b/examples/basics/joinedArray/CMakeLists.txt
index c4fe97195..2ce60496e 100644
--- a/examples/basics/joinedArray/CMakeLists.txt
+++ b/examples/basics/joinedArray/CMakeLists.txt
@@ -4,14 +4,10 @@
 #------------------------------------------------------------------------------#
 
 add_executable(joinedArray_write joinedArray_write.cpp)
+target_link_libraries(joinedArray_write adios2)
 
-if(ADIOS_USE_MPI)
+if(ADIOS_HAVE_MPI)
   find_package(MPI COMPONENTS C REQUIRED)
-
   target_include_directories(joinedArray_write PRIVATE ${MPI_C_INCLUDE_PATH})
   target_link_libraries(joinedArray_write ${MPI_C_LIBRARIES})
-
 endif()
-
-target_link_libraries(joinedArray_write adios2)
-
diff --git a/examples/basics/localArray/CMakeLists.txt b/examples/basics/localArray/CMakeLists.txt
index 91077b8ce..d3d0edf14 100644
--- a/examples/basics/localArray/CMakeLists.txt
+++ b/examples/basics/localArray/CMakeLists.txt
@@ -4,14 +4,10 @@
 #------------------------------------------------------------------------------#
 
 add_executable(localArray_write localArray_write.cpp)
+target_link_libraries(localArray_write adios2)
 
-if(ADIOS_USE_MPI)
+if(ADIOS_HAVE_MPI)
   find_package(MPI COMPONENTS C REQUIRED)
-
   target_include_directories(localArray_write PRIVATE ${MPI_C_INCLUDE_PATH})
   target_link_libraries(localArray_write ${MPI_C_LIBRARIES})
-
 endif()
-
-target_link_libraries(localArray_write adios2)
-
diff --git a/examples/basics/values/CMakeLists.txt b/examples/basics/values/CMakeLists.txt
index b5894f894..b2aefa0e5 100644
--- a/examples/basics/values/CMakeLists.txt
+++ b/examples/basics/values/CMakeLists.txt
@@ -4,14 +4,10 @@
 #------------------------------------------------------------------------------#
 
 add_executable(values_write values_write.cpp)
+target_link_libraries(values_write adios2)
 
-if(ADIOS_USE_MPI)
+if(ADIOS_HAVE_MPI)
   find_package(MPI COMPONENTS C REQUIRED)
-
   target_include_directories(values_write PRIVATE ${MPI_C_INCLUDE_PATH})
   target_link_libraries(values_write ${MPI_C_LIBRARIES})
-
 endif()
-
-target_link_libraries(values_write adios2)
-
diff --git a/examples/experimental/CMakeLists.txt b/examples/experimental/CMakeLists.txt
index 5d46e776b..a02ded2b5 100644
--- a/examples/experimental/CMakeLists.txt
+++ b/examples/experimental/CMakeLists.txt
@@ -3,6 +3,6 @@
 # accompanying file Copyright.txt for details.
 #------------------------------------------------------------------------------#
 
-if(ADIOS_USE_ADIOS1)
+if(ADIOS_HAVE_ADIOS1)
   add_subdirectory(multistep)
 endif()
diff --git a/examples/experimental/multistep/CMakeLists.txt b/examples/experimental/multistep/CMakeLists.txt
index 9022ff3d8..1bafddf2c 100644
--- a/examples/experimental/multistep/CMakeLists.txt
+++ b/examples/experimental/multistep/CMakeLists.txt
@@ -6,8 +6,11 @@
 add_executable(writer_multistep writer_multistep.cpp)
 add_executable(reader_stepping reader_stepping.cpp)
 add_executable(reader_allsteps reader_allsteps.cpp)
+target_link_libraries(writer_multistep adios2)
+target_link_libraries(reader_stepping adios2)
+target_link_libraries(reader_allsteps adios2)
 
-if(ADIOS_USE_MPI)
+if(ADIOS_HAVE_MPI)
   find_package(MPI COMPONENTS C REQUIRED)
 
   target_include_directories(writer_multistep PRIVATE ${MPI_C_INCLUDE_PATH})
@@ -18,10 +21,4 @@ if(ADIOS_USE_MPI)
 
   target_include_directories(reader_allsteps PRIVATE ${MPI_C_INCLUDE_PATH})
   target_link_libraries(reader_allsteps ${MPI_C_LIBRARIES})
-
 endif()
-
-target_link_libraries(writer_multistep adios2)
-target_link_libraries(reader_stepping adios2)
-target_link_libraries(reader_allsteps adios2)
-
diff --git a/examples/heatTransfer/CMakeLists.txt b/examples/heatTransfer/CMakeLists.txt
index 09392deb5..9b1e0533d 100644
--- a/examples/heatTransfer/CMakeLists.txt
+++ b/examples/heatTransfer/CMakeLists.txt
@@ -4,7 +4,7 @@
 #------------------------------------------------------------------------------#
 
 
-if(ADIOS_USE_ADIOS1)
+if(ADIOS_HAVE_ADIOS1)
   add_subdirectory(write)
   add_subdirectory(read)
 endif()
diff --git a/examples/heatTransfer/read/CMakeLists.txt b/examples/heatTransfer/read/CMakeLists.txt
index 8527738fb..ddb8c0269 100644
--- a/examples/heatTransfer/read/CMakeLists.txt
+++ b/examples/heatTransfer/read/CMakeLists.txt
@@ -3,7 +3,7 @@
 # accompanying file Copyright.txt for details.
 #------------------------------------------------------------------------------#
 
-if(ADIOS_USE_MPI)
+if(ADIOS_HAVE_MPI)
 
     find_package(MPI COMPONENTS C REQUIRED)
     add_executable(heatTransfer_read_adios2 heatRead_adios2.cpp PrintData.cpp)
@@ -14,7 +14,7 @@ if(ADIOS_USE_MPI)
       adios2 ${MPI_C_LIBRARIES}
     )
     
-  if(ADIOS_USE_ADIOS1)
+  if(ADIOS_HAVE_ADIOS1)
     find_package(ADIOS1 REQUIRED)
 
     add_executable(heatTransfer_read_adios1 heatRead_adios1.cpp PrintData.cpp)
diff --git a/examples/heatTransfer/write/CMakeLists.txt b/examples/heatTransfer/write/CMakeLists.txt
index 5034755f7..877267940 100644
--- a/examples/heatTransfer/write/CMakeLists.txt
+++ b/examples/heatTransfer/write/CMakeLists.txt
@@ -3,7 +3,7 @@
 # accompanying file Copyright.txt for details.
 #------------------------------------------------------------------------------#
 
-if(ADIOS_USE_MPI)
+if(ADIOS_HAVE_MPI)
   find_package(MPI COMPONENTS C REQUIRED)
 
   add_executable(heatTransfer_write_adios2
@@ -17,7 +17,7 @@ if(ADIOS_USE_MPI)
   )
   target_link_libraries(heatTransfer_write_adios2 adios2 ${MPI_C_LIBRARIES})
 
-  if(ADIOS_USE_ADIOS1)
+  if(ADIOS_HAVE_ADIOS1)
     find_package(ADIOS1 REQUIRED)
     find_package(MPI COMPONENTS C REQUIRED)
 
@@ -35,7 +35,7 @@ if(ADIOS_USE_MPI)
     )
   endif()
 
-  if(ADIOS_USE_HDF5)
+  if(ADIOS_HAVE_HDF5)
     find_package(HDF5 REQUIRED)
     find_package(MPI COMPONENTS C REQUIRED)
 
@@ -54,7 +54,7 @@ if(ADIOS_USE_MPI)
   endif()
 
 
-  if(ADIOS_USE_HDF5)
+  if(ADIOS_HAVE_HDF5)
     find_package(HDF5 REQUIRED)
     find_package(MPI COMPONENTS C REQUIRED)
 
@@ -73,7 +73,7 @@ if(ADIOS_USE_MPI)
   endif()
 
 
-  if(ADIOS_USE_HDF5)
+  if(ADIOS_HAVE_HDF5)
      find_package(MPI COMPONENTS C REQUIRED)
 
      add_executable(heatTransfer_write_a2h5
diff --git a/examples/hello/CMakeLists.txt b/examples/hello/CMakeLists.txt
index 3795d3ab7..ae04105ea 100644
--- a/examples/hello/CMakeLists.txt
+++ b/examples/hello/CMakeLists.txt
@@ -7,15 +7,15 @@ add_subdirectory(bpWriter)
 add_subdirectory(bpTimeWriter)
 add_subdirectory(bpFlushWriter)
 
-if(ADIOS_USE_ADIOS1)
+if(ADIOS_HAVE_ADIOS1)
   add_subdirectory(adios1Writer)
 endif()
 
-if(ADIOS_USE_DataMan)
+if(ADIOS_HAVE_DataMan)
   add_subdirectory(datamanReader)
   add_subdirectory(datamanWriter)
 endif()
 
-if(ADIOS_USE_HDF5)
+if(ADIOS_HAVE_HDF5)
   add_subdirectory(hdf5Writer)
 endif()
diff --git a/examples/hello/adios1Writer/CMakeLists.txt b/examples/hello/adios1Writer/CMakeLists.txt
index f99964a73..61e73e20a 100644
--- a/examples/hello/adios1Writer/CMakeLists.txt
+++ b/examples/hello/adios1Writer/CMakeLists.txt
@@ -3,7 +3,7 @@
 # accompanying file Copyright.txt for details.
 #------------------------------------------------------------------------------#
 
-if(ADIOS_USE_MPI)
+if(ADIOS_HAVE_MPI)
   find_package(MPI COMPONENTS C REQUIRED)
 
   add_executable(hello_adios1Writer helloADIOS1Writer.cpp)
diff --git a/examples/hello/bpFlushWriter/CMakeLists.txt b/examples/hello/bpFlushWriter/CMakeLists.txt
index 2061028ed..74027445e 100644
--- a/examples/hello/bpFlushWriter/CMakeLists.txt
+++ b/examples/hello/bpFlushWriter/CMakeLists.txt
@@ -3,7 +3,7 @@
 # accompanying file Copyright.txt for details.
 #------------------------------------------------------------------------------#
 
-if(ADIOS_USE_MPI)
+if(ADIOS_HAVE_MPI)
   find_package(MPI COMPONENTS C REQUIRED)
 
   add_executable(hello_bpFlushWriter helloBPFlushWriter.cpp)
diff --git a/examples/hello/bpTimeWriter/CMakeLists.txt b/examples/hello/bpTimeWriter/CMakeLists.txt
index f95bd367c..3aad83273 100644
--- a/examples/hello/bpTimeWriter/CMakeLists.txt
+++ b/examples/hello/bpTimeWriter/CMakeLists.txt
@@ -3,7 +3,7 @@
 # accompanying file Copyright.txt for details.
 #------------------------------------------------------------------------------#
 
-if(ADIOS_USE_MPI)
+if(ADIOS_HAVE_MPI)
   find_package(MPI COMPONENTS C REQUIRED)
 
   add_executable(hello_bpTimeWriter helloBPTimeWriter.cpp)
diff --git a/examples/hello/bpWriter/CMakeLists.txt b/examples/hello/bpWriter/CMakeLists.txt
index 7dc8e40c2..56c647c17 100644
--- a/examples/hello/bpWriter/CMakeLists.txt
+++ b/examples/hello/bpWriter/CMakeLists.txt
@@ -3,7 +3,7 @@
 # accompanying file Copyright.txt for details.
 #------------------------------------------------------------------------------#
 
-if(ADIOS_USE_MPI)
+if(ADIOS_HAVE_MPI)
   find_package(MPI COMPONENTS C REQUIRED)
 
   add_executable(hello_bpWriter helloBPWriter.cpp)
diff --git a/examples/hello/datamanReader/CMakeLists.txt b/examples/hello/datamanReader/CMakeLists.txt
index 72b341844..cb54e206c 100644
--- a/examples/hello/datamanReader/CMakeLists.txt
+++ b/examples/hello/datamanReader/CMakeLists.txt
@@ -3,7 +3,7 @@
 # accompanying file Copyright.txt for details.
 #------------------------------------------------------------------------------#
 
-if(ADIOS_USE_MPI)
+if(ADIOS_HAVE_MPI)
   find_package(MPI COMPONENTS C REQUIRED)
 
   add_executable(hello_datamanReader helloDataManReader.cpp)
diff --git a/examples/hello/datamanWriter/CMakeLists.txt b/examples/hello/datamanWriter/CMakeLists.txt
index f18e0d1cf..001e8c389 100644
--- a/examples/hello/datamanWriter/CMakeLists.txt
+++ b/examples/hello/datamanWriter/CMakeLists.txt
@@ -3,7 +3,7 @@
 # accompanying file Copyright.txt for details.
 #------------------------------------------------------------------------------#
 
-if(ADIOS_USE_MPI)
+if(ADIOS_HAVE_MPI)
   find_package(MPI COMPONENTS C REQUIRED)
   
   add_executable(hello_datamanWriter helloDataManWriter.cpp)
diff --git a/examples/hello/hdf5Writer/CMakeLists.txt b/examples/hello/hdf5Writer/CMakeLists.txt
index 4c5a3c173..e0dc7a124 100644
--- a/examples/hello/hdf5Writer/CMakeLists.txt
+++ b/examples/hello/hdf5Writer/CMakeLists.txt
@@ -3,7 +3,7 @@
 # accompanying file Copyright.txt for details.
 #------------------------------------------------------------------------------#
 
-if(ADIOS_USE_MPI)
+if(ADIOS_HAVE_MPI)
   find_package(MPI COMPONENTS C REQUIRED)
 
   add_executable(hello_hdf5Writer helloHDF5Writer.cpp)
diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
index 45126c37b..2943c178a 100644
--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -3,7 +3,7 @@
 # accompanying file Copyright.txt for details.
 #------------------------------------------------------------------------------#
   
-if(ADIOS_USE_DataMan)
+if(ADIOS_HAVE_DataMan)
   add_subdirectory(dataman)
 endif()
 
diff --git a/source/adios2/ADIOSConfig.h.in b/source/adios2/ADIOSConfig.h.in
index 7f5726973..046923c2c 100644
--- a/source/adios2/ADIOSConfig.h.in
+++ b/source/adios2/ADIOSConfig.h.in
@@ -36,13 +36,13 @@
 /* CMake Option: ADIOS_USE_ADIOS1=ON */
 #cmakedefine ADIOS2_HAVE_ADIOS1
 
-/* CMake Option: ADIOS_USE_HDF5=On */
+/* CMake Option: ADIOS_USE_HDF5=ON */
 #cmakedefine ADIOS2_HAVE_HDF5
 
-/* CMake Option: ADIOS_USE_DataMan=TRUE */
+/* CMake Option: ADIOS_USE_DataMan=ON */
 #cmakedefine ADIOS2_HAVE_DATAMAN
 
-/* CMake Option: ADIOS_USE_Python=TRUE */
-#cmakedefine ADIOS2_HAVE_Python
+/* CMake Option: ADIOS_USE_Python=ON */
+#cmakedefine ADIOS2_HAVE_PYTHON
 
 #endif /* ADIOSCONFIG_H_ */
diff --git a/source/adios2/CMakeLists.txt b/source/adios2/CMakeLists.txt
index 004dd8136..f182f8bc4 100644
--- a/source/adios2/CMakeLists.txt
+++ b/source/adios2/CMakeLists.txt
@@ -54,7 +54,7 @@ target_include_directories(adios2
 find_package(Threads REQUIRED)
 target_link_libraries(adios2 PUBLIC ${CMAKE_THREAD_LIBS_INIT})
 
-if(ADIOS_USE_DataMan)
+if(ADIOS_HAVE_DataMan)
   target_sources(adios2 PRIVATE
     engine/dataman/DataManReader.cpp
     engine/dataman/DataManWriter.cpp
@@ -62,20 +62,20 @@ if(ADIOS_USE_DataMan)
   target_link_libraries(adios2 PRIVATE dataman)
 endif()
   
-if(ADIOS_USE_BZip2)
+if(ADIOS_HAVE_BZip2)
   find_package(BZip2 REQUIRED)
-  target_sources(adios2 PRIVATE transform/BZip2.cpp)
+  target_sources(adios2 PRIVATE transform/compression/BZip2.cpp)
   target_link_libraries(adios2 PRIVATE BZip2::BZip2)
 endif()
 
-if(ADIOS_USE_ZFP)
+if(ADIOS_HAVE_ZFP)
   find_package(ZFP REQUIRED)
   message("ADIOS ZFP support not yet implemented")
-#  target_sources(adios2 PRIVATE transform/ZFP.cpp)
+#  target_sources(adios2 PRIVATE transform/compression/ZFP.cpp)
 #  target_link_libraries(adios2 PRIVATE zfp::zfp)
 endif()
 
-if(ADIOS_USE_MPI)
+if(ADIOS_HAVE_MPI)
   find_package(MPI COMPONENTS C REQUIRED)
   target_include_directories(adios2 PUBLIC ${MPI_C_INCLUDE_PATH})
   target_link_libraries(adios2 PUBLIC ${MPI_C_LIBRARIES})
@@ -83,8 +83,8 @@ else()
   target_sources(adios2 PRIVATE mpidummy.cpp)
 endif()
 
-if(ADIOS_USE_ADIOS1)
-  if(ADIOS_USE_MPI)
+if(ADIOS_HAVE_ADIOS1)
+  if(ADIOS_HAVE_MPI)
     find_package(ADIOS1 1.12.0 REQUIRED)
   else()
     find_package(ADIOS1 1.12.0 COMPONENTS sequential REQUIRED)
@@ -100,14 +100,14 @@ if(ADIOS_USE_ADIOS1)
   target_link_libraries(adios2 PRIVATE adios1::adios)
 endif()
 
-if(ADIOS_USE_HDF5)
+if(ADIOS_HAVE_HDF5)
   find_package(HDF5 REQUIRED)
-  if(ADIOS_USE_MPI AND (NOT HDF5_IS_PARALLEL))
+  if(ADIOS_HAVE_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."
     )
-  elseif((NOT ADIOS_USE_MPI) AND HDF5_IS_PARALLEL)
+  elseif((NOT ADIOS_HAVE_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."
diff --git a/source/dataman/CMakeLists.txt b/source/dataman/CMakeLists.txt
index 1acb89487..a5d4b6ab8 100644
--- a/source/dataman/CMakeLists.txt
+++ b/source/dataman/CMakeLists.txt
@@ -3,6 +3,13 @@
 # accompanying file Copyright.txt for details.
 #------------------------------------------------------------------------------#
 
+if(NOT SHARED_LIBS_SUPPORTED)
+  message(FATAL_ERROR "DataMan requires shared library support")
+endif()
+if(MSVC)
+  message(FATAL_ERROR "DataMan is not currently compatible with MSVC")
+endif()
+
 set(dataman_targets)
 
 add_library(dataman
@@ -29,8 +36,7 @@ add_library(temporalman MODULE TemporalMan.h TemporalMan.cpp)
 target_link_libraries(temporalman PRIVATE dataman)
 list(APPEND dataman_targets temporalman)
 
-option(ADIOS_USE_DataMan_ZeroMQ "Enable ZeroMQ for DataMan" OFF)
-if(ADIOS_USE_DataMan_ZeroMQ)
+if(ADIOS_HAVE_ZeroMQ)
   find_package(ZeroMQ REQUIRED)
 
   add_library(zmqman MODULE
@@ -49,8 +55,7 @@ if(ADIOS_USE_DataMan_ZeroMQ)
 endif()
 
 
-set(ADIOS_USE_DataMan_ZFP ${ADIOS_USE_ZFP} CACHE INTERNAL "Enable ZFP for DataMan" FORCE)
-if(ADIOS_USE_DataMan_ZFP)
+if(ADIOS_HAVE_ZFP)
   find_package(ZFP REQUIRED)
 
   add_library(zfpman MODULE ZfpMan.h ZfpMan.cpp)
diff --git a/testing/adios2/engine/CMakeLists.txt b/testing/adios2/engine/CMakeLists.txt
index 8dfbfda2e..0b87d3cb2 100644
--- a/testing/adios2/engine/CMakeLists.txt
+++ b/testing/adios2/engine/CMakeLists.txt
@@ -5,18 +5,18 @@
 
 # We currently require ADIOS1 to test ADIOS v2 bp functionality since the read
 # API is not available yet
-if(ADIOS_USE_ADIOS1)
+if(ADIOS_HAVE_ADIOS1)
   add_subdirectory(bp)
 endif()
 
-if(ADIOS_USE_ADIOS1)
+if(ADIOS_HAVE_ADIOS1)
   add_subdirectory(adios1)
 endif()
 
-if(ADIOS_USE_HDF5)
+if(ADIOS_HAVE_HDF5)
   add_subdirectory(hdf5)
 endif()
 
-if(ADIOS_USE_DataMan)
+if(ADIOS_HAVE_DataMan)
   add_subdirectory(dataman)
 endif()
diff --git a/testing/adios2/engine/adios1/CMakeLists.txt b/testing/adios2/engine/adios1/CMakeLists.txt
index 35fd48db9..43c743504 100644
--- a/testing/adios2/engine/adios1/CMakeLists.txt
+++ b/testing/adios2/engine/adios1/CMakeLists.txt
@@ -4,7 +4,7 @@
 #------------------------------------------------------------------------------#
 
 # MPI versions of the test are not properly implemented at the moment
-if(NOT ADIOS_USE_MPI)
+if(NOT ADIOS_HAVE_MPI)
   find_package(ADIOS1 COMPONENTS sequential REQUIRED)
 
   add_executable(TestADIOS1WriteRead TestADIOS1WriteRead.cpp)
diff --git a/testing/adios2/engine/bp/CMakeLists.txt b/testing/adios2/engine/bp/CMakeLists.txt
index 270f0171c..ff6ac251d 100644
--- a/testing/adios2/engine/bp/CMakeLists.txt
+++ b/testing/adios2/engine/bp/CMakeLists.txt
@@ -4,7 +4,7 @@
 #------------------------------------------------------------------------------#
 
 # MPI versions of the test are not properly implemented at the moment
-if(NOT ADIOS_USE_MPI)
+if(NOT ADIOS_HAVE_MPI)
   find_package(ADIOS1 COMPONENTS sequential REQUIRED)
 
   add_executable(TestBPWriteRead TestBPWriteRead.cpp)
diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt
index 3e5b0fdb9..62502eeab 100644
--- a/thirdparty/CMakeLists.txt
+++ b/thirdparty/CMakeLists.txt
@@ -5,6 +5,6 @@ if(BUILD_TESTING)
   add_subdirectory(GTest)
 endif()
 
-if(ADIOS_USE_Python)
+if(ADIOS_HAVE_Python)
   add_subdirectory(pybind11)
 endif()
-- 
GitLab