From f3d19543cd301e8c263a123968abe066fa6f9dd2 Mon Sep 17 00:00:00 2001
From: Dominic Kempf <dominic.kempf@iwr.uni-heidelberg.de>
Date: Mon, 16 Apr 2018 13:14:22 +0200
Subject: [PATCH] Guard all usages of opcounting in CMake

---
 applications/knl/poisson_dg/knl_poisson_dg.mini        |  1 +
 .../knl/poisson_dg_tensor/knl_poisson_dg_tensor.mini   |  1 +
 applications/poisson_dg/poisson_dg.mini                |  1 +
 applications/poisson_dg_tensor/poisson_dg_tensor.mini  |  1 +
 applications/stokes_dg/stokes_dg.mini                  |  1 +
 test/poisson/CMakeLists.txt                            | 10 ++++++----
 6 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/applications/knl/poisson_dg/knl_poisson_dg.mini b/applications/knl/poisson_dg/knl_poisson_dg.mini
index ba2f345f..41755b7e 100644
--- a/applications/knl/poisson_dg/knl_poisson_dg.mini
+++ b/applications/knl/poisson_dg/knl_poisson_dg.mini
@@ -3,6 +3,7 @@ __exec_suffix = deg{formcompiler.ufl_variants.degree}_{opcount_suffix}_level{for
 
 opcount_suffix = opcount, nonopcount | expand opcount
 {opcount_suffix} == opcount and {formcompiler.instrumentation_level} != 4 | exclude
+dune-opcounter_FOUND, 1 | expand opcount | cmake_guard
 
 # Calculate the size of the grid to equlibritate it to 100 MB/rank
 # Input parameters
diff --git a/applications/knl/poisson_dg_tensor/knl_poisson_dg_tensor.mini b/applications/knl/poisson_dg_tensor/knl_poisson_dg_tensor.mini
index 4f3f5826..9d87f7ee 100644
--- a/applications/knl/poisson_dg_tensor/knl_poisson_dg_tensor.mini
+++ b/applications/knl/poisson_dg_tensor/knl_poisson_dg_tensor.mini
@@ -3,6 +3,7 @@ __exec_suffix = deg{formcompiler.ufl_variants.degree}_{opcount_suffix}_level{for
 
 opcount_suffix = opcount, nonopcount | expand opcount
 {opcount_suffix} == opcount and {formcompiler.instrumentation_level} != 4 | exclude
+dune-opcounter_FOUND, 1 | expand opcount | cmake_guard
 
 # Calculate the size of the grid to equlibritate it to 100 MB/rank
 # Input parameters
diff --git a/applications/poisson_dg/poisson_dg.mini b/applications/poisson_dg/poisson_dg.mini
index 7e65a481..d031d823 100644
--- a/applications/poisson_dg/poisson_dg.mini
+++ b/applications/poisson_dg/poisson_dg.mini
@@ -3,6 +3,7 @@ __exec_suffix = deg{formcompiler.ufl_variants.degree}_{opcount_suffix}_level{for
 
 opcount_suffix = opcount, nonopcount | expand opcount
 {opcount_suffix} == opcount and {formcompiler.instrumentation_level} != 4 | exclude
+dune-opcounter_FOUND, 1 | expand opcount | cmake_guard
 
 # Calculate the size of the grid to equlibritate it to 100 MB/rank
 # Input parameters
diff --git a/applications/poisson_dg_tensor/poisson_dg_tensor.mini b/applications/poisson_dg_tensor/poisson_dg_tensor.mini
index 4e7ac555..a5738a46 100644
--- a/applications/poisson_dg_tensor/poisson_dg_tensor.mini
+++ b/applications/poisson_dg_tensor/poisson_dg_tensor.mini
@@ -3,6 +3,7 @@ __exec_suffix = deg{formcompiler.ufl_variants.degree}_{opcount_suffix}_level{for
 
 opcount_suffix = opcount, nonopcount | expand opcount
 {opcount_suffix} == opcount and {formcompiler.instrumentation_level} != 4 | exclude
+dune-opcounter_FOUND, 1 | expand opcount | cmake_guard
 
 # Calculate the size of the grid to equlibritate it to 100 MB/rank
 # Input parameters
diff --git a/applications/stokes_dg/stokes_dg.mini b/applications/stokes_dg/stokes_dg.mini
index a80567f9..6160ced2 100644
--- a/applications/stokes_dg/stokes_dg.mini
+++ b/applications/stokes_dg/stokes_dg.mini
@@ -3,6 +3,7 @@ __exec_suffix = deg{formcompiler.ufl_variants.v_degree}_{opcount_suffix}_level{f
 
 opcount_suffix = opcount, nonopcount | expand opcount
 {opcount_suffix} == opcount and {formcompiler.instrumentation_level} != 4 | exclude
+dune-opcounter_FOUND, 1 | expand opcount | cmake_guard
 
 # Calculate the size of the grid to equlibritate it to 100 MB/rank
 # Input parameters
diff --git a/test/poisson/CMakeLists.txt b/test/poisson/CMakeLists.txt
index a05cbe8c..0a4f9897 100644
--- a/test/poisson/CMakeLists.txt
+++ b/test/poisson/CMakeLists.txt
@@ -44,10 +44,12 @@ dune_add_formcompiler_system_test(UFLFILE poisson_dg.ufl
                                   )
 
 # 8. Poisson with operator counting
-dune_add_formcompiler_system_test(UFLFILE opcount_poisson_dg.ufl
-                                  BASENAME opcount_poisson_dg_symdiff
-                                  INIFILE opcount_poisson_dg_symdiff.mini
-                                  )
+if(dune-opcounter_FOUND)
+  dune_add_formcompiler_system_test(UFLFILE opcount_poisson_dg.ufl
+                                    BASENAME opcount_poisson_dg_symdiff
+                                    INIFILE opcount_poisson_dg_symdiff.mini
+                                    )
+endif()
 
 # 9. Poisson Test Case: DG quadrilaterals
 dune_add_formcompiler_system_test(UFLFILE poisson_dg_quadrilateral.ufl
-- 
GitLab