From: Drew Parsons <dparsons@debian.org>
Date: Tue, 10 Sep 2024 14:47:22 +0200
Subject: skip plugin engines if the plugin is not built

only build plugins/engine if ADIOS2_add_examples_plugins_engine is set
(i.e. skip engines, since the plugin is not built)
---
 examples/basics/globalArrayND/CMakeLists.txt         | 4 +++-
 examples/basics/joinedArray/CMakeLists.txt           | 4 +++-
 examples/basics/localArray/CMakeLists.txt            | 4 +++-
 examples/basics/queryWorker/CMakeLists.txt           | 4 +++-
 examples/basics/values/CMakeLists.txt                | 4 +++-
 examples/basics/variablesShapes/CMakeLists.txt       | 4 +++-
 examples/hello/bpAttributeWriteRead/CMakeLists.txt   | 4 +++-
 examples/hello/bpFWriteCRead/CMakeLists.txt          | 4 +++-
 examples/hello/bpFlushWriter/CMakeLists.txt          | 4 +++-
 examples/hello/bpOperatorSZWriter/CMakeLists.txt     | 4 +++-
 examples/hello/bpReader/CMakeLists.txt               | 4 +++-
 examples/hello/bpStepsWriteRead/CMakeLists.txt       | 4 +++-
 examples/hello/bpStepsWriteReadKokkos/CMakeLists.txt | 4 +++-
 examples/hello/bpWriter/CMakeLists.txt               | 4 +++-
 examples/hello/datamanKokkos/CMakeLists.txt          | 4 +++-
 examples/hello/datamanReader/CMakeLists.txt          | 4 +++-
 examples/hello/datamanWriter/CMakeLists.txt          | 4 +++-
 examples/hello/dataspacesReader/CMakeLists.txt       | 4 +++-
 examples/hello/dataspacesWriter/CMakeLists.txt       | 4 +++-
 examples/hello/hdf5Reader/CMakeLists.txt             | 4 +++-
 examples/hello/hdf5SubFile/CMakeLists.txt            | 4 +++-
 examples/hello/hdf5Writer/CMakeLists.txt             | 4 +++-
 examples/hello/helloWorld/CMakeLists.txt             | 4 +++-
 examples/hello/inlineReaderWriter/CMakeLists.txt     | 4 +++-
 examples/hello/skeleton/CMakeLists.txt               | 4 +++-
 examples/hello/sstReader/CMakeLists.txt              | 4 +++-
 examples/hello/sstWriter/CMakeLists.txt              | 4 +++-
 examples/plugins/CMakeLists.txt                      | 4 +++-
 examples/useCases/insituGlobalArrays/CMakeLists.txt  | 4 +++-
 29 files changed, 87 insertions(+), 29 deletions(-)

diff --git a/examples/basics/globalArrayND/CMakeLists.txt b/examples/basics/globalArrayND/CMakeLists.txt
index f1d131c..c2106ed 100644
--- a/examples/basics/globalArrayND/CMakeLists.txt
+++ b/examples/basics/globalArrayND/CMakeLists.txt
@@ -9,7 +9,9 @@ project(ADIOS2BasicsGlobalArrayNDExample)
 if(NOT TARGET adios2_core)
   set(_components CXX)
 
-  find_package(MPI COMPONENTS C)
+  if(ADIOS2_HAVE_MPI)
+    find_package(MPI COMPONENTS C)
+  endif()
   if(MPI_FOUND)
     # Workaround for various MPI implementations forcing the link of C++ bindings
     add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX)
diff --git a/examples/basics/joinedArray/CMakeLists.txt b/examples/basics/joinedArray/CMakeLists.txt
index a342d75..5cc92a0 100644
--- a/examples/basics/joinedArray/CMakeLists.txt
+++ b/examples/basics/joinedArray/CMakeLists.txt
@@ -9,7 +9,9 @@ project(ADIOS2BasicsJoinedArrayExample)
 if(NOT TARGET adios2_core)
   set(_components CXX)
 
-  find_package(MPI COMPONENTS C)
+  if(ADIOS2_HAVE_MPI)
+    find_package(MPI COMPONENTS C)
+  endif()
   if(MPI_FOUND)
     # Workaround for various MPI implementations forcing the link of C++ bindings
     add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX)
