]> git.cworth.org Git - apitrace/commitdiff
Add ENABLE_GUI option to control GUI builds and dependency checks
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Wed, 27 Jul 2011 23:32:54 +0000 (00:32 +0100)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Wed, 27 Jul 2011 23:42:57 +0000 (00:42 +0100)
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.

CMakeLists.txt

index 8098441401bd10ea60249b923455a224d1c8e8a8..26fa455f346e941a0193644d8aface7a6abcc923 100755 (executable)
@@ -3,6 +3,17 @@ cmake_minimum_required (VERSION 2.8)
 project (apitrace)
 
 
+##############################################################################
+# 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
 
@@ -12,8 +23,14 @@ set (CMAKE_USE_PYTHON_VERSION 2.7 2.6)
 
 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)
@@ -392,9 +409,9 @@ install (TARGETS glretrace RUNTIME DESTINATION bin)
 ##############################################################################
 # GUI
 
-if (QT4_FOUND AND QJSON_FOUND)
+if (ENABLE_GUI AND QT4_FOUND AND QJSON_FOUND)
     add_subdirectory(gui)
-endif (QT4_FOUND AND QJSON_FOUND)
+endif ()
 
 
 ##############################################################################