diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2004-07-09 19:38:41 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2004-07-09 19:38:41 (GMT) |
commit | 0e0eec11628f9451d247525ee0ae9bae944140f1 (patch) | |
tree | 27f6f8d9102d2631c47266816c5cca8629849e3d /Modules | |
parent | 5b63b1843eb3a8c9b85d593fb62525194f9ef889 (diff) | |
download | CMake-0e0eec11628f9451d247525ee0ae9bae944140f1.zip CMake-0e0eec11628f9451d247525ee0ae9bae944140f1.tar.gz CMake-0e0eec11628f9451d247525ee0ae9bae944140f1.tar.bz2 |
merge in fixes from neundorf at kde org, bug 869
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/FindQt.cmake | 230 |
1 files changed, 168 insertions, 62 deletions
diff --git a/Modules/FindQt.cmake b/Modules/FindQt.cmake index b9335d0..3a1caca 100644 --- a/Modules/FindQt.cmake +++ b/Modules/FindQt.cmake @@ -6,35 +6,75 @@ # QT_DEFINITIONS, definitions to use when compiling code that uses Qt. # QT_FOUND, If false, don't try to use Qt. +#if you need the multithreaded version of Qt, set QT_MT_REQUIRED to TRUE + # also defined, but not for general use are # QT_MOC_EXECUTABLE, where to find the moc tool. # QT_UIC_EXECUTABLE, where to find the uic tool. # QT_QT_LIBRARY, where to find the Qt library. # QT_QTMAIN_LIBRARY, where to find the qtmain library. This is only required by Qt3 on Windows. - - +MESSAGE(STATUS "Checking for Qt") FIND_PATH(QT_INCLUDE_DIR qt.h $ENV{QTDIR}/include /usr/local/qt/include /usr/local/include - /usr/include/qt3 + /usr/lib/qt/include /usr/include/qt /usr/include + /usr/share/qt3/include C:/Progra~1/qt/include + /usr/include/qt3 ) -FIND_LIBRARY(QT_QT_LIBRARY - NAMES qt qt-mt qt-mt230nc - PATHS - $ENV{QTDIR}/lib - /usr/local/qt/lib - /usr/local/lib - /usr/lib - /usr/share/qt3/lib - C:/Progra~1/qt/lib - ) +IF(QT_INCLUDE_DIR) + MESSAGE(STATUS "Found Qt header files in ${QT_INCLUDE_DIR}") + + #extract the version string from qglobal.h + FILE(READ ${QT_INCLUDE_DIR}/qglobal.h QGLOBAL_H) + STRING(REGEX REPLACE ".*#define[\\t\\ ]+QT_VERSION_STR[\\t\\ ]+\"([0-9]+\\.[0-9]+\\.[0-9]+)\".*" "\\1" qt_version_str "${QGLOBAL_H}") + # Under windows the qt library (MSVC) has the format qt-mtXYZ where XYZ is the + # version X.Y.Z, so we need to remove the dots from version + STRING(REGEX REPLACE "\\." "" qt_version_str_lib "${qt_version_str}") +ELSE(QT_INCLUDE_DIR) + MESSAGE(STATUS "Did not find Qt headers (qglobal.h)") +ENDIF(QT_INCLUDE_DIR) + + +IF (QT_MT_REQUIRED) + FIND_LIBRARY(QT_QT_LIBRARY + NAMES qt-mt qt-mt${qt_version_str_lib} qt-mt230nc + PATHS + $ENV{QTDIR}/lib + /usr/local/qt/lib + /usr/local/lib + /usr/lib/qt/lib + /usr/lib + /usr/share/qt3/lib + C:/Progra~1/qt/lib + ) + +ELSE (QT_MT_REQUIRED) + FIND_LIBRARY(QT_QT_LIBRARY + NAMES qt qt-${qt_version_str_lib} qt-mt qt-mt230nc + PATHS + $ENV{QTDIR}/lib + /usr/local/qt/lib + /usr/local/lib + /usr/lib/qt/lib + /usr/lib + /usr/share/qt3/lib + C:/Progra~1/qt/lib + ) +ENDIF (QT_MT_REQUIRED) + +IF(QT_QT_LIBRARY) + MESSAGE(STATUS "Found Qt library: ${QT_QT_LIBRARY}") +ELSE(QT_QT_LIBRARY) + MESSAGE(STATUS "Did not find Qt library") +ENDIF(QT_QT_LIBRARY) + FIND_LIBRARY(QT_QASSISTANTCLIENT_LIBRARY NAMES qassistantclient @@ -50,17 +90,34 @@ FIND_LIBRARY(QT_QASSISTANTCLIENT_LIBRARY FIND_PROGRAM(QT_MOC_EXECUTABLE NAMES moc moc-qt3 PATHS - $ENV{QTDIR}/bin - "C:/Program Files/qt/bin" - C:/Progra~1/qt/bin - /usr/bin - + $ENV{QTDIR}/bin + /usr/local/qt/bin + /usr/lib/qt/bin + /usr/share/qt3/bin + C:/Progra~1/qt/bin ) -FIND_PROGRAM(QT_UIC_EXECUTABLE uic - $ENV{QTDIR}/bin C:/Progra~1/qt/bin /usr/bin - ) +IF(QT_MOC_EXECUTABLE) + MESSAGE(STATUS "Found Qt moc executable ${QT_MOC_EXECUTABLE}") + SET ( QT_WRAP_CPP "YES") +ELSE(QT_MOC_EXECUTABLE) + MESSAGE(STATUS "Did not find Qt moc executable") +ENDIF(QT_MOC_EXECUTABLE) +FIND_PROGRAM(QT_UIC_EXECUTABLE uic + $ENV{QTDIR}/bin + /usr/local/qt/bin + /usr/lib/qt/bin + /usr/share/qt3/bin + C:/Progra~1/qt/bin +) + +IF(QT_UIC_EXECUTABLE) + MESSAGE(STATUS "Found Qt uic executable ${QT_UIC_EXECUTABLE}") + SET ( QT_WRAP_UI "YES") +ELSE(QT_UIC_EXECUTABLE) + MESSAGE(STATUS "Did not find Qt uic executable") +ENDIF(QT_UIC_EXECUTABLE) IF (WIN32) FIND_LIBRARY(QT_QTMAIN_LIBRARY qtmain @@ -70,54 +127,103 @@ IF (WIN32) ENDIF (WIN32) +IF (QT_MIN_VERSION) + STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" qt_major_vers "${qt_version_str}") + STRING(REGEX REPLACE "[0-9]+\\.([0-9]+)\\.[0-9]+" "\\1" qt_minor_vers "${qt_version_str}") + STRING(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" qt_patch_vers "${qt_version_str}") + + #now parse the parts of the user given version string into variables + STRING(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+$" req_qt_major_vers "${QT_MIN_VERSION}") + IF (NOT req_qt_major_vers) + MESSAGE( FATAL_ERROR "Invalid Qt version string given: \"${QT_MIN_VERSION}\", expected e.g. \"3.1.5\"") + ENDIF (NOT req_qt_major_vers) + + STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" req_qt_major_vers "${QT_MIN_VERSION}") + STRING(REGEX REPLACE "[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" req_qt_minor_vers "${QT_MIN_VERSION}") + STRING(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" req_qt_patch_vers "${QT_MIN_VERSION}") + + # req = "6.5.4", qt = "3.2.1" + + IF (req_qt_major_vers GREATER qt_major_vers) # (6 > 3) ? + MESSAGE( FATAL_ERROR "Qt major version not matched (required: ${QT_MIN_VERSION}, found: ${qt_version_str})") # yes + ELSE (req_qt_major_vers GREATER qt_major_vers) # no + IF (req_qt_major_vers LESS qt_major_vers) # (6 < 3) ? + SET( QT_VERSION_BIG_ENOUGH "YES" ) # yes + ELSE (req_qt_major_vers LESS qt_major_vers) # ( 6==3) ? + IF (req_qt_minor_vers GREATER qt_minor_vers) # (5>2) ? + MESSAGE( FATAL_ERROR "Qt minor version not matched (required: ${QT_MIN_VERSION}, found: ${qt_version_str})") # yes + ELSE (req_qt_minor_vers GREATER qt_minor_vers) # no + IF (req_qt_minor_vers LESS qt_minor_vers) # (5<2) ? + SET( QT_VERSION_BIG_ENOUGH "YES" ) # yes + ELSE (req_qt_minor_vers LESS qt_minor_vers) # (5==2) + IF (req_qt_patch_vers GREATER qt_patch_vers) # (4>1) ? + MESSAGE( FATAL_ERROR "Qt patch level not matched (required: ${QT_MIN_VERSION}, found: ${qt_version_str})") # yes + ELSE (req_qt_patch_vers GREATER qt_patch_vers) # (4>1) ? + SET( QT_VERSION_BIG_ENOUGH "YES" ) # yes + ENDIF (req_qt_patch_vers GREATER qt_patch_vers) # (4>1) ? + ENDIF (req_qt_minor_vers LESS qt_minor_vers) + ENDIF (req_qt_minor_vers GREATER qt_minor_vers) + ENDIF (req_qt_major_vers LESS qt_major_vers) + ENDIF (req_qt_major_vers GREATER qt_major_vers) + MESSAGE(STATUS "Qt version ok (required: ${QT_MIN_VERSION}, found: ${qt_version_str})") +ENDIF (QT_MIN_VERSION) + +# if the include a library are found then we have it IF(QT_INCLUDE_DIR) IF(QT_QT_LIBRARY) - SET( QT_LIBRARIES ${QT_LIBRARIES} ${QT_QT_LIBRARY} ) SET( QT_FOUND "YES" ) - SET( QT_DEFINITIONS "") - - IF (WIN32) - IF (QT_QTMAIN_LIBRARY) - # for version 3 - SET (QT_DEFINITIONS -DQT_DLL) - SET (QT_DEFINITIONS "-DQT_DLL -DQT_THREAD_SUPPORT -DNO_DEBUG") - SET (QT_LIBRARIES imm32.lib ${QT_QT_LIBRARY} ${QT_QTMAIN_LIBRARY} ) - SET (QT_LIBRARIES ${QT_LIBRARIES} winmm wsock32) - ELSE (QT_QTMAIN_LIBRARY) - # for version 2 - SET (QT_LIBRARIES imm32.lib ws2_32.lib ${QT_QT_LIBRARY} ) - ENDIF (QT_QTMAIN_LIBRARY) - ELSE (WIN32) - SET (QT_LIBRARIES ${QT_QT_LIBRARY} ) - ENDIF (WIN32) - - IF (QT_QASSISTANTCLIENT_LIBRARY) - SET (QT_LIBRARIES ${QT_QASSISTANTCLIENT_LIBRARY} ${QT_LIBRARIES}) - ENDIF (QT_QASSISTANTCLIENT_LIBRARY) - - - - # Backwards compatibility for CMake1.4 and 1.2 - SET (QT_MOC_EXE ${QT_MOC_EXECUTABLE} ) - SET (QT_UIC_EXE ${QT_UIC_EXECUTABLE} ) - - IF(UNIX) - INCLUDE( ${CMAKE_ROOT}/Modules/FindX11.cmake ) - IF (X11_FOUND) - SET (QT_LIBRARIES ${QT_LIBRARIES} ${X11_LIBRARIES}) - ENDIF (X11_FOUND) - IF (CMAKE_DL_LIBS) - SET (QT_LIBRARIES ${QT_LIBRARIES} ${CMAKE_DL_LIBS}) - ENDIF (CMAKE_DL_LIBS) - ENDIF(UNIX) + ENDIF(QT_QT_LIBRARY) +ENDIF(QT_INCLUDE_DIR) + +IF(QT_FOUND) + SET( QT_LIBRARIES ${QT_LIBRARIES} ${QT_QT_LIBRARY} ) + SET( QT_DEFINITIONS "") + + IF (WIN32) + IF (QT_QTMAIN_LIBRARY) + # for version 3 + SET (QT_DEFINITIONS "-DQT_DLL -DQT_THREAD_SUPPORT -DNO_DEBUG") + SET (QT_LIBRARIES imm32.lib ${QT_QT_LIBRARY} ${QT_QTMAIN_LIBRARY} ) + SET (QT_LIBRARIES ${QT_LIBRARIES} winmm wsock32) + ELSE (QT_QTMAIN_LIBRARY) + # for version 2 + SET (QT_LIBRARIES imm32.lib ws2_32.lib ${QT_QT_LIBRARY} ) + ENDIF (QT_QTMAIN_LIBRARY) + ELSE (WIN32) + SET (QT_LIBRARIES ${QT_QT_LIBRARY} ) + + SET (QT_DEFINITIONS "-DQT_SHARED -DQT_NO_DEBUG") IF(QT_QT_LIBRARY MATCHES "qt-mt") - INCLUDE( ${CMAKE_ROOT}/Modules/FindThreads.cmake ) - SET(QT_LIBRARIES ${QT_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) + SET (QT_DEFINITIONS ${QT_DEFINITIONS} -DQT_THREAD_SUPPORT -D_REENTRANT) ENDIF(QT_QT_LIBRARY MATCHES "qt-mt") + + ENDIF (WIN32) + + IF (QT_QASSISTANTCLIENT_LIBRARY) + SET (QT_LIBRARIES ${QT_QASSISTANTCLIENT_LIBRARY} ${QT_LIBRARIES}) + ENDIF (QT_QASSISTANTCLIENT_LIBRARY) + + # Backwards compatibility for CMake1.4 and 1.2 + SET (QT_MOC_EXE ${QT_MOC_EXECUTABLE} ) + SET (QT_UIC_EXE ${QT_UIC_EXECUTABLE} ) + # for unix add X11 stuff + IF(UNIX) + INCLUDE( ${CMAKE_ROOT}/Modules/FindX11.cmake ) + IF (X11_FOUND) + SET (QT_LIBRARIES ${QT_LIBRARIES} ${X11_LIBRARIES}) + ENDIF (X11_FOUND) + IF (CMAKE_DL_LIBS) + SET (QT_LIBRARIES ${QT_LIBRARIES} ${CMAKE_DL_LIBS}) + ENDIF (CMAKE_DL_LIBS) + ENDIF(UNIX) + IF(QT_QT_LIBRARY MATCHES "qt-mt") + INCLUDE( ${CMAKE_ROOT}/Modules/FindThreads.cmake ) + SET(QT_LIBRARIES ${QT_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) + ENDIF(QT_QT_LIBRARY MATCHES "qt-mt") +ENDIF(QT_FOUND) + - ENDIF(QT_QT_LIBRARY) -ENDIF(QT_INCLUDE_DIR) MARK_AS_ADVANCED( |