diff --git a/examples/basics/localArray/CMakeLists.txt b/examples/basics/localArray/CMakeLists.txt
index a43a615..e8814c9 100644
--- a/examples/basics/localArray/CMakeLists.txt
+++ b/examples/basics/localArray/CMakeLists.txt
@@ -9,7 +9,9 @@ project(ADIOS2BasicsLocalArrayExample)
 if(NOT TARGET adios2_core)
   set(_components CXX)
 
-  find_package(MPI COMPONENTS C)
+  if(ADIOS2_HAVE_MPI)
+    find_package(MPI COMPONENTS C)
+  endif()
   if(MPI_FOUND)
     # Workaround for various MPI implementations forcing the link of C++ bindings
     add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX)
diff --git a/examples/basics/queryWorker/CMakeLists.txt b/examples/basics/queryWorker/CMakeLists.txt
index 7cce9e5..10e4c2e 100644
--- a/examples/basics/queryWorker/CMakeLists.txt
+++ b/examples/basics/queryWorker/CMakeLists.txt
@@ -9,7 +9,9 @@ project(ADIOS2BasicsQueryWorkerExample)
 if(NOT TARGET adios2_core)
   set(_components CXX)
 
-  find_package(MPI COMPONENTS C)
+  if(ADIOS2_HAVE_MPI)
+    find_package(MPI COMPONENTS C)
+  endif()
   if(MPI_FOUND)
     # Workaround for various MPI implementations forcing the link of C++ bindings
     add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX)
diff --git a/examples/basics/values/CMakeLists.txt b/examples/basics/values/CMakeLists.txt
index f37b7da..c272507 100644
--- a/examples/basics/values/CMakeLists.txt
+++ b/examples/basics/values/CMakeLists.txt
@@ -18,7 +18,9 @@ if(NOT TARGET adios2_core)
     list(APPEND _components Fortran)
   endif()
 
-  find_package(MPI COMPONENTS ${_components})
+  if(ADIOS2_HAVE_MPI)
+    find_package(MPI COMPONENTS ${_components})
+  endif()
   if(MPI_FOUND)
     # Workaround for various MPI implementations forcing the link of C++ bindings
     add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX)
diff --git a/examples/basics/variablesShapes/CMakeLists.txt b/examples/basics/variablesShapes/CMakeLists.txt
index 2dbd92f..4a00e5e 100644
--- a/examples/basics/variablesShapes/CMakeLists.txt
+++ b/examples/basics/variablesShapes/CMakeLists.txt
@@ -9,7 +9,9 @@ project(ADIOS2BasicsVariablesShapesExample)
 if(NOT TARGET adios2_core)
   set(_components CXX)
 
-  find_package(MPI COMPONENTS C)
+  if(ADIOS2_HAVE_MPI)
+    find_package(MPI COMPONENTS C)
+  endif()
   if(MPI_FOUND)
     # Workaround for various MPI implementations forcing the link of C++ bindings
     add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX)
diff --git a/examples/hello/bpAttributeWriteRead/CMakeLists.txt b/examples/hello/bpAttributeWriteRead/CMakeLists.txt
index cfc777f..0d3e42a 100644
--- a/examples/hello/bpAttributeWriteRead/CMakeLists.txt
+++ b/examples/hello/bpAttributeWriteRead/CMakeLists.txt
@@ -9,7 +9,9 @@ project(ADIOS2HelloBPAttributeWriteReadExample)
 if(NOT TARGET adios2_core)
   set(_components CXX)
 
-  find_package(MPI COMPONENTS C)
+  if(ADIOS2_HAVE_MPI)
+    find_package(MPI COMPONENTS C)
+  endif()
   if(MPI_FOUND)
     # Workaround for various MPI implementations forcing the link of C++ bindings
     add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX)
diff --git a/examples/hello/bpFWriteCRead/CMakeLists.txt b/examples/hello/bpFWriteCRead/CMakeLists.txt
index 759d691..f97539a 100644
--- a/examples/hello/bpFWriteCRead/CMakeLists.txt
+++ b/examples/hello/bpFWriteCRead/CMakeLists.txt
@@ -18,7 +18,9 @@ if(NOT TARGET adios2_core)
     list(APPEND _components Fortran)
   endif()
 
