diff --git a/Common/CommandLine.cpp b/Common/CommandLine.cpp
index de4f0f8d66a09e76d38e2f40e813b5ebb92a9562..5cc8be0a080b73247b4403848349f1b13b8f52b1 100644
--- a/Common/CommandLine.cpp
+++ b/Common/CommandLine.cpp
@@ -112,50 +112,7 @@ const char *Get_GmshBuildHost(){ return GMSH_HOST; }
 const char *Get_GmshPackager(){ return GMSH_PACKAGER; }
 const char *Get_GmshBuildOS(){ return GMSH_OS; }
 const char *Get_GmshShortLicense(){ return GMSH_SHORT_LICENSE; }
-std::string Get_GmshBuildOptions()
-{
-  std::string opt;
-#if defined(HAVE_NETGEN)
-  opt += "NETGEN ";
-#endif
-#if defined(HAVE_TETGEN)
-  opt += "TETGEN ";
-#endif
-#if defined(HAVE_LIBJPEG)
-  opt += "JPEG ";
-#endif
-#if defined(HAVE_LIBPNG)
-  opt += "PNG ";
-#endif
-#if defined(HAVE_LIBZ)
-  opt += "ZLIB ";
-#endif
-#if defined(HAVE_MATH_EVAL)
-  opt += "MATHEVAL ";
-#endif
-#if defined(HAVE_METIS)
-  opt += "METIS ";
-#endif
-#if defined(HAVE_CHACO)
-  opt += "CHACO ";
-#endif
-#if defined(HAVE_ANN)
-  opt += "ANN ";
-#endif
-#if defined(HAVE_CGNS)
-  opt += "CGNS ";
-#endif
-#if defined(HAVE_OCC)
-  opt += "OCC ";
-#endif
-#if defined(HAVE_MED)
-  opt += "MED ";
-#endif
-#if defined(HAVE_GMM)
-  opt += "GMM++ ";
-#endif
-  return opt;
-}
+std::string Get_GmshBuildOptions(){ return GMSH_CONFIG_OPTIONS; }
 
 void Get_Options(int argc, char *argv[])
 {
diff --git a/Common/GmshConfig.h.in b/Common/GmshConfig.h.in
index 1a1e3ca2d3ea65a96ddc4b645d2dd0861162b363..3b5ad15d4702f66713b96fd7b900f4cc552f0e5e 100644
--- a/Common/GmshConfig.h.in
+++ b/Common/GmshConfig.h.in
@@ -35,4 +35,6 @@
 #undef HAVE_TETGEN
 #undef HAVE_TREE_BROWSER
 
+#define GMSH_CONFIG_OPTIONS ""
+
 #endif
diff --git a/configure b/configure
index 413c6ed27e31aee0f164dc10522d139a25200d62..debf99efb4f5a80750e3f65c89f7e6ae23533d2c 100755
--- a/configure
+++ b/configure
@@ -3928,7 +3928,7 @@ fi
 #define HAVE_TREE_BROWSER 1
 _ACEOF
 
-       BO="${BO} TreeBrowser"
+      BO="${BO} TreeBrowser"
     fi
   fi
 
@@ -7098,6 +7098,10 @@ _ACEOF
   fi
 fi
 
+cat >>confdefs.h <<_ACEOF
+#define GMSH_CONFIG_OPTIONS "${BO}"
+_ACEOF
+
 ac_config_headers="$ac_config_headers Common/GmshConfig.h:Common/GmshConfig.h.in"
 
 
diff --git a/configure.in b/configure.in
index d92e38c2c0622a5a382ba358d7842347bafb4228..b045346381b892337a2ac21a7afa3767d0e09b2d 100644
--- a/configure.in
+++ b/configure.in
@@ -274,7 +274,7 @@ if test "x$enable_gui" != "xno"; then
       GMSH_DIRS="${GMSH_DIRS} contrib/TreeBrowser"
       GMSH_LIBS="${GMSH_LIBS} -lGmshTreeBrowser"
       AC_DEFINE(HAVE_TREE_BROWSER)
-       BO="${BO} TreeBrowser"
+      BO="${BO} TreeBrowser"
     fi
   fi
 
@@ -856,6 +856,7 @@ if test $ac_cv_sizeof_size_t != 4; then
   fi
 fi
 
+AC_DEFINE_UNQUOTED(GMSH_CONFIG_OPTIONS, "${BO}")
 AC_CONFIG_HEADER(Common/GmshConfig.h:Common/GmshConfig.h.in)
 
 dnl Write output