Subversion Repositories Scribus

Rev

Rev 8495 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5381 cbradney 1
# - Locate Qt include paths and libraries
2
# This module defines:
3
#  QT_INCLUDE_DIR - where to find qt.h, etc.
4
#  QT_LIBRARIES   - the libraries to link against to use Qt.
5
#  QT_DEFINITIONS - definitions to use when
6
#                   compiling code that uses Qt.
7
#  QT_FOUND       - If false, don't try to use Qt.
8
#
9
# If you need the multithreaded version of Qt, set QT_MT_REQUIRED to TRUE
10
#
11
# Also defined, but not for general use are:
12
#  QT_MOC_EXECUTABLE, where to find the moc tool.
13
#  QT_UIC_EXECUTABLE, where to find the uic tool.
14
#  QT_QT_LIBRARY, where to find the Qt library.
15
#  QT_QTMAIN_LIBRARY, where to find the qtmain
16
#   library. This is only required by Qt3 on Windows.
17
 
18
# These are around for backwards compatibility
19
# they will be set
20
#  QT_WRAP_CPP, set true if QT_MOC_EXECUTABLE is found
21
#  QT_WRAP_UI set true if QT_UIC_EXECUTABLE is found
22
 
23
FILE(GLOB GLOB_PATHS_BIN /usr/lib/qt-3*/bin/)
24
FIND_PATH(QT_INCLUDE_DIR qt.h
25
  "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.1;InstallDir]/include/Qt"
26
  "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.0;InstallDir]/include/Qt"
27
  "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.1.0;InstallDir]/include/Qt"
28
  $ENV{QTDIR}/include
29
  ${GLOB_PATHS_BIN}
30
  /usr/local/qt/include
31
  /usr/local/include
32
  /usr/lib/qt/include
33
  /usr/include/qt
34
  /usr/include
35
  /usr/share/qt3/include
36
  C:/Progra~1/qt/include
37
  /usr/include/qt3
38
  /usr/X11R6/include
39
  )
40
 
41
# if qglobal.h is not in the qt_include_dir then set
42
# QT_INCLUDE_DIR to NOTFOUND
43
IF(NOT EXISTS ${QT_INCLUDE_DIR}/qglobal.h)
44
  SET(QT_INCLUDE_DIR QT_INCLUDE_DIR-NOTFOUND CACHE PATH "path to qt3 include directory" FORCE)
45
ENDIF(NOT EXISTS ${QT_INCLUDE_DIR}/qglobal.h)
46
 
47
IF(QT_INCLUDE_DIR)
48
  #extract the version string from qglobal.h
49
  FILE(READ ${QT_INCLUDE_DIR}/qglobal.h QGLOBAL_H)
50
  STRING(REGEX MATCH "#define[\t ]+QT_VERSION_STR[\t ]+\"([0-9]+.[0-9]+.[0-9]+)\"" QGLOBAL_H "${QGLOBAL_H}")
51
  STRING(REGEX REPLACE ".*\"([0-9]+.[0-9]+.[0-9]+)\".*" "\\1" QGLOBAL_H "${QGLOBAL_H}")
52
 
53
  # Under windows the qt library (MSVC) has the format qt-mtXYZ where XYZ is the
54
  # version X.Y.Z, so we need to remove the dots from version
55
  STRING(REGEX REPLACE "\\." "" qt_version_str_lib "${QGLOBAL_H}")
56
ELSE(QT_INCLUDE_DIR)
57
ENDIF(QT_INCLUDE_DIR)
58
 
59
FILE(GLOB GLOB_PATHS_LIB /usr/lib/qt-3*/lib/)
60
IF (QT_MT_REQUIRED)
61
  FIND_LIBRARY(QT_QT_LIBRARY
62
    NAMES
63
    qt-mt qt-mt${qt_version_str_lib} qt-mtnc${qt_version_str_lib}
64
    qt-mtedu${qt_version_str_lib} qt-mt230nc qt-mtnc321
65
    PATHS
66
  "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.1;InstallDir]/lib"
67
  "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.0;InstallDir]/lib"
68
  "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.1.0;InstallDir]/lib"
69
    $ENV{QTDIR}/lib
70
    ${GLOB_PATHS_LIB}
71
    /usr/local/qt/lib
72
    /usr/local/lib
73
    /usr/lib/qt/lib
74
    /usr/lib
75
    /usr/share/qt3/lib
76
    C:/Progra~1/qt/lib
77
    /usr/X11R6/lib
78
    )
