summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Modules/DeployQt4.cmake72
-rw-r--r--Tests/CMakeLists.txt92
-rw-r--r--Tests/Qt4Deploy/CMakeLists.txt70
-rw-r--r--Tests/Qt4Deploy/testdeploy.cpp29
4 files changed, 195 insertions, 68 deletions
diff --git a/Modules/DeployQt4.cmake b/Modules/DeployQt4.cmake
index 83f322c..8a5e9c5 100644
--- a/Modules/DeployQt4.cmake
+++ b/Modules/DeployQt4.cmake
@@ -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
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 00cac94..53c59cc 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -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}
diff --git a/Tests/Qt4Deploy/CMakeLists.txt b/Tests/Qt4Deploy/CMakeLists.txt
new file mode 100644
index 0000000..646ea9f
--- /dev/null
+++ b/Tests/Qt4Deploy/CMakeLists.txt
@@ -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()
diff --git a/Tests/Qt4Deploy/testdeploy.cpp b/Tests/Qt4Deploy/testdeploy.cpp
new file mode 100644
index 0000000..8b9c8d6
--- /dev/null
+++ b/Tests/Qt4Deploy/testdeploy.cpp
@@ -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;
+}