diff options
author | Stephen Kelly <steveire@gmail.com> | 2012-12-31 08:41:09 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2013-01-07 19:00:47 (GMT) |
commit | 57a67bf27efc286fffa883baad86c7d5d51834cc (patch) | |
tree | e1c7bd8916be485c638dcd28c43b82df7e8c3921 /Modules/FindQt4.cmake | |
parent | 00deb127be64cf8934d92c1593c8ea4a5f0f2061 (diff) | |
download | CMake-57a67bf27efc286fffa883baad86c7d5d51834cc.zip CMake-57a67bf27efc286fffa883baad86c7d5d51834cc.tar.gz CMake-57a67bf27efc286fffa883baad86c7d5d51834cc.tar.bz2 |
Qt4: Add module dependencies to the IMPORTED targets
This means for example, that consumers can use:
target_link_libraries(foo ${QT_QTGUI_LIBRARIES})
instead of also needing to specify all 'public' dependencies:
target_link_libraries(foo ${QT_QTGUI_LIBRARIES} ${QT_QTCORE_LIBRARIES} )
when using the IMPORTED targets. Also populate the
IMPORTED_LINK_DEPENDENT_LIBRARIES property so CMake can help the linker
find shared library dependencies.
Diffstat (limited to 'Modules/FindQt4.cmake')
-rw-r--r-- | Modules/FindQt4.cmake | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake index ea4d8f4..381141c 100644 --- a/Modules/FindQt4.cmake +++ b/Modules/FindQt4.cmake @@ -942,12 +942,36 @@ if (QT_QMAKE_EXECUTABLE AND QTVERSION) ############################################ + macro(_qt4_add_target_depends_internal _QT_MODULE _PROPERTY) + if (TARGET Qt4::${_QT_MODULE}) + foreach(_DEPEND ${ARGN}) + if (NOT TARGET Qt4::Qt${_DEPEND}) + message(FATAL_ERROR "_qt4_add_target_depends invoked with invalid arguments") + endif() + set_property(TARGET Qt4::${_QT_MODULE} APPEND PROPERTY + ${_PROPERTY} + "Qt4::Qt${_DEPEND}" + ) + endforeach() + endif() + endmacro() + + macro(_qt4_add_target_depends _QT_MODULE) + _qt4_add_target_depends_internal(${_QT_MODULE} IMPORTED_LINK_INTERFACE_LIBRARIES ${ARGN}) + endmacro() + + macro(_qt4_add_target_private_depends _QT_MODULE) + _qt4_add_target_depends_internal(${_QT_MODULE} IMPORTED_LINK_DEPENDENT_LIBRARIES ${ARGN}) + endmacro() + + # Set QT_xyz_LIBRARY variable and add # library include path to QT_INCLUDES _QT4_ADJUST_LIB_VARS(QtCore) foreach(QT_MODULE ${QT_MODULES}) _QT4_ADJUST_LIB_VARS(${QT_MODULE}) + _qt4_add_target_depends(${QT_MODULE} Core) endforeach() _QT4_ADJUST_LIB_VARS(QtAssistant) @@ -962,6 +986,37 @@ if (QT_QMAKE_EXECUTABLE AND QTVERSION) _QT4_ADJUST_LIB_VARS(QAxContainer) endif() + # Only public dependencies are listed here. + # Eg, QtDBus links to QtXml, but users of QtDBus do not need to + # link to QtXml because QtDBus only uses it internally, not in public + # headers. + # Everything depends on QtCore, but that is covered above already + _qt4_add_target_depends(Qt3Support Sql Gui Network) + _qt4_add_target_depends(QtDeclarative Script Gui) + _qt4_add_target_depends(QtDesigner Gui) + _qt4_add_target_depends(QtHelp Gui) + _qt4_add_target_depends(QtMultimedia Gui) + _qt4_add_target_depends(QtOpenGL Gui) + _qt4_add_target_depends(QtSvg Gui) + _qt4_add_target_depends(QtWebKit Gui Network) + + _qt4_add_target_private_depends(Qt3Support Xml) + _qt4_add_target_private_depends(QtSvg Xml) + _qt4_add_target_private_depends(QtDBus Xml) + _qt4_add_target_private_depends(QtUiTools Xml Gui) + _qt4_add_target_private_depends(QtHelp Sql Xml Network) + _qt4_add_target_private_depends(QtXmlPatterns Network) + _qt4_add_target_private_depends(QtScriptTools Gui) + _qt4_add_target_private_depends(QtWebKit XmlPatterns) + _qt4_add_target_private_depends(QtDeclarative XmlPatterns Svg Sql Gui) + _qt4_add_target_private_depends(QtMultimedia Gui) + _qt4_add_target_private_depends(QtOpenGL Gui) + _qt4_add_target_private_depends(QAxServer Gui) + _qt4_add_target_private_depends(QAxContainer Gui) + _qt4_add_target_private_depends(phonon Gui) + if(QT_QTDBUS_FOUND) + _qt4_add_target_private_depends(phonon DBus) + endif() ####################################### # |