79
 
80
ELSE (QT_MT_REQUIRED)
81
  FIND_LIBRARY(QT_QT_LIBRARY
82
    NAMES
83
    qt qt-${qt_version_str_lib} qt-edu${qt_version_str_lib}
84
    qt-mt qt-mt${qt_version_str_lib} qt-mtnc${qt_version_str_lib}
85
    qt-mtedu${qt_version_str_lib} qt-mt230nc qt-mtnc321
86
    PATHS
87
    "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.1;InstallDir]/lib"
88
    "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.0;InstallDir]/lib"
89
    "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.1.0;InstallDir]/lib"
90
    $ENV{QTDIR}/lib
91
    ${GLOB_PATHS_LIB}
92
    /usr/local/qt/lib
93
    /usr/local/lib
94
    /usr/lib/qt/lib
95
    /usr/lib
96
    /usr/share/qt3/lib
97
    C:/Progra~1/qt/lib
98
    /usr/X11R6/lib
99
    )
100
ENDIF (QT_MT_REQUIRED)
101
 
102
IF(QT_QT_LIBRARY)
103
ELSE(QT_QT_LIBRARY)
104
ENDIF(QT_QT_LIBRARY)
105
 
106
 
107
FIND_LIBRARY(QT_QASSISTANTCLIENT_LIBRARY
108
  NAMES qassistantclient
109
  PATHS
110
  "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.1;InstallDir]/lib"
111
  "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.0;InstallDir]/lib"
112
  "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.1.0;InstallDir]/lib"
113
  $ENV{QTDIR}/lib
114
  ${GLOB_PATHS_LIB}
115
  /usr/local/qt/lib
116
  /usr/local/lib
117
  /usr/lib
118
  /usr/share/qt3/lib
119
  C:/Progra~1/qt/lib
120
  /usr/X11R6/lib
121
  )
122
 
123
FIND_PROGRAM(QT_MOC_EXECUTABLE
124
  NAMES moc moc-qt3
125
  PATHS
126
  "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.1;InstallDir]/include/Qt"
127
  "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.0;InstallDir]/include/Qt"
128
  "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.1.0;InstallDir]/include/Qt"
129
  $ENV{QTDIR}/bin
130
  ${GLOB_PATHS_BIN}
131
  /usr/local/qt/bin
132
  /usr/lib/qt/bin
133
  /usr/share/qt3/bin
134
  C:/Progra~1/qt/bin
135
  /usr/X11R6/bin
136
  NO_DEFAULT_PATH
137
  )
138
 
139
IF(QT_MOC_EXECUTABLE)
140
  SET ( QT_WRAP_CPP "YES")
141
ELSE(QT_MOC_EXECUTABLE)
142
ENDIF(QT_MOC_EXECUTABLE)
143
 
144
FIND_PROGRAM(QT_UIC_EXECUTABLE uic
145
  "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.1;InstallDir]/include/Qt"
146
  "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.0;InstallDir]/include/Qt"
147
  "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.1.0;InstallDir]/include/Qt"
148
  $ENV{QTDIR}/bin
149
  ${GLOB_PATHS_BIN}
150
  /usr/local/qt/bin
151
  /usr/lib/qt/bin
152
  /usr/share/qt3/bin
153
  C:/Progra~1/qt/bin
154
  /usr/X11R6/bin
155
  NO_DEFAULT_PATH
156
  )
157
 
158
IF(QT_UIC_EXECUTABLE)
159
  SET ( QT_WRAP_UI "YES")
160
ELSE(QT_UIC_EXECUTABLE)
161
ENDIF(QT_UIC_EXECUTABLE)
162
 
