cmake-gui: Install Qt5 Windows platform plugin

Qt5 requires a platform-specific runtime-loaded plugin.  We already
install it for OS X.  Install it for Windows too.
This commit is contained in:
Konstantin Podsvirov 2015-07-24 10:15:06 +03:00 committed by Brad King
parent d546133d49
commit 42f0155bb9
1 changed files with 24 additions and 10 deletions

View File

@ -36,17 +36,22 @@ if (Qt5Widgets_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
# We need to install Cocoa platform plugin and add qt.conf for Qt5 on Mac. # We need to install platform plugin and add qt.conf for Qt5 on Mac and Windows.
# FIXME: This should be part of Qt5 CMake scripts, but unfortunatelly # FIXME: This should be part of Qt5 CMake scripts, but unfortunatelly
# Qt5 Mac support is missing there. # Qt5 support is missing there.
if(APPLE) if(APPLE OR WIN32)
macro(install_qt5_plugin _qt_plugin_name _qt_plugins_var) macro(install_qt5_plugin _qt_plugin_name _qt_plugins_var)
get_target_property(_qt_plugin_path "${_qt_plugin_name}" LOCATION) get_target_property(_qt_plugin_path "${_qt_plugin_name}" LOCATION)
if(EXISTS "${_qt_plugin_path}") if(EXISTS "${_qt_plugin_path}")
get_filename_component(_qt_plugin_file "${_qt_plugin_path}" NAME) get_filename_component(_qt_plugin_file "${_qt_plugin_path}" NAME)
get_filename_component(_qt_plugin_type "${_qt_plugin_path}" PATH) get_filename_component(_qt_plugin_type "${_qt_plugin_path}" PATH)
get_filename_component(_qt_plugin_type "${_qt_plugin_type}" NAME) get_filename_component(_qt_plugin_type "${_qt_plugin_type}" NAME)
set(_qt_plugin_dest "PlugIns/${_qt_plugin_type}") if(APPLE)
set(_qt_plugin_dir "PlugIns")
elseif(WIN32)
set(_qt_plugin_dir "plugins")
endif()
set(_qt_plugin_dest "${_qt_plugin_dir}/${_qt_plugin_type}")
install(FILES "${_qt_plugin_path}" install(FILES "${_qt_plugin_path}"
DESTINATION "${_qt_plugin_dest}" DESTINATION "${_qt_plugin_dest}"
${COMPONENT}) ${COMPONENT})
@ -56,12 +61,21 @@ if (Qt5Widgets_FOUND)
message(FATAL_ERROR "QT plugin ${_qt_plugin_name} not found") message(FATAL_ERROR "QT plugin ${_qt_plugin_name} not found")
endif() endif()
endmacro() endmacro()
install_qt5_plugin("Qt5::QCocoaIntegrationPlugin" QT_PLUGINS) if(APPLE)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/qt.conf" install_qt5_plugin("Qt5::QCocoaIntegrationPlugin" QT_PLUGINS)
"[Paths]\nPlugins = PlugIns\n") file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/qt.conf"
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/qt.conf" "[Paths]\nPlugins = ${_qt_plugin_dir}\n")
DESTINATION "${CMAKE_INSTALL_PREFIX}/Resources" install(FILES "${CMAKE_CURRENT_BINARY_DIR}/qt.conf"
${COMPONENT}) DESTINATION "${CMAKE_INSTALL_PREFIX}/Resources"
${COMPONENT})
elseif(WIN32)
install_qt5_plugin("Qt5::QWindowsIntegrationPlugin" QT_PLUGINS)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/qt.conf"
"[Paths]\nPlugins = ../${_qt_plugin_dir}\n")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/qt.conf"
DESTINATION bin
${COMPONENT})
endif()
endif() endif()
if(WIN32 AND TARGET Qt5::Core) if(WIN32 AND TARGET Qt5::Core)