-  find_package(MPI COMPONENTS ${_components})
+  if(ADIOS2_HAVE_MPI)
+    find_package(MPI COMPONENTS ${_components})
+  endif()
   if(MPI_FOUND)
     # Workaround for various MPI implementations forcing the link of C++ bindings
     add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX)
diff --git a/examples/hello/bpFlushWriter/CMakeLists.txt b/examples/hello/bpFlushWriter/CMakeLists.txt
index 61c78eb..515e7e3 100644
--- a/examples/hello/bpFlushWriter/CMakeLists.txt
+++ b/examples/hello/bpFlushWriter/CMakeLists.txt
@@ -9,7 +9,9 @@ project(ADIOS2HelloBPFlushWriterExample)
 if(NOT TARGET adios2_core)
   set(_components CXX)
 
-  find_package(MPI COMPONENTS C)
+  if(ADIOS2_HAVE_MPI)
+    find_package(MPI COMPONENTS C)
+  endif()
   if(MPI_FOUND)
     # Workaround for various MPI implementations forcing the link of C++ bindings
     add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX)
diff --git a/examples/hello/bpOperatorSZWriter/CMakeLists.txt b/examples/hello/bpOperatorSZWriter/CMakeLists.txt
index c54aadf..3dcbd01 100644
--- a/examples/hello/bpOperatorSZWriter/CMakeLists.txt
+++ b/examples/hello/bpOperatorSZWriter/CMakeLists.txt
@@ -9,7 +9,9 @@ project(ADIOS2HelloBPOperatorSZWriterExample)
 if(NOT TARGET adios2_core)
   set(_components C)
 
-  find_package(MPI COMPONENTS ${_components})
+  if(ADIOS2_HAVE_MPI)
+    find_package(MPI COMPONENTS ${_components})
+  endif()
   if(MPI_FOUND)
     # Workaround for various MPI implementations forcing the link of C++ bindings
     add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX)
diff --git a/examples/hello/bpReader/CMakeLists.txt b/examples/hello/bpReader/CMakeLists.txt
index 47a5140..8df5843 100644
--- a/examples/hello/bpReader/CMakeLists.txt
+++ b/examples/hello/bpReader/CMakeLists.txt
@@ -18,7 +18,9 @@ if(NOT TARGET adios2::cxx11)
     list(APPEND _components Fortran)
   endif()
 
-  find_package(MPI COMPONENTS ${_components})
+  if(ADIOS2_HAVE_MPI)
+    find_package(MPI COMPONENTS ${_components})
+  endif()
   if(MPI_FOUND)
     # Workaround for various MPI implementations forcing the link of C++ bindings
     add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX)
diff --git a/examples/hello/bpStepsWriteRead/CMakeLists.txt b/examples/hello/bpStepsWriteRead/CMakeLists.txt
index 6acf969..2ed4aa4 100644
--- a/examples/hello/bpStepsWriteRead/CMakeLists.txt
+++ b/examples/hello/bpStepsWriteRead/CMakeLists.txt
@@ -9,7 +9,9 @@ project(ADIOS2HelloBPStepsWriteReadExample)
 if(NOT TARGET adios2_core)
   set(_components CXX)
 
-  find_package(MPI COMPONENTS C)
+  if(ADIOS2_HAVE_MPI)
+    find_package(MPI COMPONENTS C)
+  endif()
   if(MPI_FOUND)
     # Workaround for various MPI implementations forcing the link of C++ bindings
     add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX)
diff --git a/examples/hello/bpStepsWriteReadKokkos/CMakeLists.txt b/examples/hello/bpStepsWriteReadKokkos/CMakeLists.txt
index 6f0025e..fd451c7 100644
--- a/examples/hello/bpStepsWriteReadKokkos/CMakeLists.txt
+++ b/examples/hello/bpStepsWriteReadKokkos/CMakeLists.txt
@@ -27,7 +27,9 @@ if(NOT TARGET adios2_core)
     list(APPEND _components Fortran)
   endif()
 
