diff options
author | Robin Burchell <robin.burchell@collabora.co.uk> | 2011-01-17 12:31:44 (GMT) |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2011-01-17 12:31:44 (GMT) |
commit | a13e97b42c89159667f2d89c7eda2dbfdf1465e8 (patch) | |
tree | 69156ba854317007a63436f2bc26fb9252756479 | |
parent | 32f3fcd9ab19f66cb435e6a8830ce54ccf13885a (diff) | |
download | Qt-a13e97b42c89159667f2d89c7eda2dbfdf1465e8.zip Qt-a13e97b42c89159667f2d89c7eda2dbfdf1465e8.tar.gz Qt-a13e97b42c89159667f2d89c7eda2dbfdf1465e8.tar.bz2 |
Add packagesExist() function to qmake.
This can be used to detect whether or not a given (set of) packages exist,
which can be useful for compiling in or our extra functionality at build time.
Merge-request: 1022
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
-rw-r--r-- | doc/src/development/qmake-manual.qdoc | 13 | ||||
-rw-r--r-- | doc/src/snippets/code/doc_src_qmake-manual.qdoc | 12 | ||||
-rw-r--r-- | mkspecs/features/link_pkgconfig.prf | 3 | ||||
-rw-r--r-- | mkspecs/features/qt_functions.prf | 14 |
4 files changed, 41 insertions, 1 deletions
diff --git a/doc/src/development/qmake-manual.qdoc b/doc/src/development/qmake-manual.qdoc index d7a48a3..b6270d5 100644 --- a/doc/src/development/qmake-manual.qdoc +++ b/doc/src/development/qmake-manual.qdoc @@ -3397,6 +3397,19 @@ \tableofcontents{2} + \section1 packagesExist(packages) + + Uses the PKGCONFIG mechanism to determine whether or not the given packages + exist at the time of project parsing. + + This can be useful to optionally enable or disable features. For example: + + \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 157 + + And then, in the code: + + \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 158 + \section1 basename(variablename) Returns the basename of the file specified. For example: diff --git a/doc/src/snippets/code/doc_src_qmake-manual.qdoc b/doc/src/snippets/code/doc_src_qmake-manual.qdoc index ab67a3d..ec35a52 100644 --- a/doc/src/snippets/code/doc_src_qmake-manual.qdoc +++ b/doc/src/snippets/code/doc_src_qmake-manual.qdoc @@ -1029,3 +1029,15 @@ DEPLOYMENT += dep_note //! [156] DEPLOYMENT.display_name = My Qt App //! [156] + +//! [157] +packagesExist(sqlite3 QtNetwork QtDeclarative) { + DEFINES += USE_FANCY_UI +} +//! [157] + +//! [158] +#ifdef USE_FANCY_UI + // Use the fancy UI, as we have extra packages available +#endif +//! [158] diff --git a/mkspecs/features/link_pkgconfig.prf b/mkspecs/features/link_pkgconfig.prf index d70e5de..b1b00e43 100644 --- a/mkspecs/features/link_pkgconfig.prf +++ b/mkspecs/features/link_pkgconfig.prf @@ -1,5 +1,6 @@ # handle pkg-config files -isEmpty(PKG_CONFIG):PKG_CONFIG = pkg-config +isEmpty(PKG_CONFIG):PKG_CONFIG = pkg-config # keep consistent with qt_functions.prf too! + for(PKGCONFIG_LIB, $$list($$unique(PKGCONFIG))) { QMAKE_CXXFLAGS += $$system($$PKG_CONFIG --cflags $$PKGCONFIG_LIB) QMAKE_CFLAGS += $$system($$PKG_CONFIG --cflags $$PKGCONFIG_LIB) diff --git a/mkspecs/features/qt_functions.prf b/mkspecs/features/qt_functions.prf index 964e13b..f1c3e13 100644 --- a/mkspecs/features/qt_functions.prf +++ b/mkspecs/features/qt_functions.prf @@ -103,3 +103,17 @@ defineTest(qtPrepareTool) { } export($$1) } + +defineTest(packagesExist) { + # this can't be done in global scope here because qt_functions is loaded + # before the .pro is parsed, so if the .pro set PKG_CONFIG, we wouldn't know it + # yet. oops. + isEmpty(PKG_CONFIG):PKG_CONFIG = pkg-config # keep consistent with link_pkgconfig.prf! too + + for(package, ARGS) { + !system($$PKG_CONFIG --exists $$package):return(false) + } + + return(true) +} + |