2012-08-28 13:22:17 +04:00
# - Searches for all installed versions of Qt.
2005-09-10 01:04:28 +04:00
# This should only be used if your project can work with multiple
2012-08-28 13:22:17 +04:00
# versions of Qt. If not, you should just directly use FindQt4 or FindQt3.
# If multiple versions of Qt are found on the machine, then
2005-12-14 21:51:08 +03:00
# The user must set the option DESIRED_QT_VERSION to the version
# they want to use. If only one version of qt is found on the machine,
2012-08-13 21:42:58 +04:00
# then the DESIRED_QT_VERSION is set to that version and the
2005-12-14 21:51:08 +03:00
# matching FindQt3 or FindQt4 module is included.
# Once the user sets DESIRED_QT_VERSION, then the FindQt3 or FindQt4 module
# is included.
2005-09-10 01:04:28 +04:00
#
2012-08-13 21:42:58 +04:00
# QT_REQUIRED if this is set to TRUE then if CMake can
2012-08-28 13:22:17 +04:00
# not find Qt4 or Qt3 an error is raised
2005-12-15 22:17:43 +03:00
# and a message is sent to the user.
#
2005-09-10 01:04:28 +04:00
# DESIRED_QT_VERSION OPTION is created
# QT4_INSTALLED is set to TRUE if qt4 is found.
# QT3_INSTALLED is set to TRUE if qt3 is found.
2005-07-15 20:14:47 +04:00
2009-09-28 19:45:50 +04:00
#=============================================================================
# Copyright 2001-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
2010-08-07 04:48:47 +04:00
# (To distribute this file outside of CMake, substitute the full
2009-09-28 19:45:50 +04:00
# License text for the above reference.)
2005-12-14 21:51:08 +03:00
2005-09-10 01:04:28 +04:00
# look for signs of qt3 installations
2012-10-24 21:52:58 +04:00
file ( GLOB GLOB_TEMP_VAR /usr/lib*/qt-3*/bin/qmake /usr/lib*/qt3*/bin/qmake )
2012-08-13 21:47:32 +04:00
if ( GLOB_TEMP_VAR )
set ( QT3_INSTALLED TRUE )
2012-08-13 21:50:14 +04:00
endif ( )
2012-08-13 21:47:32 +04:00
set ( GLOB_TEMP_VAR )
2005-09-10 01:04:28 +04:00
2012-08-13 21:47:32 +04:00
file ( GLOB GLOB_TEMP_VAR /usr/local/qt-x11-commercial-3*/bin/qmake )
if ( GLOB_TEMP_VAR )
set ( QT3_INSTALLED TRUE )
2012-08-13 21:50:14 +04:00
endif ( )
2012-08-13 21:47:32 +04:00
set ( GLOB_TEMP_VAR )
2005-09-10 01:04:28 +04:00
# look for qt4 installations
2012-08-13 21:47:32 +04:00
file ( GLOB GLOB_TEMP_VAR /usr/local/qt-x11-commercial-4*/bin/qmake )
if ( GLOB_TEMP_VAR )
set ( QT4_INSTALLED TRUE )
2012-08-13 21:50:14 +04:00
endif ( )
2012-08-13 21:47:32 +04:00
set ( GLOB_TEMP_VAR )
2005-09-10 01:04:28 +04:00
2012-08-13 21:47:32 +04:00
file ( GLOB GLOB_TEMP_VAR /usr/local/Trolltech/Qt-4*/bin/qmake )
if ( GLOB_TEMP_VAR )
set ( QT4_INSTALLED TRUE )
2012-08-13 21:50:14 +04:00
endif ( )
2012-08-13 21:47:32 +04:00
set ( GLOB_TEMP_VAR )
2005-09-10 01:04:28 +04:00
2012-10-24 21:50:47 +04:00
if ( Qt_FIND_VERSION )
set ( DESIRED_QT_VERSION "${Qt_FIND_VERSION}" )
endif ( )
2005-09-10 01:04:28 +04:00
# now find qmake
2012-08-13 21:47:32 +04:00
find_program ( QT_QMAKE_EXECUTABLE_FINDQT NAMES qmake PATHS "${QT_SEARCH_PATH}/bin" "$ENV{QTDIR}/bin" )
if ( QT_QMAKE_EXECUTABLE_FINDQT )
exec_program ( ${ QT_QMAKE_EXECUTABLE_FINDQT } ARGS "-query QT_VERSION"
2005-09-10 01:04:28 +04:00
O U T P U T _ V A R I A B L E Q T V E R S I O N )
2012-08-13 21:47:32 +04:00
if ( QTVERSION MATCHES "4.*" )
2012-08-28 13:22:17 +04:00
set ( QT_QMAKE_EXECUTABLE ${ QT_QMAKE_EXECUTABLE_FINDQT } CACHE PATH "Qt4 qmake program." )
2012-08-13 21:47:32 +04:00
set ( QT4_INSTALLED TRUE )
2012-08-13 21:50:14 +04:00
endif ( )
2012-08-13 21:47:32 +04:00
if ( QTVERSION MATCHES "Unknown" )
set ( QT3_INSTALLED TRUE )
2012-08-13 21:50:14 +04:00
endif ( )
endif ( )
2005-09-10 01:04:28 +04:00
2012-08-13 21:47:32 +04:00
if ( QT_QMAKE_EXECUTABLE_FINDQT )
exec_program ( ${ QT_QMAKE_EXECUTABLE_FINDQT }
2012-08-13 21:42:58 +04:00
A R G S " - q u e r y Q T _ I N S T A L L _ H E A D E R S "
2005-09-10 01:04:28 +04:00
O U T P U T _ V A R I A B L E q t _ h e a d e r s )
2012-08-13 21:50:14 +04:00
endif ( )
2005-09-10 01:04:28 +04:00
2012-08-13 21:47:32 +04:00
find_file ( QT4_QGLOBAL_H_FILE qglobal.h
2005-09-10 05:51:23 +04:00
" $ { Q T _ S E A R C H _ P A T H } / Q t / i n c l u d e "
" [ H K E Y _ C U R R E N T _ U S E R \ \ S o f t w a r e \ \ T r o l l t e c h \ \ Q t 3 V e r s i o n s \ \ 4 . 0 . 0 ; I n s t a l l D i r ] / i n c l u d e / Q t "
2005-09-12 19:43:24 +04:00
" [ H K E Y _ C U R R E N T _ U S E R \ \ S o f t w a r e \ \ T r o l l t e c h \ \ V e r s i o n s \ \ 4 . 0 . 0 ; I n s t a l l D i r ] / i n c l u d e / Q t "
2005-09-10 01:04:28 +04:00
$ { q t _ h e a d e r s } / Q t
$ E N V { Q T D I R } / i n c l u d e / Q t
/ u s r / l o c a l / q t / i n c l u d e / Q t
/ u s r / l o c a l / i n c l u d e / Q t
/ u s r / l i b / q t / i n c l u d e / Q t
/ u s r / i n c l u d e / Q t
/ u s r / s h a r e / q t 4 / i n c l u d e / Q t
2005-09-10 05:51:23 +04:00
C : / P r o g r a ~ 1 / q t / i n c l u d e / Q t )
2005-09-10 01:04:28 +04:00
2012-08-13 21:47:32 +04:00
if ( QT4_QGLOBAL_H_FILE )
set ( QT4_INSTALLED TRUE )
2012-08-13 21:50:14 +04:00
endif ( )
2005-09-10 01:04:28 +04:00
2012-08-13 21:47:32 +04:00
find_file ( QT3_QGLOBAL_H_FILE qglobal.h
2012-08-13 21:42:58 +04:00
" $ { Q T _ S E A R C H _ P A T H } / Q t / i n c l u d e "
2005-09-10 05:51:23 +04:00
" [ H K E Y _ C U R R E N T _ U S E R \ \ S o f t w a r e \ \ T r o l l t e c h \ \ Q t 3 V e r s i o n s \ \ 3 . 2 . 1 ; I n s t a l l D i r ] / i n c l u d e / Q t "
" [ H K E Y _ C U R R E N T _ U S E R \ \ S o f t w a r e \ \ T r o l l t e c h \ \ Q t 3 V e r s i o n s \ \ 3 . 2 . 0 ; I n s t a l l D i r ] / i n c l u d e / Q t "
" [ H K E Y _ C U R R E N T _ U S E R \ \ S o f t w a r e \ \ T r o l l t e c h \ \ Q t 3 V e r s i o n s \ \ 3 . 1 . 0 ; I n s t a l l D i r ] / i n c l u d e / Q t "
2005-09-10 01:04:28 +04:00
C : / Q t / 3 . 3 . 3 E d u c a t i o n a l / i n c l u d e
$ E N V { Q T D I R } / i n c l u d e
/ u s r / i n c l u d e / q t 3 / Q t
/ u s r / l o c a l / q t / i n c l u d e
/ u s r / l o c a l / i n c l u d e
/ u s r / l i b / q t / i n c l u d e
/ u s r / i n c l u d e
/ u s r / s h a r e / q t 3 / i n c l u d e
C : / P r o g r a ~ 1 / q t / i n c l u d e
/ u s r / i n c l u d e / q t 3 )
2012-08-13 21:47:32 +04:00
if ( QT3_QGLOBAL_H_FILE )
set ( QT3_INSTALLED TRUE )
2012-08-13 21:50:14 +04:00
endif ( )
2005-09-10 01:04:28 +04:00
2012-10-24 21:50:47 +04:00
if ( QT3_INSTALLED AND QT4_INSTALLED AND NOT DESIRED_QT_VERSION )
2005-09-10 01:04:28 +04:00
# force user to pick if we have both
2012-08-28 13:22:17 +04:00
set ( DESIRED_QT_VERSION 0 CACHE STRING "Pick a version of Qt to use: 3 or 4" )
2012-08-13 21:50:14 +04:00
else ( )
2005-09-10 01:04:28 +04:00
# if only one found then pick that one
2012-10-24 21:50:47 +04:00
if ( QT3_INSTALLED AND NOT DESIRED_QT_VERSION EQUAL 4 )
2012-08-28 13:22:17 +04:00
set ( DESIRED_QT_VERSION 3 CACHE STRING "Pick a version of Qt to use: 3 or 4" )
2012-08-13 21:50:14 +04:00
endif ( )
2012-10-24 21:50:47 +04:00
if ( QT4_INSTALLED AND NOT DESIRED_QT_VERSION EQUAL 3 )
2012-08-28 13:22:17 +04:00
set ( DESIRED_QT_VERSION 4 CACHE STRING "Pick a version of Qt to use: 3 or 4" )
2012-08-13 21:50:14 +04:00
endif ( )
endif ( )
2005-09-10 01:04:28 +04:00
2012-08-13 21:47:32 +04:00
if ( DESIRED_QT_VERSION MATCHES 3 )
set ( Qt3_FIND_REQUIRED ${ Qt_FIND_REQUIRED } )
set ( Qt3_FIND_QUIETLY ${ Qt_FIND_QUIETLY } )
2012-11-04 00:35:44 +04:00
include ( ${ CMAKE_CURRENT_LIST_DIR } /FindQt3.cmake )
2012-08-13 21:50:14 +04:00
endif ( )
2012-08-13 21:47:32 +04:00
if ( DESIRED_QT_VERSION MATCHES 4 )
set ( Qt4_FIND_REQUIRED ${ Qt_FIND_REQUIRED } )
set ( Qt4_FIND_QUIETLY ${ Qt_FIND_QUIETLY } )
2012-11-04 00:35:44 +04:00
include ( ${ CMAKE_CURRENT_LIST_DIR } /FindQt4.cmake )
2012-08-13 21:50:14 +04:00
endif ( )
2005-09-10 01:04:28 +04:00
2012-08-13 21:47:32 +04:00
if ( NOT QT3_INSTALLED AND NOT QT4_INSTALLED )
if ( QT_REQUIRED )
2012-08-28 13:22:17 +04:00
message ( SEND_ERROR "CMake was unable to find any Qt versions, put qmake in your path, or set QT_QMAKE_EXECUTABLE." )
2012-08-13 21:50:14 +04:00
endif ( )
else ( )
2012-08-13 21:47:32 +04:00
if ( NOT QT_FOUND AND NOT DESIRED_QT_VERSION )
if ( QT_REQUIRED )
2012-08-28 13:22:17 +04:00
message ( SEND_ERROR "Multiple versions of Qt found please set DESIRED_QT_VERSION" )
2012-08-13 21:50:14 +04:00
else ( )
2012-08-28 13:22:17 +04:00
message ( "Multiple versions of Qt found please set DESIRED_QT_VERSION" )
2012-08-13 21:50:14 +04:00
endif ( )
endif ( )
2012-08-13 21:47:32 +04:00
if ( NOT QT_FOUND AND DESIRED_QT_VERSION )
if ( QT_REQUIRED )
2012-08-28 13:22:17 +04:00
message ( FATAL_ERROR "CMake was unable to find Qt version: ${DESIRED_QT_VERSION}. Set advanced values QT_QMAKE_EXECUTABLE and QT${DESIRED_QT_VERSION}_QGLOBAL_FILE, if those are set then QT_QT_LIBRARY or QT_LIBRARY_DIR." )
2012-08-13 21:50:14 +04:00
else ( )
2012-08-28 13:22:17 +04:00
message ( "CMake was unable to find desired Qt version: ${DESIRED_QT_VERSION}. Set advanced values QT_QMAKE_EXECUTABLE and QT${DESIRED_QT_VERSION}_QGLOBAL_FILE." )
2012-08-13 21:50:14 +04:00
endif ( )
endif ( )
endif ( )
2012-08-13 21:47:32 +04:00
mark_as_advanced ( QT3_QGLOBAL_H_FILE QT4_QGLOBAL_H_FILE QT_QMAKE_EXECUTABLE_FINDQT )