From 5899cf053898264bd1d9df2118d6bbe90fb71f02 Mon Sep 17 00:00:00 2001
From: Ansgar Philippsen <ansgar.philippsen@gmail.com>
Date: Mon, 2 Jul 2012 11:31:43 -0400
Subject: [PATCH] more fixes to spnav build

---
 CMakeLists.txt                      |  2 +-
 modules/config/CMakeLists.txt       |  5 ----
 modules/config/config.hh.in         |  1 -
 modules/gui/src/CMakeLists.txt      | 11 ++++++++-
 modules/gui/src/module_config.hh    |  6 +++++
 modules/gui/src/module_config.hh.in | 36 +++++++++++++++++++++++++++++
 6 files changed, 53 insertions(+), 8 deletions(-)
 create mode 100644 modules/gui/src/module_config.hh.in

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6a95e351a..bc5d82641 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 a95554b40..c7cdc9468 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 3268ebab4..23027e248 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 92cba1bfe..b4d9ee6e4 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 a4c324080..d246cae35 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 000000000..a45752148
--- /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
-- 
GitLab