UseQt4.cmake 3.93 KB
Newer Older
1 2 3 4 5 6 7 8 9
#.rst:
# UseQt4
# ------
#
# Use Module for QT4
#
# Sets up C and C++ to use Qt 4.  It is assumed that FindQt.cmake has
# already been loaded.  See FindQt.cmake for information on how to load
# Qt 4 into your CMake project.
10

11 12 13 14 15 16 17 18 19 20
#=============================================================================
# Copyright 2005-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
21
# (To distribute this file outside of CMake, substitute the full
22
#  License text for the above reference.)
23

24
add_definitions(${QT_DEFINITIONS})
25
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<NOT:$<CONFIG:Debug>>:QT_NO_DEBUG>)
26

27 28 29 30 31
if(QT_INCLUDE_DIRS_NO_SYSTEM)
  include_directories(${QT_INCLUDE_DIR})
else(QT_INCLUDE_DIRS_NO_SYSTEM)
  include_directories(SYSTEM ${QT_INCLUDE_DIR})
endif(QT_INCLUDE_DIRS_NO_SYSTEM)
32

33 34
set(QT_LIBRARIES "")
set(QT_LIBRARIES_PLUGINS "")
35

36 37 38
if (QT_USE_QTMAIN)
  if (Q_WS_WIN)
    set(QT_LIBRARIES ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY})
39 40
  endif ()
endif ()
41

42 43
if(QT_DONT_USE_QTGUI)
  set(QT_USE_QTGUI 0)
44
else()
45
  set(QT_USE_QTGUI 1)
46
endif()
47

48 49
if(QT_DONT_USE_QTCORE)
  set(QT_USE_QTCORE 0)
50
else()
51
  set(QT_USE_QTCORE 1)
52
endif()
53

54 55
if (QT_USE_QT3SUPPORT)
  add_definitions(-DQT3_SUPPORT)
56
endif ()
57

58
# list dependent modules, so dependent libraries are added
59
set(QT_QT3SUPPORT_MODULE_DEPENDS QTGUI QTSQL QTXML QTNETWORK QTCORE)
60
set(QT_QTSVG_MODULE_DEPENDS QTGUI QTCORE)
61 62 63 64
set(QT_QTUITOOLS_MODULE_DEPENDS QTGUI QTXML QTCORE)
set(QT_QTHELP_MODULE_DEPENDS QTGUI QTSQL QTXML QTNETWORK QTCORE)
if(QT_QTDBUS_FOUND)
  set(QT_PHONON_MODULE_DEPENDS QTGUI QTDBUS QTCORE)
65
else()
66
  set(QT_PHONON_MODULE_DEPENDS QTGUI QTCORE)
67
endif()
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
set(QT_QTDBUS_MODULE_DEPENDS QTXML QTCORE)
set(QT_QTXMLPATTERNS_MODULE_DEPENDS QTNETWORK QTCORE)
set(QT_QAXCONTAINER_MODULE_DEPENDS QTGUI QTCORE)
set(QT_QAXSERVER_MODULE_DEPENDS QTGUI QTCORE)
set(QT_QTSCRIPTTOOLS_MODULE_DEPENDS QTGUI QTCORE)
set(QT_QTWEBKIT_MODULE_DEPENDS QTXMLPATTERNS QTGUI QTCORE)
set(QT_QTDECLARATIVE_MODULE_DEPENDS QTSCRIPT QTSVG QTSQL QTXMLPATTERNS QTGUI QTCORE)
set(QT_QTMULTIMEDIA_MODULE_DEPENDS QTGUI QTCORE)
set(QT_QTOPENGL_MODULE_DEPENDS QTGUI QTCORE)
set(QT_QTSCRIPT_MODULE_DEPENDS QTCORE)
set(QT_QTGUI_MODULE_DEPENDS QTCORE)
set(QT_QTTEST_MODULE_DEPENDS QTCORE)
set(QT_QTXML_MODULE_DEPENDS QTCORE)
set(QT_QTSQL_MODULE_DEPENDS QTCORE)
set(QT_QTNETWORK_MODULE_DEPENDS QTCORE)
83

84
# Qt modules  (in order of dependence)
85
foreach(module QT3SUPPORT QTOPENGL QTASSISTANT QTDESIGNER QTMOTIF QTNSPLUGIN
86
               QAXSERVER QAXCONTAINER QTDECLARATIVE QTSCRIPT QTSVG QTUITOOLS QTHELP
87 88
               QTWEBKIT PHONON QTSCRIPTTOOLS QTMULTIMEDIA QTXMLPATTERNS QTGUI QTTEST
               QTDBUS QTXML QTSQL QTNETWORK QTCORE)
89

90 91 92 93 94
  if (QT_USE_${module} OR QT_USE_${module}_DEPENDS)
    if (QT_${module}_FOUND)
      if(QT_USE_${module})
        string(REPLACE "QT" "" qt_module_def "${module}")
        add_definitions(-DQT_${qt_module_def}_LIB)
95 96 97 98 99
        if(QT_INCLUDE_DIRS_NO_SYSTEM)
          include_directories(${QT_${module}_INCLUDE_DIR})
        else(QT_INCLUDE_DIRS_NO_SYSTEM)
          include_directories(SYSTEM ${QT_${module}_INCLUDE_DIR})
        endif(QT_INCLUDE_DIRS_NO_SYSTEM)
100
      endif()
101 102 103
      if(QT_USE_${module} OR QT_IS_STATIC)
        set(QT_LIBRARIES ${QT_LIBRARIES} ${QT_${module}_LIBRARY})
      endif()
104 105 106
      set(QT_LIBRARIES_PLUGINS ${QT_LIBRARIES_PLUGINS} ${QT_${module}_PLUGINS})
      if(QT_IS_STATIC)
        set(QT_LIBRARIES ${QT_LIBRARIES} ${QT_${module}_LIB_DEPENDENCIES})
107
      endif()
108 109
      foreach(depend_module ${QT_${module}_MODULE_DEPENDS})
        set(QT_USE_${depend_module}_DEPENDS 1)
110 111
      endforeach()
    else ()
112
      message("Qt ${module} library not found.")
113 114
    endif ()
  endif ()
115

116
endforeach()
117