2016-09-27 19:01:08 +00:00
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
2018-10-22 14:31:08 +00:00
#[=======================================================================[.rst:
F i n d Q t
- - - - - -
S e a r c h e s f o r a l l i n s t a l l e d v e r s i o n s o f Q t 3 o r Q t 4 .
T h i s m o d u l e c a n n o t h a n d l e Q t 5 o r a n y l a t e r v e r s i o n s .
F o r t h o s e , s e e : m a n u a l : ` c m a k e - qt ( 7 ) ` .
2018-10-31 17:26:04 +00:00
T h i s m o d u l e e x i s t s f o r t h e : c o m m a n d : ` f i n d _ p a c k a g e ` c o m m a n d o n l y i f
p o l i c y : p o l i c y : ` C M P 0 0 8 4 ` i s n o t s e t t o ` ` N E W ` ` .
2018-10-22 14:31:08 +00:00
T h i s m o d u l e s h o u l d o n l y b e u s e d i f y o u r p r o j e c t c a n w o r k w i t h m u l t i p l e
v e r s i o n s o f Q t . I f n o t , y o u s h o u l d j u s t d i r e c t l y u s e F i n d Q t 4 o r
F i n d Q t 3 . I f m u l t i p l e v e r s i o n s o f Q t a r e f o u n d o n t h e m a c h i n e , t h e n
T h e u s e r m u s t s e t t h e o p t i o n D E S I R E D _ Q T _ V E R S I O N t o t h e v e r s i o n t h e y
w a n t t o u s e . I f o n l y o n e v e r s i o n o f q t i s f o u n d o n t h e m a c h i n e , t h e n
t h e D E S I R E D _ Q T _ V E R S I O N i s s e t t o t h a t v e r s i o n a n d t h e m a t c h i n g F i n d Q t 3
o r F i n d Q t 4 m o d u l e i s i n c l u d e d . O n c e t h e u s e r s e t s D E S I R E D _ Q T _ V E R S I O N ,
t h e n t h e F i n d Q t 3 o r F i n d Q t 4 m o d u l e i s i n c l u d e d .
: :
Q T _ R E Q U I R E D i f t h i s i s s e t t o T R U E t h e n i f C M a k e c a n
n o t f i n d Q t 4 o r Q t 3 a n e r r o r i s r a i s e d
a n d a m e s s a g e i s s e n t t o t h e u s e r .
: :
D E S I R E D _ Q T _ V E R S I O N O P T I O N i s c r e a t e d
Q T 4 _ I N S T A L L E D i s s e t t o T R U E i f q t 4 i s f o u n d .
Q T 3 _ I N S T A L L E D i s s e t t o T R U E i f q t 3 i s f o u n d .
#]=======================================================================]
2005-07-15 16:14:47 +00:00
2018-10-31 17:26:04 +00:00
if ( _findqt_testing )
set ( _findqt_included TRUE )
return ( )
endif ( )
2005-09-09 21:04:28 +00:00
# look for signs of qt3 installations
2012-10-24 17:52:58 +00:00
file ( GLOB GLOB_TEMP_VAR /usr/lib*/qt-3*/bin/qmake /usr/lib*/qt3*/bin/qmake )
2012-08-13 17:47:32 +00:00
if ( GLOB_TEMP_VAR )
set ( QT3_INSTALLED TRUE )
2012-08-13 17:50:14 +00:00
endif ( )
2012-08-13 17:47:32 +00:00
set ( GLOB_TEMP_VAR )
2005-09-09 21:04:28 +00:00
2012-08-13 17:47:32 +00: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 17:50:14 +00:00
endif ( )
2012-08-13 17:47:32 +00:00
set ( GLOB_TEMP_VAR )
2005-09-09 21:04:28 +00:00
2012-12-05 17:36:14 +00:00
file ( GLOB GLOB_TEMP_VAR /usr/local/lib/qt3/bin/qmake )
if ( GLOB_TEMP_VAR )
set ( QT3_INSTALLED TRUE )
endif ( )
set ( GLOB_TEMP_VAR )
2005-09-09 21:04:28 +00:00
# look for qt4 installations
2012-08-13 17:47:32 +00: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 17:50:14 +00:00
endif ( )
2012-08-13 17:47:32 +00:00
set ( GLOB_TEMP_VAR )
2005-09-09 21:04:28 +00:00
2012-08-13 17:47:32 +00:00
file ( GLOB GLOB_TEMP_VAR /usr/local/Trolltech/Qt-4*/bin/qmake )
if ( GLOB_TEMP_VAR )
set ( QT4_INSTALLED TRUE )
2012-08-13 17:50:14 +00:00
endif ( )
2012-08-13 17:47:32 +00:00
set ( GLOB_TEMP_VAR )
2005-09-09 21:04:28 +00:00
2012-12-05 17:36:14 +00:00
file ( GLOB GLOB_TEMP_VAR /usr/local/lib/qt4/bin/qmake )
if ( GLOB_TEMP_VAR )
set ( QT4_INSTALLED TRUE )
endif ( )
set ( GLOB_TEMP_VAR )
2012-10-24 17:50:47 +00:00
if ( Qt_FIND_VERSION )
2015-01-16 19:50:15 +00:00
if ( Qt_FIND_VERSION MATCHES "^([34])(\\.[0-9]+.*)?$" )
set ( DESIRED_QT_VERSION ${ CMAKE_MATCH_1 } )
else ( )
message ( FATAL_ERROR "FindQt was called with invalid version '${Qt_FIND_VERSION}'. Only Qt major versions 3 or 4 are supported. If you do not need to support both Qt3 and Qt4 in your source consider calling find_package(Qt3) or find_package(Qt4) instead of find_package(Qt) instead." )
endif ( )
2012-10-24 17:50:47 +00:00
endif ( )
2005-09-09 21:04:28 +00:00
# now find qmake
2012-08-13 17:47:32 +00: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-09 21:04:28 +00:00
O U T P U T _ V A R I A B L E Q T V E R S I O N )
2014-04-11 16:17:46 +00:00
if ( QTVERSION MATCHES "4" )
2012-08-28 09:22:17 +00:00
set ( QT_QMAKE_EXECUTABLE ${ QT_QMAKE_EXECUTABLE_FINDQT } CACHE PATH "Qt4 qmake program." )
2012-08-13 17:47:32 +00:00
set ( QT4_INSTALLED TRUE )
2012-08-13 17:50:14 +00:00
endif ( )
2012-08-13 17:47:32 +00:00
if ( QTVERSION MATCHES "Unknown" )
set ( QT3_INSTALLED TRUE )
2012-08-13 17:50:14 +00:00
endif ( )
endif ( )
2005-09-09 21:04:28 +00:00
2012-08-13 17:47:32 +00:00
if ( QT_QMAKE_EXECUTABLE_FINDQT )
exec_program ( ${ QT_QMAKE_EXECUTABLE_FINDQT }
2012-08-13 17:42:58 +00: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-09 21:04:28 +00: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 17:50:14 +00:00
endif ( )
2005-09-09 21:04:28 +00:00
2012-08-13 17:47:32 +00:00
find_file ( QT4_QGLOBAL_H_FILE qglobal.h
2005-09-10 01:51:23 +00: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 15:43:24 +00: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-09 21:04:28 +00: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 i b / q t / 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
2012-12-05 17:36:14 +00:00
/ u s r / l o c a l / i n c l u d e / X 1 1 / q t 4 / Q t
2017-11-20 15:29:25 +00:00
C : / P r o g r a ~ 1 / q t / i n c l u d e / Q t
P A T H _ S U F F I X E S q t / i n c l u d e / Q t i n c l u d e / Q t )
2005-09-09 21:04:28 +00:00
2012-08-13 17:47:32 +00:00
if ( QT4_QGLOBAL_H_FILE )
set ( QT4_INSTALLED TRUE )
2012-08-13 17:50:14 +00:00
endif ( )
2005-09-09 21:04:28 +00:00
2012-08-13 17:47:32 +00:00
find_file ( QT3_QGLOBAL_H_FILE qglobal.h
2012-08-13 17:42:58 +00: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 01:51:23 +00: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-09 21:04:28 +00: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 / s h a r e / q t 3 / i n c l u d e
2012-12-05 17:36:14 +00:00
/ u s r / l o c a l / i n c l u d e / X 1 1 / q t 3
2005-09-09 21:04:28 +00:00
C : / P r o g r a ~ 1 / q t / i n c l u d e
2017-11-20 15:29:25 +00:00
P A T H _ S U F F I X E S q t / i n c l u d e i n c l u d e / q t 3 )
2005-09-09 21:04:28 +00:00
2012-08-13 17:47:32 +00:00
if ( QT3_QGLOBAL_H_FILE )
set ( QT3_INSTALLED TRUE )
2012-08-13 17:50:14 +00:00
endif ( )
2005-09-09 21:04:28 +00:00
2012-10-24 17:50:47 +00:00
if ( QT3_INSTALLED AND QT4_INSTALLED AND NOT DESIRED_QT_VERSION )
2005-09-09 21:04:28 +00:00
# force user to pick if we have both
2012-08-28 09:22:17 +00:00
set ( DESIRED_QT_VERSION 0 CACHE STRING "Pick a version of Qt to use: 3 or 4" )
2012-08-13 17:50:14 +00:00
else ( )
2005-09-09 21:04:28 +00:00
# if only one found then pick that one
2012-10-24 17:50:47 +00:00
if ( QT3_INSTALLED AND NOT DESIRED_QT_VERSION EQUAL 4 )
2012-08-28 09:22:17 +00:00
set ( DESIRED_QT_VERSION 3 CACHE STRING "Pick a version of Qt to use: 3 or 4" )
2012-08-13 17:50:14 +00:00
endif ( )
2012-10-24 17:50:47 +00:00
if ( QT4_INSTALLED AND NOT DESIRED_QT_VERSION EQUAL 3 )
2012-08-28 09:22:17 +00:00
set ( DESIRED_QT_VERSION 4 CACHE STRING "Pick a version of Qt to use: 3 or 4" )
2012-08-13 17:50:14 +00:00
endif ( )
endif ( )
2005-09-09 21:04:28 +00:00
2014-04-11 16:49:03 +00:00
if ( DESIRED_QT_VERSION EQUAL 3 )
2012-08-13 17:47:32 +00:00
set ( Qt3_FIND_REQUIRED ${ Qt_FIND_REQUIRED } )
set ( Qt3_FIND_QUIETLY ${ Qt_FIND_QUIETLY } )
2012-11-03 20:35:44 +00:00
include ( ${ CMAKE_CURRENT_LIST_DIR } /FindQt3.cmake )
2012-08-13 17:50:14 +00:00
endif ( )
2014-04-11 16:49:03 +00:00
if ( DESIRED_QT_VERSION EQUAL 4 )
2012-08-13 17:47:32 +00:00
set ( Qt4_FIND_REQUIRED ${ Qt_FIND_REQUIRED } )
set ( Qt4_FIND_QUIETLY ${ Qt_FIND_QUIETLY } )
2012-11-03 20:35:44 +00:00
include ( ${ CMAKE_CURRENT_LIST_DIR } /FindQt4.cmake )
2012-08-13 17:50:14 +00:00
endif ( )
2005-09-09 21:04:28 +00:00
2012-08-13 17:47:32 +00:00
if ( NOT QT3_INSTALLED AND NOT QT4_INSTALLED )
if ( QT_REQUIRED )
2012-08-28 09:22:17 +00: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 17:50:14 +00:00
endif ( )
else ( )
2012-08-13 17:47:32 +00:00
if ( NOT QT_FOUND AND NOT DESIRED_QT_VERSION )
if ( QT_REQUIRED )
2012-08-28 09:22:17 +00:00
message ( SEND_ERROR "Multiple versions of Qt found please set DESIRED_QT_VERSION" )
2012-08-13 17:50:14 +00:00
else ( )
2012-08-28 09:22:17 +00:00
message ( "Multiple versions of Qt found please set DESIRED_QT_VERSION" )
2012-08-13 17:50:14 +00:00
endif ( )
endif ( )
2012-08-13 17:47:32 +00:00
if ( NOT QT_FOUND AND DESIRED_QT_VERSION )
if ( QT_REQUIRED )
2015-01-16 19:59:12 +00: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_H_FILE, if those are set then QT_QT_LIBRARY or QT_LIBRARY_DIR." )
2012-08-13 17:50:14 +00:00
else ( )
2015-01-16 19:59:12 +00: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_H_FILE." )
2012-08-13 17:50:14 +00:00
endif ( )
endif ( )
endif ( )
2012-08-13 17:47:32 +00:00
mark_as_advanced ( QT3_QGLOBAL_H_FILE QT4_QGLOBAL_H_FILE QT_QMAKE_EXECUTABLE_FINDQT )