Subversion Repositories Scribus

Rev

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

Rev Author Line No. Line
5406 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" qt_version_str "${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 "${qt_version_str}")
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
 
5430 cbradney 123
# qt 3 should prefer QTDIR over the PATH
5406 cbradney 124
FIND_PROGRAM(QT_MOC_EXECUTABLE
125
  NAMES moc moc-qt3
126
  PATHS
5430 cbradney 127
  $ENV{QTDIR}/bin
128
  NO_DEFAULT_PATH
129
)
130
 
131
FIND_PROGRAM(QT_MOC_EXECUTABLE
132
  NAMES moc moc-qt3
133
  PATHS
5406 cbradney 134
  "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.1;InstallDir]/include/Qt"
135
  "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.0;InstallDir]/include/Qt"
136
  "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.1.0;InstallDir]/include/Qt"
137
  $ENV{QTDIR}/bin
138
  ${GLOB_PATHS_BIN}
139
  /usr/local/qt/bin
140
  /usr/lib/qt/bin
141
  /usr/share/qt3/bin
142
  C:/Progra~1/qt/bin
143
  /usr/X11R6/bin
144
  )
145
 
146
IF(QT_MOC_EXECUTABLE)
147
  SET ( QT_WRAP_CPP "YES")
148
ELSE(QT_MOC_EXECUTABLE)
149
ENDIF(QT_MOC_EXECUTABLE)
150
 
5430 cbradney 151
# qt 3 should prefer QTDIR over the PATH
5406 cbradney 152
FIND_PROGRAM(QT_UIC_EXECUTABLE uic
5430 cbradney 153
  PATHS
154
  $ENV{QTDIR}/bin
155
  NO_DEFAULT_PATH
156
)
157
FIND_PROGRAM(QT_UIC_EXECUTABLE uic
5406 cbradney 158
  "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.1;InstallDir]/include/Qt"
159
  "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.0;InstallDir]/include/Qt"
160
  "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.1.0;InstallDir]/include/Qt"
161
  $ENV{QTDIR}/bin
162
  ${GLOB_PATHS_BIN}
163
  /usr/local/qt/bin
164
  /usr/lib/qt/bin
165
  /usr/share/qt3/bin
166
  C:/Progra~1/qt/bin
167
  /usr/X11R6/bin
168
  )
169
 
170
IF(QT_UIC_EXECUTABLE)
171
  SET ( QT_WRAP_UI "YES")
172
ELSE(QT_UIC_EXECUTABLE)
173
ENDIF(QT_UIC_EXECUTABLE)
174
 
175
IF (WIN32)
176
  FIND_LIBRARY(QT_QTMAIN_LIBRARY qtmain
177
    "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.1;InstallDir]/lib"
178
    "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.0;InstallDir]/lib"
179
    "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.1.0;InstallDir]/lib"
180
    "$ENV{ProgramFiles}/qt/lib"
181
    $ENV{QTDIR}/lib "C:/Program Files/qt/lib"
182
    DOC "This Library is only needed by and included with Qt3 on MSWindows. It should be NOTFOUND, undefined or IGNORE otherwise."
183
    )
184
ENDIF (WIN32)
185
 
186
 
187
IF (QT_MIN_VERSION)
188
 
189
  STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" qt_major_vers "${qt_version_str}")
190
  STRING(REGEX REPLACE "[0-9]+\\.([0-9]+)\\.[0-9]+" "\\1" qt_minor_vers "${qt_version_str}")
