CMakeLists.txt 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. cmake_minimum_required(VERSION 2.8)
  2. project(Qt4Deploy)
  3. set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/install)
  4. find_package(Qt4 REQUIRED QtMain QtCore QtSql)
  5. include(${QT_USE_FILE})
  6. add_executable(testdeploy MACOSX_BUNDLE testdeploy.cpp)
  7. target_link_libraries(testdeploy ${QT_LIBRARIES})
  8. set_target_properties(testdeploy PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}")
  9. if(CMAKE_CONFIGURATION_TYPES AND QT_QTCORE_LIBRARY_RELEASE AND QT_QTCORE_LIBRARY_DEBUG)
  10. # note: installing debug Qt libraries from a Qt installation configured with
  11. # -debug-and-release not yet supported (very low priority).
  12. install(CODE "
  13. if(\"\${CMAKE_INSTALL_CONFIG_NAME}\" MATCHES \"^([Dd][Ee][Bb][Uu][Gg])$\")
  14. return()
  15. endif()
  16. ")
  17. endif()
  18. # install the Qt4 app with qsqlite plugin
  19. install(CODE "file(REMOVE_RECURSE \"${CMAKE_INSTALL_PREFIX}\")")
  20. install(TARGETS testdeploy DESTINATION .)
  21. include(../../Modules/DeployQt4.cmake)
  22. if(APPLE)
  23. install_qt4_executable(testdeploy.app "qsqlite")
  24. elseif(WIN32)
  25. install_qt4_executable(testdeploy.exe "qsqlite")
  26. else()
  27. install_qt4_executable(testdeploy "qsqlite")
  28. endif()
  29. # test depends on standard qsqlite plugin
  30. if(QT_QSQLITE_PLUGIN_DEBUG OR QT_QSQLITE_PLUGIN_RELEASE)
  31. # test the deployed Qt application
  32. if(APPLE)
  33. install(CODE "
  34. message(STATUS \"executing: ${CMAKE_INSTALL_PREFIX}/testdeploy.app/Contents/MacOS/testdeploy\")
  35. execute_process(COMMAND \"${CMAKE_INSTALL_PREFIX}/testdeploy.app/Contents/MacOS/testdeploy\"
  36. RESULT_VARIABLE result)
  37. if(NOT result STREQUAL \"0\")
  38. message(FATAL_ERROR \"error running testdeploy app\")
  39. endif()
  40. ")
  41. else()
  42. install(CODE "
  43. message(STATUS \"executing: ${CMAKE_INSTALL_PREFIX}/testdeploy\")
  44. execute_process(COMMAND \"${CMAKE_INSTALL_PREFIX}/testdeploy\"
  45. RESULT_VARIABLE result)
  46. if(NOT result STREQUAL \"0\")
  47. message(FATAL_ERROR \"error running testdeploy app\")
  48. endif()
  49. ")
  50. endif()
  51. # custom target to install and test the installation at build time
  52. if(CMAKE_CONFIGURATION_TYPES)
  53. set(install_config "-DCMAKE_INSTALL_CONFIG_NAME=${CMAKE_CFG_INTDIR}")
  54. endif()
  55. add_custom_target(testdeploy_test ALL
  56. COMMAND ${CMAKE_COMMAND} ${install_config} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_install.cmake
  57. COMMENT "${CMAKE_COMMAND} ${install_config} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_install.cmake"
  58. DEPENDS testdeploy)
  59. endif()