-  find_package(MPI QUIET COMPONENTS ${_components})
+  if(ADIOS2_HAVE_MPI)
+    find_package(MPI QUIET COMPONENTS ${_components})
+  endif()
   if(MPI_FOUND)
     # Workaround for various MPI implementations forcing the link of C++ bindings
     add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX)
diff --git a/examples/hello/bpWriter/CMakeLists.txt b/examples/hello/bpWriter/CMakeLists.txt
index 9eb0fbf..9f89470 100644
--- a/examples/hello/bpWriter/CMakeLists.txt
+++ b/examples/hello/bpWriter/CMakeLists.txt
@@ -18,7 +18,9 @@ if(NOT TARGET adios2_core)
     list(APPEND _components Fortran)
   endif()
 
-  find_package(MPI COMPONENTS ${_components})
+  if(ADIOS2_HAVE_MPI)
+    find_package(MPI COMPONENTS ${_components})
+  endif()
   if(MPI_FOUND)
     # Workaround for various MPI implementations forcing the link of C++ bindings
     add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX)
diff --git a/examples/hello/datamanKokkos/CMakeLists.txt b/examples/hello/datamanKokkos/CMakeLists.txt
index 9bbe1a2..1feaad3 100644
--- a/examples/hello/datamanKokkos/CMakeLists.txt
+++ b/examples/hello/datamanKokkos/CMakeLists.txt
@@ -9,7 +9,9 @@ project(ADIOS2HelloDataManKokkosExample)
 if(NOT TARGET adios2_core)
   set(_components CXX)
 
-  find_package(MPI COMPONENTS C)
+  if(ADIOS2_HAVE_MPI)
+    find_package(MPI COMPONENTS C)
+  endif()
   if(MPI_FOUND)
     # Workaround for various MPI implementations forcing the link of C++ bindings
     add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX)
diff --git a/examples/hello/datamanReader/CMakeLists.txt b/examples/hello/datamanReader/CMakeLists.txt
index 656bace..fc63022 100644
--- a/examples/hello/datamanReader/CMakeLists.txt
+++ b/examples/hello/datamanReader/CMakeLists.txt
@@ -9,7 +9,9 @@ project(ADIOS2HelloDataManReaderExample)
 if(NOT TARGET adios2_core)
   set(_components CXX)
 
-  find_package(MPI COMPONENTS C)
+  if(ADIOS2_HAVE_MPI)
+    find_package(MPI COMPONENTS C)
+  endif()
   if(MPI_FOUND)
     # Workaround for various MPI implementations forcing the link of C++ bindings
     add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX)
diff --git a/examples/hello/datamanWriter/CMakeLists.txt b/examples/hello/datamanWriter/CMakeLists.txt
index 0bc0789..b7564d5 100644
--- a/examples/hello/datamanWriter/CMakeLists.txt
+++ b/examples/hello/datamanWriter/CMakeLists.txt
@@ -9,7 +9,9 @@ project(ADIOS2HelloDataManWriterExample)
 if(NOT TARGET adios2_core)
   set(_components CXX)
 
-  find_package(MPI COMPONENTS C)
+  if(ADIOS2_HAVE_MPI)
+    find_package(MPI COMPONENTS C)
+  endif()
   if(MPI_FOUND)
     # Workaround for various MPI implementations forcing the link of C++ bindings
     add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX)
diff --git a/examples/hello/dataspacesReader/CMakeLists.txt b/examples/hello/dataspacesReader/CMakeLists.txt
index 11e8e3f..95eb732 100644
--- a/examples/hello/dataspacesReader/CMakeLists.txt
+++ b/examples/hello/dataspacesReader/CMakeLists.txt
@@ -9,7 +9,9 @@ project(ADIOS2HelloDataSpacesReaderExample)
 if(NOT TARGET adios2_core)
   set(_components CXX)
 
-  find_package(MPI COMPONENTS C)
+  if(ADIOS2_HAVE_MPI)
+    find_package(MPI COMPONENTS C)
+  endif()
   if(MPI_FOUND)
     # Workaround for various MPI implementations forcing the link of C++ bindings
     add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX)