163
IF (WIN32)
164
  FIND_LIBRARY(QT_QTMAIN_LIBRARY qtmain
165
    "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.1;InstallDir]/lib"
166
    "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.0;InstallDir]/lib"
167
    "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.1.0;InstallDir]/lib"
168
    "$ENV{ProgramFiles}/qt/lib"
169
    $ENV{QTDIR}/lib "C:/Program Files/qt/lib"
170
    DOC "This Library is only needed by and included with Qt3 on MSWindows. It should be NOTFOUND, undefined or IGNORE otherwise."
171
    )
172
ENDIF (WIN32)
173
 
174
 
175
IF (QT_MIN_VERSION)
176
 
177
  STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" qt_major_vers "${qt_version_str}")
178
  STRING(REGEX REPLACE "[0-9]+\\.([0-9]+)\\.[0-9]+" "\\1" qt_minor_vers "${qt_version_str}")
179
  STRING(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" qt_patch_vers "${qt_version_str}")
180
 
181
  #now parse the parts of the user given version string into variables
182
  STRING(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+$" req_qt_major_vers "${QT_MIN_VERSION}")
183
  IF (NOT req_qt_major_vers)
184
    MESSAGE( FATAL_ERROR "Invalid Qt version string given: \"${QT_MIN_VERSION}\", expected e.g. \"3.1.5\"")
185
  ENDIF (NOT req_qt_major_vers)
186
 
187
  STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" req_qt_major_vers "${QT_MIN_VERSION}")
188
  STRING(REGEX REPLACE "[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" req_qt_minor_vers "${QT_MIN_VERSION}")
189
  STRING(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" req_qt_patch_vers "${QT_MIN_VERSION}")
190
 
191
  # req = "6.5.4", qt = "3.2.1"
192
 
193
  IF (req_qt_major_vers GREATER qt_major_vers)                  # (6 > 3) ?
194
    MESSAGE(  FATAL_ERROR "Qt major version not matched (required: ${QT_MIN_VERSION}, found: ${qt_version_str})")            # yes
195
  ELSE  (req_qt_major_vers GREATER qt_major_vers)               # no
196
    IF (req_qt_major_vers LESS qt_major_vers)                  # (6 < 3) ?
197
      SET( QT_VERSION_BIG_ENOUGH "YES" )                      # yes
198
    ELSE (req_qt_major_vers LESS qt_major_vers)                # ( 6==3) ?
199
      IF (req_qt_minor_vers GREATER qt_minor_vers)            # (5>2) ?
200
        MESSAGE(  FATAL_ERROR "Qt minor version not matched (required: ${QT_MIN_VERSION}, found: ${qt_version_str})")      # yes
201
      ELSE (req_qt_minor_vers GREATER qt_minor_vers)          # no
202
        IF (req_qt_minor_vers LESS qt_minor_vers)            # (5<2) ?
203
          SET( QT_VERSION_BIG_ENOUGH "YES" )                # yes
204
        ELSE (req_qt_minor_vers LESS qt_minor_vers)          # (5==2)
205
          IF (req_qt_patch_vers GREATER qt_patch_vers)      # (4>1) ?
206
            MESSAGE( FATAL_ERROR "Qt patch level not matched (required: ${QT_MIN_VERSION}, found: ${qt_version_str})")  # yes
207
          ELSE (req_qt_patch_vers GREATER qt_patch_vers)    # (4>1) ?
208
            SET( QT_VERSION_BIG_ENOUGH "YES" )             # yes
209
          ENDIF (req_qt_patch_vers GREATER qt_patch_vers)   # (4>1) ?
210
        ENDIF (req_qt_minor_vers LESS qt_minor_vers)
211
      ENDIF (req_qt_minor_vers GREATER qt_minor_vers)
212
    ENDIF (req_qt_major_vers LESS qt_major_vers)
213
  ENDIF (req_qt_major_vers GREATER qt_major_vers)
214
ENDIF (QT_MIN_VERSION)
215
 
216
# if the include a library are found then we have it
217
IF(QT_INCLUDE_DIR)
218
  IF(QT_QT_LIBRARY)
219
    SET( QT_FOUND "YES" )
220
  ENDIF(QT_QT_LIBRARY)
221
ENDIF(QT_INCLUDE_DIR)
222
 
223
IF(QT_FOUND)
224
  SET( QT_LIBRARIES ${QT_LIBRARIES} ${QT_QT_LIBRARY} )
225
  SET( QT_DEFINITIONS "")
226
 
227
  IF (WIN32 AND NOT CYGWIN)
228
    IF (QT_QTMAIN_LIBRARY)
229
      # for version 3
230
      SET (QT_DEFINITIONS -DQT_DLL -DQT_THREAD_SUPPORT -DNO_DEBUG)
231
      SET (QT_LIBRARIES imm32.lib ${QT_QT_LIBRARY} ${QT_QTMAIN_LIBRARY} )
232
      SET (QT_LIBRARIES ${QT_LIBRARIES} winmm wsock32)
233
    ELSE (QT_QTMAIN_LIBRARY)
234
      # for version 2
235
      SET (QT_LIBRARIES imm32.lib ws2_32.lib ${QT_QT_LIBRARY} )
236
    ENDIF (QT_QTMAIN_LIBRARY)
237
  ELSE (WIN32 AND NOT CYGWIN)
238
    SET (QT_LIBRARIES ${QT_QT_LIBRARY} )
239
 
240
    SET (QT_DEFINITIONS -DQT_SHARED -DQT_NO_DEBUG)
241
    IF(QT_QT_LIBRARY MATCHES "qt-mt")
242
      SET (QT_DEFINITIONS ${QT_DEFINITIONS} -DQT_THREAD_SUPPORT -D_REENTRANT)
243
    ENDIF(QT_QT_LIBRARY MATCHES "qt-mt")
244
 
245
  ENDIF (WIN32 AND NOT CYGWIN)
246
 
247
  IF (QT_QASSISTANTCLIENT_LIBRARY)
248
    SET (QT_LIBRARIES ${QT_QASSISTANTCLIENT_LIBRARY} ${QT_LIBRARIES})
249
  ENDIF (QT_QASSISTANTCLIENT_LIBRARY)
250
 
251
  # Backwards compatibility for CMake1.4 and 1.2
252
  SET (QT_MOC_EXE ${QT_MOC_EXECUTABLE} )
253
  SET (QT_UIC_EXE ${QT_UIC_EXECUTABLE} )
254
  # for unix add X11 stuff
255
  IF(UNIX)
256
    FIND_PACKAGE(X11)
257
    IF (X11_FOUND)
258
      SET (QT_LIBRARIES ${QT_LIBRARIES} ${X11_LIBRARIES})
259
    ENDIF (X11_FOUND)
260
    IF (CMAKE_DL_LIBS)
261
      SET (QT_LIBRARIES ${QT_LIBRARIES} ${CMAKE_DL_LIBS})
262
    ENDIF (CMAKE_DL_LIBS)
263
  ENDIF(UNIX)
264
  IF(QT_QT_LIBRARY MATCHES "qt-mt")
265
    FIND_PACKAGE(Threads)
266
    SET(QT_LIBRARIES ${QT_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
267
  ENDIF(QT_QT_LIBRARY MATCHES "qt-mt")
268
ENDIF(QT_FOUND)
269
 
270
 
271
IF (QT_MOC_EXECUTABLE)
272
  SET ( QT_WRAP_CPP "YES")
273
ENDIF (QT_MOC_EXECUTABLE)
274
 
275
IF (QT_UIC_EXECUTABLE)
276
  SET ( QT_WRAP_UI "YES")
277
ENDIF (QT_UIC_EXECUTABLE)
278
 
279
 
280
 
281
MARK_AS_ADVANCED(
282
  QT_INCLUDE_DIR
283
  QT_QT_LIBRARY
284
  QT_QTMAIN_LIBRARY
285
  QT_QASSISTANTCLIENT_LIBRARY
286
  QT_UIC_EXECUTABLE
287
  QT_MOC_EXECUTABLE
288
  QT_WRAP_CPP
289
  QT_WRAP_UI
290
  )