191
  STRING(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" qt_patch_vers "${qt_version_str}")
192
 
193
  #now parse the parts of the user given version string into variables
194
  STRING(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+$" req_qt_major_vers "${QT_MIN_VERSION}")
195
  IF (NOT req_qt_major_vers)
196
    MESSAGE( FATAL_ERROR "Invalid Qt version string given: \"${QT_MIN_VERSION}\", expected e.g. \"3.1.5\"")
197
  ENDIF (NOT req_qt_major_vers)
198
 
199
  STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" req_qt_major_vers "${QT_MIN_VERSION}")
200
  STRING(REGEX REPLACE "[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" req_qt_minor_vers "${QT_MIN_VERSION}")
201
  STRING(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" req_qt_patch_vers "${QT_MIN_VERSION}")
202
 
203
  # req = "6.5.4", qt = "3.2.1"
204
 
205
  IF (req_qt_major_vers GREATER qt_major_vers)                  # (6 > 3) ?
206
    MESSAGE(  FATAL_ERROR "Qt major version not matched (required: ${QT_MIN_VERSION}, found: ${qt_version_str})")            # yes
207
  ELSE  (req_qt_major_vers GREATER qt_major_vers)               # no
208
    IF (req_qt_major_vers LESS qt_major_vers)                  # (6 < 3) ?
209
      SET( QT_VERSION_BIG_ENOUGH "YES" )                      # yes
210
    ELSE (req_qt_major_vers LESS qt_major_vers)                # ( 6==3) ?
211
      IF (req_qt_minor_vers GREATER qt_minor_vers)            # (5>2) ?
212
        MESSAGE(  FATAL_ERROR "Qt minor version not matched (required: ${QT_MIN_VERSION}, found: ${qt_version_str})")      # yes
213
      ELSE (req_qt_minor_vers GREATER qt_minor_vers)          # no
214
        IF (req_qt_minor_vers LESS qt_minor_vers)            # (5<2) ?
215
          SET( QT_VERSION_BIG_ENOUGH "YES" )                # yes
216
        ELSE (req_qt_minor_vers LESS qt_minor_vers)          # (5==2)
217
          IF (req_qt_patch_vers GREATER qt_patch_vers)      # (4>1) ?
218
            MESSAGE( FATAL_ERROR "Qt patch level not matched (required: ${QT_MIN_VERSION}, found: ${qt_version_str})")  # yes
219
          ELSE (req_qt_patch_vers GREATER qt_patch_vers)    # (4>1) ?
220
            SET( QT_VERSION_BIG_ENOUGH "YES" )             # yes
221
          ENDIF (req_qt_patch_vers GREATER qt_patch_vers)   # (4>1) ?
222
        ENDIF (req_qt_minor_vers LESS qt_minor_vers)
223
      ENDIF (req_qt_minor_vers GREATER qt_minor_vers)
224
    ENDIF (req_qt_major_vers LESS qt_major_vers)
225
  ENDIF (req_qt_major_vers GREATER qt_major_vers)
226
ENDIF (QT_MIN_VERSION)
227
 
228
# if the include a library are found then we have it
229
IF(QT_INCLUDE_DIR)
230
  IF(QT_QT_LIBRARY)
231
    SET( QT_FOUND "YES" )
232
  ENDIF(QT_QT_LIBRARY)
233
ENDIF(QT_INCLUDE_DIR)
234
 
235
IF(QT_FOUND)
236
  SET( QT_LIBRARIES ${QT_LIBRARIES} ${QT_QT_LIBRARY} )
237
  SET( QT_DEFINITIONS "")
238
 
239
  IF (WIN32 AND NOT CYGWIN)
240
    IF (QT_QTMAIN_LIBRARY)
241
      # for version 3
242
      SET (QT_DEFINITIONS -DQT_DLL -DQT_THREAD_SUPPORT -DNO_DEBUG)
243
      SET (QT_LIBRARIES imm32.lib ${QT_QT_LIBRARY} ${QT_QTMAIN_LIBRARY} )
244
      SET (QT_LIBRARIES ${QT_LIBRARIES} winmm wsock32)
245
    ELSE (QT_QTMAIN_LIBRARY)
246
      # for version 2
247
      SET (QT_LIBRARIES imm32.lib ws2_32.lib ${QT_QT_LIBRARY} )
248
    ENDIF (QT_QTMAIN_LIBRARY)
249
  ELSE (WIN32 AND NOT CYGWIN)
250
    SET (QT_LIBRARIES ${QT_QT_LIBRARY} )
251
 
252
    SET (QT_DEFINITIONS -DQT_SHARED -DQT_NO_DEBUG)
253
    IF(QT_QT_LIBRARY MATCHES "qt-mt")
254
      SET (QT_DEFINITIONS ${QT_DEFINITIONS} -DQT_THREAD_SUPPORT -D_REENTRANT)
255
    ENDIF(QT_QT_LIBRARY MATCHES "qt-mt")
256
 
257
  ENDIF (WIN32 AND NOT CYGWIN)
258
 
259
  IF (QT_QASSISTANTCLIENT_LIBRARY)
260
    SET (QT_LIBRARIES ${QT_QASSISTANTCLIENT_LIBRARY} ${QT_LIBRARIES})
261
  ENDIF (QT_QASSISTANTCLIENT_LIBRARY)
262
 
263
  # Backwards compatibility for CMake1.4 and 1.2
264
  SET (QT_MOC_EXE ${QT_MOC_EXECUTABLE} )
265
  SET (QT_UIC_EXE ${QT_UIC_EXECUTABLE} )
266
  # for unix add X11 stuff
267
  IF(UNIX)
268
    FIND_PACKAGE(X11)
269
    IF (X11_FOUND)
270
      SET (QT_LIBRARIES ${QT_LIBRARIES} ${X11_LIBRARIES})
271
    ENDIF (X11_FOUND)
272
    IF (CMAKE_DL_LIBS)
273
      SET (QT_LIBRARIES ${QT_LIBRARIES} ${CMAKE_DL_LIBS})
274
    ENDIF (CMAKE_DL_LIBS)
275
  ENDIF(UNIX)
276
  IF(QT_QT_LIBRARY MATCHES "qt-mt")
277
    FIND_PACKAGE(Threads)
278
    SET(QT_LIBRARIES ${QT_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
279
  ENDIF(QT_QT_LIBRARY MATCHES "qt-mt")
280
ENDIF(QT_FOUND)
281
 
282
 
283
IF (QT_MOC_EXECUTABLE)
284
  SET ( QT_WRAP_CPP "YES")
285
ENDIF (QT_MOC_EXECUTABLE)
286
 
287
IF (QT_UIC_EXECUTABLE)
288
  SET ( QT_WRAP_UI "YES")
289
ENDIF (QT_UIC_EXECUTABLE)
290
 
291
 
292
 
293
MARK_AS_ADVANCED(
294
  QT_INCLUDE_DIR
295
  QT_QT_LIBRARY
296
  QT_QTMAIN_LIBRARY
297
  QT_QASSISTANTCLIENT_LIBRARY
298
  QT_UIC_EXECUTABLE
299
  QT_MOC_EXECUTABLE
300
  QT_WRAP_CPP
301
  QT_WRAP_UI
302
  )