diff --git a/examples/hello/dataspacesWriter/CMakeLists.txt b/examples/hello/dataspacesWriter/CMakeLists.txt
index 32a1bb4..2a56864 100644
--- a/examples/hello/dataspacesWriter/CMakeLists.txt
+++ b/examples/hello/dataspacesWriter/CMakeLists.txt
@@ -9,7 +9,9 @@ project(ADIOS2HelloDataSpacesWriterExample)
 if(NOT TARGET adios2_core)
   set(_components CXX)
 
-  find_package(MPI COMPONENTS C)
+  if(ADIOS2_HAVE_MPI)
+    find_package(MPI COMPONENTS C)
+  endif()
   if(MPI_FOUND)
     # Workaround for various MPI implementations forcing the link of C++ bindings
     add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX)
diff --git a/examples/hello/hdf5Reader/CMakeLists.txt b/examples/hello/hdf5Reader/CMakeLists.txt
index ebfcb9a..1ed6b40 100644
--- a/examples/hello/hdf5Reader/CMakeLists.txt
+++ b/examples/hello/hdf5Reader/CMakeLists.txt
@@ -9,7 +9,9 @@ project(ADIOS2HelloHDF5ReaderExample)
 if(NOT TARGET adios2_core)
   set(_components CXX)
 
-  find_package(MPI COMPONENTS C)
+  if(ADIOS2_HAVE_MPI)
+    find_package(MPI COMPONENTS C)
+  endif()
   if(MPI_FOUND)
     # Workaround for various MPI implementations forcing the link of C++ bindings
     add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX)
diff --git a/examples/hello/hdf5SubFile/CMakeLists.txt b/examples/hello/hdf5SubFile/CMakeLists.txt
index 81e494f..ce1d5e7 100644
--- a/examples/hello/hdf5SubFile/CMakeLists.txt
+++ b/examples/hello/hdf5SubFile/CMakeLists.txt
@@ -9,7 +9,9 @@ project(HelloHDF5SubFileExample)
 if(NOT TARGET adios2_core)
   set(_components CXX)
 
-  find_package(MPI COMPONENTS C)
+  if(ADIOS2_HAVE_MPI)
+    find_package(MPI COMPONENTS C)
+  endif()
   if(MPI_FOUND)
     # Workaround for various MPI implementations forcing the link of C++ bindings
     add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX)
diff --git a/examples/hello/hdf5Writer/CMakeLists.txt b/examples/hello/hdf5Writer/CMakeLists.txt
index b1fd2bc..43d7c43 100644
--- a/examples/hello/hdf5Writer/CMakeLists.txt
+++ b/examples/hello/hdf5Writer/CMakeLists.txt
@@ -9,7 +9,9 @@ project(ADIOS2HelloHDF5WriterExample)
 if(NOT TARGET adios2_core)
   set(_components CXX)
 
-  find_package(MPI COMPONENTS C)
+  if(ADIOS2_HAVE_MPI)
+    find_package(MPI COMPONENTS C)
+  endif()
   if(MPI_FOUND)
     # Workaround for various MPI implementations forcing the link of C++ bindings
     add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX)
diff --git a/examples/hello/helloWorld/CMakeLists.txt b/examples/hello/helloWorld/CMakeLists.txt
index 416d0d5..f0be0eb 100644
--- a/examples/hello/helloWorld/CMakeLists.txt
+++ b/examples/hello/helloWorld/CMakeLists.txt
@@ -9,7 +9,9 @@ project(ADIOS2HelloHelloWorldExample)
 if(NOT TARGET adios2_core)
   set(_components C CXX)
 
-  find_package(MPI COMPONENTS C)
+  if(ADIOS2_HAVE_MPI)
+    find_package(MPI COMPONENTS C)
+  endif()
   if(MPI_FOUND)
     # Workaround for various MPI implementations forcing the link of C++ bindings
     add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX)
diff --git a/examples/hello/inlineReaderWriter/CMakeLists.txt b/examples/hello/inlineReaderWriter/CMakeLists.txt
index cf76d4d..355f388 100644
--- a/examples/hello/inlineReaderWriter/CMakeLists.txt
+++ b/examples/hello/inlineReaderWriter/CMakeLists.txt
@@ -9,7 +9,9 @@ project(ADIOS2HelloInlineReaderWriterExample)
 if(NOT TARGET adios2_core)
   set(_components CXX)
 
