diff --git a/src/Solvers/petsc_solver_AMG_report.hpp b/src/Solvers/petsc_solver_AMG_report.hpp
index 1ae20ac9e399c1916e8c327481c2ed9c02adeb54..eb5774e62b3c2ed356c2cf2264db206da0cb911a 100644
--- a/src/Solvers/petsc_solver_AMG_report.hpp
+++ b/src/Solvers/petsc_solver_AMG_report.hpp
@@ -8,6 +8,10 @@
 #ifndef OPENFPM_NUMERICS_SRC_SOLVERS_PETSC_SOLVER_AMG_REPORT_HPP_
 #define OPENFPM_NUMERICS_SRC_SOLVERS_PETSC_SOLVER_AMG_REPORT_HPP_
 
+#include "config.h"
+
+#ifdef HAVE_PETSC
+
 #include <fstream>
 #include "Solvers/petsc_solver.hpp"
 
@@ -585,5 +589,6 @@ public:
 	}
 };
 
+#endif
 
 #endif /* OPENFPM_NUMERICS_SRC_SOLVERS_PETSC_SOLVER_AMG_REPORT_HPP_ */
diff --git a/src/Solvers/petsc_solver_unit_tests.cpp b/src/Solvers/petsc_solver_unit_tests.cpp
index bc68b7c15269e55ad29ad08cb88c19e373d2f6a9..894eb4f19cc1e0dcf720b2d5c0fb5735f88fe242 100644
--- a/src/Solvers/petsc_solver_unit_tests.cpp
+++ b/src/Solvers/petsc_solver_unit_tests.cpp
@@ -8,6 +8,8 @@
 #ifndef OPENFPM_NUMERICS_SRC_SOLVERS_PETSC_SOLVER_UNIT_TESTS_CPP_
 #define OPENFPM_NUMERICS_SRC_SOLVERS_PETSC_SOLVER_UNIT_TESTS_CPP_
 
+#ifdef HAVE_PETSC
+
 #define BOOST_TEST_DYN_LINK
 #include <boost/test/unit_test.hpp>
 
@@ -132,4 +134,6 @@ BOOST_AUTO_TEST_CASE( laplacian_3D_int_zero_mg )
 
 BOOST_AUTO_TEST_SUITE_END()
 
+#endif
+
 #endif /* OPENFPM_NUMERICS_SRC_SOLVERS_PETSC_SOLVER_UNIT_TESTS_CPP_ */