From: José Fonseca Date: Wed, 27 Jul 2011 23:32:54 +0000 (+0100) Subject: Add ENABLE_GUI option to control GUI builds and dependency checks X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=e68c87f287e9cf7317db5b62f85303b2f918f968;p=apitrace Add ENABLE_GUI option to control GUI builds and dependency checks 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. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 8098441..26fa455 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 () ##############################################################################