-  find_package(MPI COMPONENTS C)
+  if(ADIOS2_HAVE_MPI)
+    find_package(MPI COMPONENTS C)
+  endif()
   if(MPI_FOUND)
     # Workaround for various MPI implementations forcing the link of C++ bindings
     add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX)
diff --git a/examples/hello/skeleton/CMakeLists.txt b/examples/hello/skeleton/CMakeLists.txt
index 4c6ead5..6911fde 100644
--- a/examples/hello/skeleton/CMakeLists.txt
+++ b/examples/hello/skeleton/CMakeLists.txt
@@ -9,7 +9,9 @@ project(ADIOS2HelloSkeletonExample)
 if(NOT TARGET adios2_core)
   set(_components CXX)
 
-  find_package(MPI COMPONENTS C)
+  if(ADIOS2_HAVE_MPI)
+    find_package(MPI COMPONENTS C)
+  endif()
   if(MPI_FOUND)
     # Workaround for various MPI implementations forcing the link of C++ bindings
     add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX)
diff --git a/examples/hello/sstReader/CMakeLists.txt b/examples/hello/sstReader/CMakeLists.txt
index be46aab..1601c47 100644
--- a/examples/hello/sstReader/CMakeLists.txt
+++ b/examples/hello/sstReader/CMakeLists.txt
@@ -9,7 +9,9 @@ project(ADIOS2HelloSstReaderExample)
 if(NOT TARGET adios2_core)
   set(_components CXX)
 
-  find_package(MPI COMPONENTS C)
+  if(ADIOS2_HAVE_MPI)
+    find_package(MPI COMPONENTS C)
+  endif()
   if(MPI_FOUND)
     # Workaround for various MPI implementations forcing the link of C++ bindings
     add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX)
diff --git a/examples/hello/sstWriter/CMakeLists.txt b/examples/hello/sstWriter/CMakeLists.txt
index 3636ddd..5ff30a6 100644
--- a/examples/hello/sstWriter/CMakeLists.txt
+++ b/examples/hello/sstWriter/CMakeLists.txt
@@ -9,7 +9,9 @@ project(ADIOS2HelloSstWriterExample)
 if(NOT TARGET adios2_core)
   set(_components CXX)
 
-  find_package(MPI COMPONENTS C)
+  if(ADIOS2_HAVE_MPI)
+    find_package(MPI COMPONENTS C)
+  endif()
   if(MPI_FOUND)
     # Workaround for various MPI implementations forcing the link of C++ bindings
     add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX)
diff --git a/examples/plugins/CMakeLists.txt b/examples/plugins/CMakeLists.txt
index 013d696..0553ff2 100644
--- a/examples/plugins/CMakeLists.txt
+++ b/examples/plugins/CMakeLists.txt
@@ -3,7 +3,9 @@
 # accompanying file Copyright.txt for details.
 #------------------------------------------------------------------------------#
 
-add_subdirectory(engine)
+if(ADIOS2_add_examples_plugins_engine)
+  add_subdirectory(engine)
+endif()
 if(ADIOS2_HAVE_Sodium)
   add_subdirectory(operator)
 endif()
diff --git a/examples/useCases/insituGlobalArrays/CMakeLists.txt b/examples/useCases/insituGlobalArrays/CMakeLists.txt
index 281c687..bb6b7ee 100644
--- a/examples/useCases/insituGlobalArrays/CMakeLists.txt
+++ b/examples/useCases/insituGlobalArrays/CMakeLists.txt
@@ -9,7 +9,9 @@ project(ADIOS2UseCasesInSituGlobalArraysExample)
 if(NOT TARGET adios2_core)
   set(_components CXX)
 
-  find_package(MPI COMPONENTS C)
+  if(ADIOS2_HAVE_MPI)
+    find_package(MPI COMPONENTS C)
+  endif()
   if(MPI_FOUND)
     # Workaround for various MPI implementations forcing the link of C++ bindings
     add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX)
