我使用cmake的软件包实用程序来创建应用程序包。使用Qt 5.5 alpha snapshot,这很好用。使用5.5 release candidate,它不再起作用了。
仍然会创建Qt框架的正确文件夹结构,但缺少实际的库二进制文件。 minimal example的CMakeLists.txt就像这样:
set(MACOSX_BUNDLE_BUNDLE_NAME BundleTest)
set(MACOSX_BUNDLE_GUI_IDENTIFIER local.BundleTest)
# Force the install prefix to have libraries installed into the bundle.
# This doesn't seem to work. Need to set the INSTALL_PREFIX manually in cmake.
set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}")
set(QT_PLUGINS_DIR "${Qt5Core_DIR}/../../../plugins")
set(APP_BUNDLE "${CMAKE_INSTALL_PREFIX}/BundleTest.app")
set(binary_dest_dir "Contents/MacOS")
set(plugin_dest_dir "Contents/PlugIns")
set(qtconf_dest_dir "Contents/Resources")
install(TARGETS BundleTest
BUNDLE DESTINATION .
COMPONENT Runtime
)
# install a qt.conf file
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/qt.conf"
DESTINATION "${APP_BUNDLE}/${qtconf_dest_dir}/"
COMPONENT Runtime
)
# install Qt's own translations
install(FILES ${QT_TRANSLATIONS}
DESTINATION "${APP_BUNDLE}/${qtconf_dest_dir}/"
COMPONENT Runtime
)
# Qt plugins
if(${CMAKE_BUILD_TYPE} MATCHES "Debug")
install(DIRECTORY ${QT_PLUGINS_DIR}/
DESTINATION ${APP_BUNDLE}/${plugin_dest_dir}/
COMPONENT Runtime
FILES_MATCHING REGEX "(sqlite|imageformats|platforms)"
)
else()
# this branch intentionally left blank
endif()
# Use BundleUtilities to get all other dependencies for the application to work.
# It takes a bundle or executable along with possible plugins and inspects it
# for dependencies. If they are not system dependencies, they are copied.
# Directories to look for dependencies
# QT_LIBRARY_DIRS is usually empty, but that doesn't prevent 5.5alpha from working.
set(DIRS
${QT_LIBRARY_DIRS}
)
# Now the work of copying dependencies into the bundle/package and also
# fixing up the Qt plugins we copied over earlier.
# The quotes are escaped and variables to use at install time have their $ escaped
# An alternative is the do a configure_file() on a script and use install(SCRIPT ...).
install(CODE
"
file(GLOB_RECURSE QT_PLUGIN_LIST
\"${APP_BUNDLE}/${plugin_dest_dir}/*/*${CMAKE_SHARED_LIBRARY_SUFFIX}\"
)
include(BundleUtilities)
fixup_bundle(\"${APP_BUNDLE}\" \"\${QT_PLUGIN_LIST}\" \"\${DIRS}\")
"
COMPONENT Runtime
)
要使用上面链接的示例重现此操作,请将CMAKE_BUILD_TYPE = Debug(将Qt插件复制过来)和CMAKE_INSTALL_PREFIX设置到构建目录,以便将库安装到应用程序包中。然后进行make && make install
舞蹈。
如何使用Qt 5.5 RC创建有效的应用程序包?