Merge topic 'qt4-deploy'

4689eed reflect that the QtAutomoc depends on QtGui
ab9661c Remove QtGui dependency in Qt4Deploy test and verify QtSql existance.
52e8279 Fix for Qt4Deploy on some test machines.
672e3bb Add test for DeployQt4.cmake
4853e1e Fix plugin installation issues.
35cbf23 Ensure libs are passed to BundleUtilities.
0ac1535 Fix bad plugin paths.
a2123e8 Fix mismatched arguments.
fc6f340 Don't use QT_LIBRARIES_PLUGINS by default.
This commit is contained in:
David Cole 2012-03-06 15:25:02 -05:00 committed by CMake Topic Stage
commit b22f2f18c1
4 changed files with 195 additions and 68 deletions

View File

@ -82,6 +82,7 @@
include(BundleUtilities)
set(DeployQt4_cmake_dir "${CMAKE_CURRENT_LIST_DIR}")
set(DeployQt4_apple_plugins_dir "PlugIns")
function(write_qt4_conf qt_conf_dir qt_conf_contents)
set(qt_conf_path "${qt_conf_dir}/qt.conf")
@ -130,6 +131,9 @@ function(fixup_qt4_executable executable)
set(qt_conf_dir "${executable}/Contents/Resources")
set(executable_path "${executable}")
set(write_qt_conf TRUE)
if(NOT plugins_dir)
set(plugins_dir "${DeployQt4_apple_plugins_dir}")
endif()
else()
get_filename_component(executable_path "${executable}" PATH)
if(NOT executable_path)
@ -141,7 +145,7 @@ function(fixup_qt4_executable executable)
foreach(plugin ${qtplugins})
set(installed_plugin_path "")
install_qt4_plugin("${plugin}" "${plugins_dir}" "${executable}" 1 installed_plugin_path)
install_qt4_plugin("${plugin}" "${executable}" 1 installed_plugin_path)
list(APPEND libs ${installed_plugin_path})
endforeach()
@ -166,23 +170,19 @@ function(install_qt4_plugin_path plugin executable copy installed_plugin_path_va
set(component ${ARGV5})
set(configurations ${ARGV6})
if(EXISTS "${plugin}")
if(plugins_dir)
set(plugins_dir "${plugins_dir}")
else()
if(APPLE)
set(plugins_dir "PlugIns")
else()
set(plugins_dir "plugins")
endif()
endif()
if(APPLE)
if(NOT plugins_dir)
set(plugins_dir "${DeployQt4_apple_plugins_dir}")
endif()
set(plugins_path "${executable}/Contents/${plugins_dir}")
else()
get_filename_component(executable_path "${executable}" PATH)
if(NOT executable_path)
set(executable_path ".")
get_filename_component(plugins_path "${executable}" PATH)
if(NOT plugins_path)
set(plugins_path ".")
endif()
if(plugins_dir)
set(plugins_path "${plugins_path}/${plugins_dir}")
endif()
set(plugins_path "${executable_path}/${plugins_dir}")
endif()
set(plugin_group "")
@ -210,7 +210,7 @@ function(install_qt4_plugin_path plugin executable copy installed_plugin_path_va
endif()
install(FILES "${plugin}" DESTINATION "${plugins_path}" ${configurations} ${component})
endif()
set(${installed_plugin_path_var} ${${installed_path_var}} "${plugins_path}/${plugin_name}" PARENT_SCOPE)
set(${installed_plugin_path_var} "${plugins_path}/${plugin_name}" PARENT_SCOPE)
endif()
endfunction()
@ -220,11 +220,7 @@ function(install_qt4_plugin plugin executable copy installed_plugin_path_var)
if(EXISTS "${plugin}")
install_qt4_plugin_path("${plugin}" "${executable}" "${copy}" "${installed_plugin_path_var}" "${plugins_dir}" "${component}")
else()
if(QT_IS_STATIC)
string(TOUPPER "QT_${plugin}_LIBRARY" plugin_var)
else()
string(TOUPPER "QT_${plugin}_PLUGIN" plugin_var)
endif()
string(TOUPPER "QT_${plugin}_PLUGIN" plugin_var)
set(plugin_release_var "${plugin_var}_RELEASE")
set(plugin_debug_var "${plugin_var}_DEBUG")
set(plugin_release "${${plugin_release_var}}")
@ -232,10 +228,24 @@ function(install_qt4_plugin plugin executable copy installed_plugin_path_var)
if(DEFINED "${plugin_release_var}" AND DEFINED "${plugin_debug_var}" AND NOT EXISTS "${plugin_release}" AND NOT EXISTS "${plugin_debug}")
message(WARNING "Qt plugin \"${plugin}\" not recognized or found.")
endif()
install_qt4_plugin_path("${plugin_release}" "${executable}" "${copy}" "${installed_plugin_path_var}" "${plugins_dir}" "${component}" "Release|RelWithDebInfo|MinSizeRel")
install_qt4_plugin_path("${plugin_debug}" "${executable}" "${copy}" "${installed_plugin_path_var}" "${plugins_dir}" "${component}" "Debug")
if(NOT EXISTS "${${plugin_debug_var}}")
set(plugin_debug "${plugin_release}")
endif()
if(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
install_qt4_plugin_path("${plugin_release}" "${executable}" "${copy}" "${installed_plugin_path_var}_release" "${plugins_dir}" "${component}" "Release|RelWithDebInfo|MinSizeRel")
install_qt4_plugin_path("${plugin_debug}" "${executable}" "${copy}" "${installed_plugin_path_var}_debug" "${plugins_dir}" "${component}" "Debug")
if(CMAKE_BUILD_TYPE MATCHES "^Debug$")
set(${installed_plugin_path_var} ${${installed_plugin_path_var}_debug})
else()
set(${installed_plugin_path_var} ${${installed_plugin_path_var}_release})
endif()
else()
install_qt4_plugin_path("${plugin_release}" "${executable}" "${copy}" "${installed_plugin_path_var}" "${plugins_dir}" "${component}")
endif()
endif()
set(installed_plugin_path_var "${installed_plugin_path_var}" PARENT_SCOPE)
set(${installed_plugin_path_var} ${${installed_plugin_path_var}} PARENT_SCOPE)
endfunction()
function(install_qt4_executable executable)
@ -264,16 +274,16 @@ function(install_qt4_executable executable)
set(qt_plugins_dir "")
endif()
if(NOT qtplugins AND QT_LIBRARIES_PLUGINS)
set(qtplugins "${QT_LIBRARIES_PLUGINS}")
if(QT_IS_STATIC)
message(WARNING "Qt built statically: not installing plugins.")
else()
foreach(plugin ${qtplugins})
set(installed_plugin_paths "")
install_qt4_plugin("${plugin}" "${executable}" 0 installed_plugin_paths "${plugins_dir}" "${component}")
list(APPEND libs ${installed_plugin_paths})
endforeach()
endif()
foreach(plugin ${qtplugins})
set(installed_plugin_paths "")
install_qt4_plugin("${plugin}" "${executable}" 0 installed_plugin_paths "${plugins_dir}" "${component}")
list(APPEND libs ${installed_plugin_paths})
endforeach()
resolve_qt4_paths(libs)
install(CODE

View File

@ -233,12 +233,35 @@ IF(BUILD_TESTING)
LIST(APPEND TEST_BUILD_DIRS ${CMake_TEST_INSTALL_PREFIX})
IF(NOT QT4_FOUND)
FIND_PACKAGE(Qt4)
ENDIF(NOT QT4_FOUND)
IF(QT4_FOUND)
# test whether the Qt4 which has been found works, on some machines
# which run nightly builds there were errors like "wrong file format"
# for libQtCore.so. So first check it works, and only if it does add
# the automoc test.
INCLUDE(CheckCXXSourceCompiles)
SET(_save_CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES}")
SET(_save_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
SET(CMAKE_REQUIRED_INCLUDES ${QT_INCLUDES})
SET(CMAKE_REQUIRED_LIBRARIES ${QT_QTCORE_LIBRARIES})
CHECK_CXX_SOURCE_COMPILES("#include <QCoreApplication>\n int main() {return (qApp == 0 ? 0 : 1); }\n"
QT4_WORKS)
SET(CMAKE_REQUIRED_INCLUDES "${_save_CMAKE_REQUIRED_INCLUDES}")
SET(CMAKE_REQUIRED_LIBRARIES "${_save_CMAKE_REQUIRED_LIBRARIES}")
ENDIF()
# run test for BundleUtilities on supported platforms/compilers
if(MSVC OR
CMAKE_SYSTEM_NAME MATCHES "Linux" OR
CMAKE_SYSTEM_NAME MATCHES "Darwin")
if(NOT "${CMAKE_TEST_GENERATOR}" STREQUAL "Watcom WMake")
ADD_TEST(BundleUtilities ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/BundleUtilities"
@ -248,6 +271,24 @@ IF(BUILD_TESTING)
--build-project BundleUtilities
)
LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BundleUtilities")
# run test for DeployQt4 on supported platforms/compilers (which depends on BundleUtilities)
# this test also depends on the existence of the standard qtiff plugin
if(QT4_WORKS AND QT_QTSQL_FOUND)
ADD_TEST(Qt4Deploy ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/Qt4Deploy"
"${CMake_BINARY_DIR}/Tests/Qt4Deploy"
--build-generator ${CMAKE_TEST_GENERATOR}
--build-makeprogram ${CMAKE_TEST_MAKEPROGRAM}
--build-project Qt4Deploy
--build-options
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}
)
LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4Deploy")
endif()
endif()
endif()
@ -861,43 +902,20 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
)
LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Environment")
IF(NOT QT4_FOUND)
FIND_PACKAGE(Qt4)
ENDIF(NOT QT4_FOUND)
IF(QT4_FOUND)
# test whether the Qt4 which has been found works, on some machines
# which run nightly builds there were errors like "wrong file format"
# for libQtCore.so. So first check it works, and only if it does add
# the automoc test.
INCLUDE(CheckCXXSourceCompiles)
SET(_save_CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES}")
SET(_save_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
SET(CMAKE_REQUIRED_INCLUDES ${QT_INCLUDES})
SET(CMAKE_REQUIRED_LIBRARIES ${QT_QTCORE_LIBRARIES})
CHECK_CXX_SOURCE_COMPILES("#include <QCoreApplication>\n int main() {return (qApp == 0 ? 0 : 1); }\n"
QT4_WORKS_FOR_AUTOMOC_TEST)
SET(CMAKE_REQUIRED_INCLUDES "${_save_CMAKE_REQUIRED_INCLUDES}")
SET(CMAKE_REQUIRED_LIBRARIES "${_save_CMAKE_REQUIRED_LIBRARIES}")
IF(QT4_WORKS_FOR_AUTOMOC_TEST)
ADD_TEST(QtAutomoc ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/QtAutomoc"
"${CMake_BINARY_DIR}/Tests/QtAutomoc"
--build-generator ${CMAKE_TEST_GENERATOR}
--build-project QtAutomoc
--build-makeprogram ${CMAKE_TEST_MAKEPROGRAM}
--build-exe-dir "${CMake_BINARY_DIR}/Tests/QtAutomoc"
--force-new-ctest-process
--build-options -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}
--test-command ${CMAKE_CTEST_COMMAND} -V
)
LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/QtAutomoc")
ENDIF()
IF(QT4_WORKS AND QT_QTGUI_FOUND)
ADD_TEST(QtAutomoc ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/QtAutomoc"
"${CMake_BINARY_DIR}/Tests/QtAutomoc"
--build-generator ${CMAKE_TEST_GENERATOR}
--build-project QtAutomoc
--build-makeprogram ${CMAKE_TEST_MAKEPROGRAM}
--build-exe-dir "${CMake_BINARY_DIR}/Tests/QtAutomoc"
--force-new-ctest-process
--build-options -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}
--test-command ${CMAKE_CTEST_COMMAND} -V
)
LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/QtAutomoc")
ENDIF()
ADD_TEST(ExternalProject ${CMAKE_CTEST_COMMAND}

View File

@ -0,0 +1,70 @@
cmake_minimum_required(VERSION 2.8)
project(Qt4Deploy)
set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/install)
find_package(Qt4 REQUIRED QtMain QtCore QtSql)
include(${QT_USE_FILE})
add_executable(testdeploy MACOSX_BUNDLE testdeploy.cpp)
target_link_libraries(testdeploy ${QT_LIBRARIES})
set_target_properties(testdeploy PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}")
if(CMAKE_CONFIGURATION_TYPES AND QT_QTCORE_LIBRARY_RELEASE AND QT_QTCORE_LIBRARY_DEBUG)
# note: installing debug Qt libraries from a Qt installation configured with
# -debug-and-release not yet supported (very low priority).
install(CODE "
if(\"\${CMAKE_INSTALL_CONFIG_NAME}\" MATCHES \"^([Dd][Ee][Bb][Uu][Gg])$\")
return()
endif()
")
endif()
# install the Qt4 app with qsqlite plugin
install(CODE "file(REMOVE_RECURSE \"${CMAKE_INSTALL_PREFIX}\")")
install(TARGETS testdeploy DESTINATION .)
include(../../Modules/DeployQt4.cmake)
if(APPLE)
install_qt4_executable(testdeploy.app "qsqlite")
elseif(WIN32)
install_qt4_executable(testdeploy.exe "qsqlite")
else()
install_qt4_executable(testdeploy "qsqlite")
endif()
# test depends on standard qsqlite plugin
if(QT_QSQLITE_PLUGIN_DEBUG OR QT_QSQLITE_PLUGIN_RELEASE)
# test the deployed Qt application
if(APPLE)
install(CODE "
message(STATUS \"executing: ${CMAKE_INSTALL_PREFIX}/testdeploy.app/Contents/MacOS/testdeploy\")
execute_process(COMMAND \"${CMAKE_INSTALL_PREFIX}/testdeploy.app/Contents/MacOS/testdeploy\"
RESULT_VARIABLE result)
if(NOT result STREQUAL \"0\")
message(FATAL_ERROR \"error running testdeploy app\")
endif()
")
else()
install(CODE "
message(STATUS \"executing: ${CMAKE_INSTALL_PREFIX}/testdeploy\")
execute_process(COMMAND \"${CMAKE_INSTALL_PREFIX}/testdeploy\"
RESULT_VARIABLE result)
if(NOT result STREQUAL \"0\")
message(FATAL_ERROR \"error running testdeploy app\")
endif()
")
endif()
# custom target to install and test the installation at build time
if(CMAKE_CONFIGURATION_TYPES)
set(install_config "-DCMAKE_INSTALL_CONFIG_NAME=${CMAKE_CFG_INTDIR}")
endif()
add_custom_target(testdeploy_test ALL
COMMAND ${CMAKE_COMMAND} ${install_config} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_install.cmake
COMMENT "${CMAKE_COMMAND} ${install_config} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_install.cmake"
DEPENDS testdeploy)
endif()

View File

@ -0,0 +1,29 @@
#include <QCoreApplication>
#include <QSqlDatabase>
#include <QLibraryInfo>
#include <QDebug>
#include <QStringList>
int main(int argc, char** argv)
{
QCoreApplication app(argc, argv);
qDebug() << "App path:" << app.applicationDirPath();
qDebug() << "Plugin path:" << QLibraryInfo::location(QLibraryInfo::PluginsPath);
bool foundSqlite = false;
qDebug() << "Supported Database Drivers:";
foreach(const QString &sqlDriver, QSqlDatabase::drivers())
{
qDebug() << " " << sqlDriver;
if(sqlDriver == "QSQLITE")
foundSqlite = true;
}
if(foundSqlite)
qDebug() << "Found sqlite support from plugin.";
else
qDebug() << "Could not find sqlite support from plugin.";
return foundSqlite ? 0 : 1;
}