1 # Locate Qt include paths and libraries
4 # QT_INCLUDE_DIR, where to find qt.h, etc.
5 # QT_LIBRARIES, the libraries to link against to use Qt.
6 # QT_DEFINITIONS, definitions to use when compiling code that uses Qt.
7 # QT_FOUND, If false, don't try to use Qt.
9 #if you need the multithreaded version of Qt, set QT_MT_REQUIRED to TRUE
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 library. This is only required by Qt3 on Windows.
17 # These are around for backwards compatibility
19 # QT_WRAP_CPP, set true if QT_MOC_EXECUTABLE is found
20 # QT_WRAP_UI set true if QT_UIC_EXECUTABLE is found
23 FIND_PATH(QT_INCLUDE_DIR qt.h
30 /usr/share/qt3/include
31 C:/Progra~1/qt/include
36 #extract the version string from qglobal.h
37 FILE(READ ${QT_INCLUDE_DIR}/qglobal.h QGLOBAL_H)
38 STRING(REGEX MATCH "#define[\t ]+QT_VERSION_STR[\t ]+\"([0-9]+.[0-9]+.[0-9]+)\"" QGLOBAL_H "${QGLOBAL_H}")
39 STRING(REGEX REPLACE ".*\"([0-9]+.[0-9]+.[0-9]+)\".*" "\\1" QGLOBAL_H "${QGLOBAL_H}")
41 # Under windows the qt library (MSVC) has the format qt-mtXYZ where XYZ is the
42 # version X.Y.Z, so we need to remove the dots from version
43 STRING(REGEX REPLACE "\\." "" qt_version_str_lib "${QGLOBAL_H}")
49 FIND_LIBRARY(QT_QT_LIBRARY
50 NAMES qt-mt qt-mt${qt_version_str_lib} qt-mt230nc
62 FIND_LIBRARY(QT_QT_LIBRARY
63 NAMES qt qt-${qt_version_str_lib} qt-mt qt-mt230nc
73 ENDIF (QT_MT_REQUIRED)
80 FIND_LIBRARY(QT_QASSISTANTCLIENT_LIBRARY
81 NAMES qassistantclient
91 FIND_PROGRAM(QT_MOC_EXECUTABLE
101 IF(QT_MOC_EXECUTABLE)
102 SET ( QT_WRAP_CPP "YES")
103 ELSE(QT_MOC_EXECUTABLE)
104 ENDIF(QT_MOC_EXECUTABLE)
106 FIND_PROGRAM(QT_UIC_EXECUTABLE uic
114 IF(QT_UIC_EXECUTABLE)
115 SET ( QT_WRAP_UI "YES")
116 ELSE(QT_UIC_EXECUTABLE)
117 ENDIF(QT_UIC_EXECUTABLE)
120 FIND_LIBRARY(QT_QTMAIN_LIBRARY qtmain
121 $ENV{QTDIR}/lib C:/Progra~1/qt/lib
122 DOC "This Library is only needed by and included with Qt3 on MSWindows. It should be NOTFOUND, undefined or IGNORE otherwise."
129 STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" qt_major_vers "${qt_version_str}")
130 STRING(REGEX REPLACE "[0-9]+\\.([0-9]+)\\.[0-9]+" "\\1" qt_minor_vers "${qt_version_str}")
131 STRING(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" qt_patch_vers "${qt_version_str}")
133 #now parse the parts of the user given version string into variables
134 STRING(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+$" req_qt_major_vers "${QT_MIN_VERSION}")
135 IF (NOT req_qt_major_vers)
136 MESSAGE( FATAL_ERROR "Invalid Qt version string given: \"${QT_MIN_VERSION}\", expected e.g. \"3.1.5\"")
137 ENDIF (NOT req_qt_major_vers)
139 STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" req_qt_major_vers "${QT_MIN_VERSION}")
140 STRING(REGEX REPLACE "[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" req_qt_minor_vers "${QT_MIN_VERSION}")
141 STRING(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" req_qt_patch_vers "${QT_MIN_VERSION}")
143 # req = "6.5.4", qt = "3.2.1"
145 IF (req_qt_major_vers GREATER qt_major_vers) # (6 > 3) ?
146 MESSAGE( FATAL_ERROR "Qt major version not matched (required: ${QT_MIN_VERSION}, found: ${qt_version_str})") # yes
147 ELSE (req_qt_major_vers GREATER qt_major_vers) # no
148 IF (req_qt_major_vers LESS qt_major_vers) # (6 < 3) ?
149 SET( QT_VERSION_BIG_ENOUGH "YES" ) # yes
150 ELSE (req_qt_major_vers LESS qt_major_vers) # ( 6==3) ?
151 IF (req_qt_minor_vers GREATER qt_minor_vers) # (5>2) ?
152 MESSAGE( FATAL_ERROR "Qt minor version not matched (required: ${QT_MIN_VERSION}, found: ${qt_version_str})") # yes
153 ELSE (req_qt_minor_vers GREATER qt_minor_vers) # no
154 IF (req_qt_minor_vers LESS qt_minor_vers) # (5<2) ?
155 SET( QT_VERSION_BIG_ENOUGH "YES" ) # yes
156 ELSE (req_qt_minor_vers LESS qt_minor_vers) # (5==2)
157 IF (req_qt_patch_vers GREATER qt_patch_vers) # (4>1) ?
158 MESSAGE( FATAL_ERROR "Qt patch level not matched (required: ${QT_MIN_VERSION}, found: ${qt_version_str})") # yes
159 ELSE (req_qt_patch_vers GREATER qt_patch_vers) # (4>1) ?
160 SET( QT_VERSION_BIG_ENOUGH "YES" ) # yes
161 ENDIF (req_qt_patch_vers GREATER qt_patch_vers) # (4>1) ?
162 ENDIF (req_qt_minor_vers LESS qt_minor_vers)
163 ENDIF (req_qt_minor_vers GREATER qt_minor_vers)
164 ENDIF (req_qt_major_vers LESS qt_major_vers)
165 ENDIF (req_qt_major_vers GREATER qt_major_vers)
166 ENDIF (QT_MIN_VERSION)
168 # if the include a library are found then we have it
171 SET( QT_FOUND "YES" )
173 ENDIF(QT_INCLUDE_DIR)
176 SET( QT_LIBRARIES ${QT_LIBRARIES} ${QT_QT_LIBRARY} )
177 SET( QT_DEFINITIONS "")
179 IF (WIN32 AND NOT CYGWIN)
180 IF (QT_QTMAIN_LIBRARY)
182 SET (QT_DEFINITIONS "-DQT_DLL -DQT_THREAD_SUPPORT -DNO_DEBUG")
183 SET (QT_LIBRARIES imm32.lib ${QT_QT_LIBRARY} ${QT_QTMAIN_LIBRARY} )
184 SET (QT_LIBRARIES ${QT_LIBRARIES} winmm wsock32)
185 ELSE (QT_QTMAIN_LIBRARY)
187 SET (QT_LIBRARIES imm32.lib ws2_32.lib ${QT_QT_LIBRARY} )
188 ENDIF (QT_QTMAIN_LIBRARY)
189 ELSE (WIN32 AND NOT CYGWIN)
190 SET (QT_LIBRARIES ${QT_QT_LIBRARY} )
192 SET (QT_DEFINITIONS "-DQT_SHARED -DQT_NO_DEBUG")
193 IF(QT_QT_LIBRARY MATCHES "qt-mt")
194 SET (QT_DEFINITIONS ${QT_DEFINITIONS} -DQT_THREAD_SUPPORT -D_REENTRANT)
195 ENDIF(QT_QT_LIBRARY MATCHES "qt-mt")
197 ENDIF (WIN32 AND NOT CYGWIN)
199 IF (QT_QASSISTANTCLIENT_LIBRARY)
200 SET (QT_LIBRARIES ${QT_QASSISTANTCLIENT_LIBRARY} ${QT_LIBRARIES})
201 ENDIF (QT_QASSISTANTCLIENT_LIBRARY)
203 # Backwards compatibility for CMake1.4 and 1.2
204 SET (QT_MOC_EXE ${QT_MOC_EXECUTABLE} )
205 SET (QT_UIC_EXE ${QT_UIC_EXECUTABLE} )
206 # for unix add X11 stuff
210 SET (QT_LIBRARIES ${QT_LIBRARIES} ${X11_LIBRARIES})
213 SET (QT_LIBRARIES ${QT_LIBRARIES} ${CMAKE_DL_LIBS})
214 ENDIF (CMAKE_DL_LIBS)
216 IF(QT_QT_LIBRARY MATCHES "qt-mt")
217 FIND_PACKAGE(Threads)
218 SET(QT_LIBRARIES ${QT_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
219 ENDIF(QT_QT_LIBRARY MATCHES "qt-mt")
223 IF (QT_MOC_EXECUTABLE)
224 SET ( QT_WRAP_CPP "YES")
225 ENDIF (QT_MOC_EXECUTABLE)
227 IF (QT_UIC_EXECUTABLE)
228 SET ( QT_WRAP_UI "YES")
229 ENDIF (QT_UIC_EXECUTABLE)
237 QT_QASSISTANTCLIENT_LIBRARY