ENH: Make Qt not found if the QtCore library can't be found.

Also report an error when trying to use MSVC with Qt built by mingw.
This commit is contained in:
Clinton Stimpson 2008-05-21 13:36:37 -04:00
parent e25a9a4169
commit db52ce45fa
1 changed files with 17 additions and 3 deletions

View File

@ -267,6 +267,7 @@ SET(QT4_INSTALLED_VERSION_TOO_OLD FALSE)
# macro for asking qmake to process pro files # macro for asking qmake to process pro files
MACRO(QT_QUERY_QMAKE outvar invar) MACRO(QT_QUERY_QMAKE outvar invar)
IF(QT_QMAKE_EXECUTABLE)
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake/tmp.pro FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake/tmp.pro
"message(CMAKE_MESSAGE<$$${invar}>)") "message(CMAKE_MESSAGE<$$${invar}>)")
@ -289,6 +290,7 @@ MACRO(QT_QUERY_QMAKE outvar invar)
STRING(REGEX REPLACE ".*CMAKE_MESSAGE<([^>]*).*" "\\1" ${outvar} "${_qmake_query_output}") STRING(REGEX REPLACE ".*CMAKE_MESSAGE<([^>]*).*" "\\1" ${outvar} "${_qmake_query_output}")
ENDIF(_qmake_result) ENDIF(_qmake_result)
ENDIF(QT_QMAKE_EXECUTABLE)
ENDMACRO(QT_QUERY_QMAKE) ENDMACRO(QT_QUERY_QMAKE)
GET_FILENAME_COMPONENT(qt_install_version "[HKEY_CURRENT_USER\\Software\\trolltech\\Versions;DefaultQtVersion]" NAME) GET_FILENAME_COMPONENT(qt_install_version "[HKEY_CURRENT_USER\\Software\\trolltech\\Versions;DefaultQtVersion]" NAME)
@ -760,6 +762,14 @@ IF (QT4_QMAKE_FOUND)
FIND_LIBRARY(QT_QTSCRIPT_LIBRARY_DEBUG NAMES QtScript_debug QtScriptd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) FIND_LIBRARY(QT_QTSCRIPT_LIBRARY_DEBUG NAMES QtScript_debug QtScriptd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
IF( NOT QT_QTCORE_LIBRARY_DEBUG AND NOT QT_QTCORE_LIBRARY_RELEASE ) IF( NOT QT_QTCORE_LIBRARY_DEBUG AND NOT QT_QTCORE_LIBRARY_RELEASE )
# try dropping a hint if trying to use Visual Studio with Qt built by mingw
IF(QT_LIBRARY_DIR AND MSVC)
IF(EXISTS ${QT_LIBRARY_DIR}/libqtmain.a)
MESSAGE( FATAL_ERROR "It appears you're trying to use Visual Studio with Qt built by mingw")
ENDIF(EXISTS ${QT_LIBRARY_DIR}/libqtmain.a)
ENDIF(QT_LIBRARY_DIR AND MSVC)
IF( NOT Qt4_FIND_QUIETLY AND Qt4_FIND_REQUIRED) IF( NOT Qt4_FIND_QUIETLY AND Qt4_FIND_REQUIRED)
MESSAGE( FATAL_ERROR "Could NOT find QtCore. Check ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log for more details.") MESSAGE( FATAL_ERROR "Could NOT find QtCore. Check ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log for more details.")
ENDIF( NOT Qt4_FIND_QUIETLY AND Qt4_FIND_REQUIRED) ENDIF( NOT Qt4_FIND_QUIETLY AND Qt4_FIND_REQUIRED)
@ -1305,18 +1315,22 @@ IF (QT4_QMAKE_FOUND)
###################################### ######################################
# if the includes,libraries,moc,uic and rcc are found then we have it # if the includes,libraries,moc,uic and rcc are found then we have it
IF( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE) IF( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND
QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE AND QT_QTCORE_LIBRARY)
SET( QT4_FOUND "YES" ) SET( QT4_FOUND "YES" )
INCLUDE(FindPackageMessage) INCLUDE(FindPackageMessage)
FIND_PACKAGE_MESSAGE(Qt4 "Found Qt-Version ${QTVERSION}" FIND_PACKAGE_MESSAGE(Qt4 "Found Qt-Version ${QTVERSION}"
"[${QT_LIBRARY_DIR}][${QT_INCLUDE_DIR}][${QT_MOC_EXECUTABLE}][${QT_UIC_EXECUTABLE}][${QT_RCC_EXECUTABLE}]") "[${QT_LIBRARY_DIR}][${QT_INCLUDE_DIR}][${QT_MOC_EXECUTABLE}][${QT_UIC_EXECUTABLE}][${QT_RCC_EXECUTABLE}]")
ELSE( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE) ELSE( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND
QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE AND QT_QTCORE_LIBRARY)
SET( QT4_FOUND "NO") SET( QT4_FOUND "NO")
SET(QT_QMAKE_EXECUTABLE "${QT_QMAKE_EXECUTABLE}-NOTFOUND" CACHE FILEPATH "Invalid qmake found" FORCE) SET(QT_QMAKE_EXECUTABLE "${QT_QMAKE_EXECUTABLE}-NOTFOUND" CACHE FILEPATH "Invalid qmake found" FORCE)
IF( Qt4_FIND_REQUIRED) IF( Qt4_FIND_REQUIRED)
MESSAGE( FATAL_ERROR "Qt libraries, includes, moc, uic or/and rcc NOT found!") MESSAGE( FATAL_ERROR "Qt libraries, includes, moc, uic or/and rcc NOT found!")
ENDIF( Qt4_FIND_REQUIRED) ENDIF( Qt4_FIND_REQUIRED)
ENDIF( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE) ENDIF( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND
QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE AND QT_QTCORE_LIBRARY)
SET(QT_FOUND ${QT4_FOUND}) SET(QT_FOUND ${QT4_FOUND})