diff --git a/contrib/HighOrderMeshOptimizer/OptHomRun.cpp b/contrib/HighOrderMeshOptimizer/OptHomRun.cpp
index 762544ca852de93c18b39ee1c4dd0f341bcbcf58..199d08a7a5bb256a83e63e87fb142ef68bdaa05c 100644
--- a/contrib/HighOrderMeshOptimizer/OptHomRun.cpp
+++ b/contrib/HighOrderMeshOptimizer/OptHomRun.cpp
@@ -2,6 +2,7 @@
 #include <sstream>
 #include <iterator>
 #include <string.h>
+#include "GmshConfig.h"
 #include "OptHOM.h"
 #include "OptHomRun.h"
 #include "GModel.h"
@@ -15,6 +16,8 @@
 #include "OS.h"
 #include <stack>
 
+#if defined(HAVE_BFGS)
+
 double distMaxStraight(MElement *el)
 {
   const polynomialBasis *lagrange = (polynomialBasis*)el->getFunctionSpace();
@@ -534,8 +537,11 @@ static void optimizeOneByOne
   }
 }
 
+#endif
+
 void HighOrderMeshOptimizer(GModel *gm, OptHomParameters &p)
 {
+#if defined(HAVE_BFGS)
   double t1 = Cpu();
 
   int samples = 30;
@@ -583,4 +589,7 @@ void HighOrderMeshOptimizer(GModel *gm, OptHomParameters &p)
   p.CPU = t2-t1;
 
   Msg::StatusBar(true, "Done optimizing high order mesh (%g s)", p.CPU);
+#else
+  Msg::Error("High-order mesh optimizer requires BFGS");
+#endif
 }
diff --git a/wrappers/gmshpy/CMakeLists.txt b/wrappers/gmshpy/CMakeLists.txt
index 69c11df7febbfa93fd6d45d74482363ee7c18a4d..cd0ca86e3bd6e86b1a05b79fa653e2abcac96464 100644
--- a/wrappers/gmshpy/CMakeLists.txt
+++ b/wrappers/gmshpy/CMakeLists.txt
@@ -62,7 +62,7 @@ ENDMACRO(SWIG_GET_WRAPPER_DEPENDENCIES)
 
 option(ENABLE_PYTHON_LIB_API "Export all C header files needed to build the python library" OFF)
 if(ENABLE_PYTHON_LIB_API)
-  set(GMSH_API ${GMSH_API} Geo/Curvature.h Mesh/Generator.h Mesh/highOrderTools.h
+  set(GMSH_API ${GMSH_API} Geo/Curvature.h Mesh/Generator.h 
       Mesh/meshGFaceLloyd.h Numeric/DivideAndConquer.h Post/PViewFactory.h
       Solver/linearSystemPETSc.h Fltk/FlGui.h Solver/functionSpace.h
       Solver/STensor43.h Solver/sparsityPattern.h Solver/SElement.h
@@ -132,12 +132,12 @@ set (GMSH_PYTHON_EXTRA_INCLUDE
   Geo/GeomMeshMatcher.h
   Geo/GFaceCompound.h
   Geo/gmshLevelset.h
-  Mesh/highOrderTools.h
   Numeric/jacobiPolynomials.h
   Numeric/legendrePolynomials.h
   Solver/linearSystemPETSc.h
   Mesh/meshGFaceLloyd.h
   contrib/HighOrderMeshOptimizer/OptHomRun.h
+  contrib/HighOrderMeshOptimizer/OptHomElastic.h
   Post/PViewAsSimpleFunction.h
   Post/PViewFactory.h
   Numeric/pyramidalBasis.h