diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6a95e351ad9510dbb7e1ada07e40207caf64afb9..bc5d8264183ab24a9b9d819a82f8147a2dae8134 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -239,7 +239,7 @@ if (ENABLE_GUI)
 endif()
 
 if (ENABLE_SPNAV)
-  find_package(SpNav REQUIRED)
+  #find_package(SpNav REQUIRED)
   set(_SPNAV ON)
 else()
   set(_SPNAV OFF)
diff --git a/modules/config/CMakeLists.txt b/modules/config/CMakeLists.txt
index a95554b40456f3339bbbea2a7ef6833e829b5592..c7cdc9468303279890c5a9a84ce2d9aae4fae4ad 100644
--- a/modules/config/CMakeLists.txt
+++ b/modules/config/CMakeLists.txt
@@ -52,11 +52,6 @@ if (_STATICPROPS)
 else()
   set(static_props 0)
 endif()
-if (ENABLE_SPNAV)
-  set(spnav_enabled 1)
-else()
-  set(spnav_enabled 0)
-endif()
 if (FFTW_USE_THREADS)
   set(fftw_use_threads 1)
 else()
diff --git a/modules/config/config.hh.in b/modules/config/config.hh.in
index 3268ebab4144946b5d78fcd83f2b0f3d816a4832..23027e24848ca02388701f86b32bc68530829840 100644
--- a/modules/config/config.hh.in
+++ b/modules/config/config.hh.in
@@ -30,7 +30,6 @@
 #define OST_IMG_ENABLED @img_enabled@
 #define OST_DOUBLE_PRECISION @double_prec@
 #define OST_STATIC_PROPERTY_WORKAROUND @static_props@
-#define OST_SPNAV_ENABLED @spnav_enabled@
 #define OST_FFT_USE_THREADS @fftw_use_threads@
 #define OST_NUMPY_SUPPORT_ENABLED @numpy_support@
 #define OST_DEBIAN_STYLE_LIBEXEC @debian_style_libexec@
diff --git a/modules/gui/src/CMakeLists.txt b/modules/gui/src/CMakeLists.txt
index 92cba1bfe308ef1c397cfbaa8f2b5473509742e7..b4d9ee6e433268164006b2c8806b1ebaf905e168 100644
--- a/modules/gui/src/CMakeLists.txt
+++ b/modules/gui/src/CMakeLists.txt
@@ -172,9 +172,9 @@ gl_win.hh
 scene_menu.hh
 gosty_app.hh
 admin.hh
+module_config.hh
 main.hh
 main_area.hh
-module_config.hh
 perspective.hh
 remote_site_loader.hh
 scene_selection.hh
@@ -429,13 +429,22 @@ if (ENABLE_IMG)
 endif()
 
 if (ENABLE_SPNAV)
+  set(spnav_enabled 1)
   list(APPEND OST_GUI_SOURCES
       input/spnav_input.cc
   )
   list(APPEND HEADERS_TO_BE_MOCCED
       input/spnav_input.hh
   )
+else()
+  set(spnav_enabled 0)
 endif()
+
+set(config_hh_generator "CMake")
+set(MODULE_CONFIG_HH_FILE "${CMAKE_CURRENT_SOURCE_DIR}/module_config.hh")
+configure_file(module_config.hh.in ${MODULE_CONFIG_HH_FILE})
+# the resulting file, module_config.hh, is already included in OST_GUI_HEADERS
+
 if (APPLE)
   set(ADDITIONAL_LIBRARIES "-framework Security")
 endif()
diff --git a/modules/gui/src/module_config.hh b/modules/gui/src/module_config.hh
index a4c324080f637e137c217ca3ff0707a8ce1f864d..d246cae358cfbc50a0018750317bf2243064996a 100644
--- a/modules/gui/src/module_config.hh
+++ b/modules/gui/src/module_config.hh
@@ -19,8 +19,14 @@
 #ifndef OST_GUI_MODULE_CONFIG_HH
 #define OST_GUI_MODULE_CONFIG_HH
 
+/*
+  DO NOT EDIT, automatically generated by CMake
+*/
+
 #include <ost/base.hh>
 
+#define OST_SPNAV_ENABLED 0
+
 #if defined(OST_MODULE_OST_GUI)
 #  define DLLEXPORT_OST_GUI DLLEXPORT
 #else
diff --git a/modules/gui/src/module_config.hh.in b/modules/gui/src/module_config.hh.in
new file mode 100644
index 0000000000000000000000000000000000000000..a45752148678c6e460b8d6bdcd4b0203cab07c59
--- /dev/null
+++ b/modules/gui/src/module_config.hh.in
@@ -0,0 +1,36 @@
+//------------------------------------------------------------------------------
+// This file is part of the OpenStructure project <www.openstructure.org>
+//
+// Copyright (C) 2008-2011 by the OpenStructure authors
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License as published by the Free
+// Software Foundation; either version 3.0 of the License, or (at your option)
+// any later version.
+// This library is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+// FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
+// details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+//------------------------------------------------------------------------------
+#ifndef OST_GUI_MODULE_CONFIG_HH
+#define OST_GUI_MODULE_CONFIG_HH
+
+/*
+  DO NOT EDIT, automatically generated by @config_hh_generator@
+*/
+
+#include <ost/base.hh>
+
+#define OST_SPNAV_ENABLED @spnav_enabled@
+
+#if defined(OST_MODULE_OST_GUI)
+#  define DLLEXPORT_OST_GUI DLLEXPORT
+#else
+#  define DLLEXPORT_OST_GUI DLLIMPORT
+#endif
+
+#endif