On Thursday, April 07, 2011 09:07:32 am Mike McQuaid wrote: > Hey, > > I've ended up with several Qt projects with nearly identical packaging > requirements (i.e. use BundleUtilties, install plugins by group, write > qt.conf, etc.). As a result, I'm going to work on some functions to > make this process easier (I already have it working for several > projects, just need to make it more generic). > > Would this be a mergeable addition? Should I add this to > BundleUtilties, FindQt4, UseQt4 or a new module (DeployQt4)? > > Thanks!
I would put it in Qt4Macros.cmake and document it in FindQt4.cmake. I would love some other people's input in this work. I have put some work into it already and can give you the patches I have so far. When I started 'using' the functions, they didn't work the way I wanted. So what I am hoping for was input on what the CMakeLists.txt files should contain... then maybe we can adjust the functions for installing Qt plugins to work with that. Here's a snippet from a CMakeLists.txt file that demonstrates how I wanted to be able to call it. You'll notice how the functions follow the install() command style. There is some of passing the same arguments into each command, but at least the caller doesn't have to formulate a different set of arguments for each function call. If there is a totally different way to think about this, I'm open to suggestions. =========== function(install_prerequisites ....) install(CODE " include(BundleUtilities) .... fixup_bundle(\"${app}\" \"${libs}\" \"${dirs}\") " ) endfunction(install_prerequisites) include(CPack) # install target install(TARGETS testqt DESTINATION bin) # install Qt plugins in a custom location qt4_install_default_plugins(DESTINATION bin/myplugins) # install qt.conf file with custom plugin location qt4_install_qtconf(DESTINATION bin BUNDLE_DESTIATION . CONTENTS Plugins myplugins) # install prerequisites (todo, how to pass installed Qt plugins into this function?) install_prerequisites(TARGET testqt DESTINATION bin BUNDLE_DESTINATION . COMPONENT Runtime) =========== Also, see attached for patch to Qt4Macros.cmake and FindQt4.cmake. -- Clinton Stimpson Elemental Technologies, Inc Computational Simulation Software, LLC www.csimsoft.com
diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake index 0a11cfb..f01ce04 100644 --- a/Modules/FindQt4.cmake +++ b/Modules/FindQt4.cmake @@ -150,6 +150,28 @@ # filenames can be found in qm_files. The ts_files # must exists and are not updated in any way. # +# macro QT4_INSTALL_DEFAULT_PLUGINS( install_prefix ) +# in: install_prefix +# Invokes install() commands for installing the default set of Qt plugins needed by an application. +# This can typically be called as qt4_install_default_plugins(bin/plugins) +# The QT_USE_* variables can control whether plugins for Qt modules are installed. +# +# macro QT4_INSTALL_PLUGIN_TYPE( install_prefix type ) +# in: install_prefix +# in: name of type of plugins (e.g. imageformats) +# Invokes install() commands for installing a type of Qt plugins. +# +# macro QT4_INSTALL_PLUGIN( install_prefix type plugin) +# in: install_prefix +# in: name of type of plugins (e.g. imageformats) +# in: name of plugin to install (e.g. qgif) +# Invokes install() commands for installing a single Qt plugin. +# +# macro QT4_INSTALL_QTCONF( install_prefix contents ...) +# in: install_prefix - where to install the qt.conf file +# in: contents of qt.conf file - list of Entry;Value pairs for the file +# in: extra arguments passed into install(CODE ...) command +# Invokes install() command for installing a qt.conf file. # # Below is a detailed list of variables that FindQt4.cmake sets. # QT_FOUND If false, don't try to use Qt. diff --git a/Modules/Qt4Macros.cmake b/Modules/Qt4Macros.cmake index 6d7a3ec..a8bdc28 100644 --- a/Modules/Qt4Macros.cmake +++ b/Modules/Qt4Macros.cmake @@ -411,3 +411,87 @@ MACRO(QT4_ADD_TRANSLATION _qm_files) SET(${_qm_files} ${${_qm_files}} ${qm}) ENDFOREACH (_current_FILE) ENDMACRO(QT4_ADD_TRANSLATION) + + +function(QT4_INSTALL_PLUGIN install_prefix _type _plugin) + string(TOUPPER ${_type} type) + string(TOUPPER ${_plugin} plugin) + + set(plugin_file_release "${QT_${plugin}_PLUGIN_RELEASE}") + set(plugin_file_debug "${QT_${plugin}_PLUGIN_DEBUG}") + + if(plugin_file_release AND plugin_file_debug) + install(FILES ${plugin_file_release} DESTINATION "${install_prefix}/${_type}/" CONFIGURATIONS Release OPTIONAL) + install(FILES ${plugin_file_debug} DESTINATION "${install_prefix}/${_type}/" CONFIGURATIONS Debug OPTIONAL) + else(plugin_file_release AND plugin_file_debug) + if(plugin_file_release) + install(FILES ${plugin_file_release} DESTINATION "${install_prefix}/${_type}/" OPTIONAL) + endif(plugin_file_release) + if(plugin_file_debug) + install(FILES ${plugin_file_debug} DESTINATION "${install_prefix}/${_type}/" OPTIONAL) + endif(plugin_file_debug) + endif(plugin_file_release AND plugin_file_debug) +endfunction(QT4_INSTALL_PLUGIN) + + + +function(QT4_INSTALL_PLUGIN_TYPE install_prefix _type) + string(TOUPPER ${_type} type) + foreach(_plugin ${QT_${type}_PLUGINS}) + qt4_install_plugin(${install_prefix} ${_type} ${_plugin}) + endforeach(_plugin) +endfunction(QT4_INSTALL_PLUGIN_TYPE) + + + +function(QT4_INSTALL_DEFAULT_PLUGINS install_prefix) + + # always install image format plugins + qt4_install_plugin_type("${install_prefix}" imageformats) + + #sql driver plugins if QtSql + if(QT_USE_QTSQL) + qt4_install_plugin_type("${install_prefix}" sqldrivers) + endif(QT_USE_QTSQL) + + #script plugins if QtScript + if(QT_USE_QTSCRIPT) + qt4_install_plugin_type("${install_prefix}" script) + endif(QT_USE_QTSCRIPT) + + #phonon backend plugins if phonon + if(QT_USE_PHONON) + qt4_install_plugin_type("${install_prefix}" phonon_backend) + endif(QT_USE_PHONON) + + #svg icon plugin if QtSvg + if(QT_USE_QTSVG) + qt4_install_plugin_type("${install_prefix}" iconengines) + endif(QT_USE_QTSVG) + + # always install accessibility plugins + qt4_install_plugin("${install_prefix}" accessible qtaccessiblewidgets) + + # acessibility for qt3support if Qt3Support + if(QT_USE_QT3SUPPORT) + qt4_install_plugin("${install_prefix}" accessible qtaccessiblecompatwidgets) + endif(QT_USE_QT3SUPPORT) + +endfunction(QT4_INSTALL_DEFAULT_PLUGINS) + +function(qt4_install_qtconf install_prefix contents) + if(contents) + set(file_contents "[Paths]") + set(toggle 1) + foreach(token ${contents}) + if(toggle) + set(file_contents "${file_contents}\n${token} = ") + set(toggle 0) + else(toggle) + set(file_contents "${file_contents}${token}") + set(toggle 1) + endif(toggle) + endforeach(token) + endif(contents) + install(CODE "FILE(WRITE ${install_prefix}/qt.conf ${file_contents})" ${ARGN}) +endfunction(qt4_install_qtconf)
_______________________________________________ cmake-developers mailing list cmake-developers@cmake.org http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers