Invoking cmake with -DENABLE_GUI=ON will require QT/QJSON. Setting it
to OFF will never build the GUI, even if QT and QJSON is available. The
default setting is AUTO, whereby QT/QJSON will be used if available (ie.
the current behavior).
Inspired on Tim Harder's patch for Gentoo and the information on
http://www.gentoo.org/proj/en/qa/automagic.xmltest , but modified to not
change the current default automagic behavior.
+##############################################################################
+# Options
+#
+# We use a cached string variable instead of the standard (boolean) OPTION
+# command so that we can default to auto-detecting optional depencies, while
+# still providing a mechanism to force/disable these optional dependencies, as
+# prescribed in http://www.gentoo.org/proj/en/qa/automagic.xmltest
+
+set (ENABLE_GUI "AUTO" CACHE STRING "Enable QT GUI.")
+
+
##############################################################################
# Find dependencies
##############################################################################
# Find dependencies
find_package (PythonInterp REQUIRED)
find_package (OpenGL REQUIRED)
find_package (PythonInterp REQUIRED)
find_package (OpenGL REQUIRED)
-find_package (Qt4 4.7 COMPONENTS QtCore QtGui QtWebKit)
-find_package (QJSON)
+
+if (ENABLE_GUI)
+ if (NOT (ENABLE_GUI STREQUAL "AUTO"))
+ set (REQUIRE_GUI REQUIRED)
+ endif ()
+ find_package (Qt4 4.7 COMPONENTS QtCore QtGui QtWebKit ${REQUIRE_GUI})
+ find_package (QJSON ${REQUIRE_GUI})
+endif ()
if (NOT WIN32)
find_package (X11 REQUIRED)
if (NOT WIN32)
find_package (X11 REQUIRED)
##############################################################################
# GUI
##############################################################################
# GUI
-if (QT4_FOUND AND QJSON_FOUND)
+if (ENABLE_GUI AND QT4_FOUND AND QJSON_FOUND)
-endif (QT4_FOUND AND QJSON_FOUND)
##############################################################################
##############################################################################