UseQt4.cmake 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. #[=======================================================================[.rst:
  4. UseQt4
  5. ------
  6. Use Module for QT4
  7. Sets up C and C++ to use Qt 4. It is assumed that :module:`FindQt` has
  8. already been loaded. See :module:`FindQt` for information on how to load
  9. Qt 4 into your CMake project.
  10. #]=======================================================================]
  11. add_definitions(${QT_DEFINITIONS})
  12. set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<NOT:$<CONFIG:Debug>>:QT_NO_DEBUG>)
  13. if(QT_INCLUDE_DIRS_NO_SYSTEM)
  14. include_directories(${QT_INCLUDE_DIR})
  15. else(QT_INCLUDE_DIRS_NO_SYSTEM)
  16. include_directories(SYSTEM ${QT_INCLUDE_DIR})
  17. endif(QT_INCLUDE_DIRS_NO_SYSTEM)
  18. set(QT_LIBRARIES "")
  19. set(QT_LIBRARIES_PLUGINS "")
  20. if (QT_USE_QTMAIN)
  21. if (Q_WS_WIN)
  22. set(QT_LIBRARIES ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY})
  23. endif ()
  24. endif ()
  25. if(QT_DONT_USE_QTGUI)
  26. set(QT_USE_QTGUI 0)
  27. else()
  28. set(QT_USE_QTGUI 1)
  29. endif()
  30. if(QT_DONT_USE_QTCORE)
  31. set(QT_USE_QTCORE 0)
  32. else()
  33. set(QT_USE_QTCORE 1)
  34. endif()
  35. if (QT_USE_QT3SUPPORT)
  36. add_definitions(-DQT3_SUPPORT)
  37. endif ()
  38. # list dependent modules, so dependent libraries are added
  39. set(QT_QT3SUPPORT_MODULE_DEPENDS QTGUI QTSQL QTXML QTNETWORK QTCORE)
  40. set(QT_QTSVG_MODULE_DEPENDS QTGUI QTCORE)
  41. set(QT_QTUITOOLS_MODULE_DEPENDS QTGUI QTXML QTCORE)
  42. set(QT_QTHELP_MODULE_DEPENDS QTGUI QTSQL QTXML QTNETWORK QTCORE)
  43. if(QT_QTDBUS_FOUND)
  44. set(QT_PHONON_MODULE_DEPENDS QTGUI QTDBUS QTCORE)
  45. else()
  46. set(QT_PHONON_MODULE_DEPENDS QTGUI QTCORE)
  47. endif()
  48. set(QT_QTDBUS_MODULE_DEPENDS QTXML QTCORE)
  49. set(QT_QTXMLPATTERNS_MODULE_DEPENDS QTNETWORK QTCORE)
  50. set(QT_QAXCONTAINER_MODULE_DEPENDS QTGUI QTCORE)
  51. set(QT_QAXSERVER_MODULE_DEPENDS QTGUI QTCORE)
  52. set(QT_QTSCRIPTTOOLS_MODULE_DEPENDS QTGUI QTCORE)
  53. set(QT_QTWEBKIT_MODULE_DEPENDS QTXMLPATTERNS QTGUI QTCORE)
  54. set(QT_QTDECLARATIVE_MODULE_DEPENDS QTSCRIPT QTSVG QTSQL QTXMLPATTERNS QTGUI QTCORE)
  55. set(QT_QTMULTIMEDIA_MODULE_DEPENDS QTGUI QTCORE)
  56. set(QT_QTOPENGL_MODULE_DEPENDS QTGUI QTCORE)
  57. set(QT_QTSCRIPT_MODULE_DEPENDS QTCORE)
  58. set(QT_QTGUI_MODULE_DEPENDS QTCORE)
  59. set(QT_QTTEST_MODULE_DEPENDS QTCORE)
  60. set(QT_QTXML_MODULE_DEPENDS QTCORE)
  61. set(QT_QTSQL_MODULE_DEPENDS QTCORE)
  62. set(QT_QTNETWORK_MODULE_DEPENDS QTCORE)
  63. # Qt modules (in order of dependence)
  64. foreach(module QT3SUPPORT QTOPENGL QTASSISTANT QTDESIGNER QTMOTIF QTNSPLUGIN
  65. QAXSERVER QAXCONTAINER QTDECLARATIVE QTSCRIPT QTSVG QTUITOOLS QTHELP
  66. QTWEBKIT PHONON QTSCRIPTTOOLS QTMULTIMEDIA QTXMLPATTERNS QTGUI QTTEST
  67. QTDBUS QTXML QTSQL QTNETWORK QTCORE)
  68. if (QT_USE_${module} OR QT_USE_${module}_DEPENDS)
  69. if (QT_${module}_FOUND)
  70. if(QT_USE_${module})
  71. string(REPLACE "QT" "" qt_module_def "${module}")
  72. add_definitions(-DQT_${qt_module_def}_LIB)
  73. if(QT_INCLUDE_DIRS_NO_SYSTEM)
  74. include_directories(${QT_${module}_INCLUDE_DIR})
  75. else(QT_INCLUDE_DIRS_NO_SYSTEM)
  76. include_directories(SYSTEM ${QT_${module}_INCLUDE_DIR})
  77. endif(QT_INCLUDE_DIRS_NO_SYSTEM)
  78. endif()
  79. if(QT_USE_${module} OR QT_IS_STATIC)
  80. set(QT_LIBRARIES ${QT_LIBRARIES} ${QT_${module}_LIBRARY})
  81. endif()
  82. set(QT_LIBRARIES_PLUGINS ${QT_LIBRARIES_PLUGINS} ${QT_${module}_PLUGINS})
  83. if(QT_IS_STATIC)
  84. set(QT_LIBRARIES ${QT_LIBRARIES} ${QT_${module}_LIB_DEPENDENCIES})
  85. endif()
  86. foreach(depend_module ${QT_${module}_MODULE_DEPENDS})
  87. set(QT_USE_${depend_module}_DEPENDS 1)
  88. endforeach()
  89. else ()
  90. message("Qt ${module} library not found.")
  91. endif ()
  92. endif ()
  93. endforeach()