diff options
author | Clinton Stimpson <clinton@elemtech.com> | 2012-01-20 23:30:35 (GMT) |
---|---|---|
committer | Clinton Stimpson <clinton@elemtech.com> | 2012-02-23 22:48:47 (GMT) |
commit | 672e3bb70f46cbc1203974fccc561760a6be8b96 (patch) | |
tree | 9c5bfefa3b50566b182d591a71ed8dc51f6d9de5 /Tests | |
parent | 4853e1effddd36c37d8e2fb4962f039c0d08af80 (diff) | |
download | CMake-672e3bb70f46cbc1203974fccc561760a6be8b96.zip CMake-672e3bb70f46cbc1203974fccc561760a6be8b96.tar.gz CMake-672e3bb70f46cbc1203974fccc561760a6be8b96.tar.bz2 |
Add test for DeployQt4.cmake
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/CMakeLists.txt | 21 | ||||
-rw-r--r-- | Tests/Qt4Deploy/CMakeLists.txt | 70 | ||||
-rw-r--r-- | Tests/Qt4Deploy/testdeploy.cpp | 29 |
3 files changed, 120 insertions, 0 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 9c97828..2e72dec 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -227,12 +227,16 @@ IF(BUILD_TESTING) LIST(APPEND TEST_BUILD_DIRS ${CMake_TEST_INSTALL_PREFIX}) + IF(NOT QT4_FOUND) + FIND_PACKAGE(Qt4) + ENDIF(NOT QT4_FOUND) # 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" @@ -242,6 +246,23 @@ 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_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} + ) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4Deploy") + endif() + endif() endif() diff --git a/Tests/Qt4Deploy/CMakeLists.txt b/Tests/Qt4Deploy/CMakeLists.txt new file mode 100644 index 0000000..ccacf74 --- /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 QtGui 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..bcf77a2 --- /dev/null +++ b/Tests/Qt4Deploy/testdeploy.cpp @@ -0,0 +1,29 @@ +#include <QCoreApplication> +#include <QImageReader> +#include <QSqlDatabase> +#include <QLibraryInfo> +#include <QDebug> + +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; +} |