]> SALOME platform Git repositories - modules/yacs.git/blob - salome_adm/unix/config_files/check_qt.m4
Salome HOME
PR: mergefrom_BSEC_br1_14Mar04
[modules/yacs.git] / salome_adm / unix / config_files / check_qt.m4
1 dnl  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 dnl  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
3 dnl 
4 dnl  This library is free software; you can redistribute it and/or 
5 dnl  modify it under the terms of the GNU Lesser General Public 
6 dnl  License as published by the Free Software Foundation; either 
7 dnl  version 2.1 of the License. 
8 dnl 
9 dnl  This library is distributed in the hope that it will be useful, 
10 dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 dnl  Lesser General Public License for more details. 
13 dnl 
14 dnl  You should have received a copy of the GNU Lesser General Public 
15 dnl  License along with this library; if not, write to the Free Software 
16 dnl  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
17 dnl 
18 dnl  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
19 dnl
20 dnl
21 dnl
22
23 AC_DEFUN([CHECK_QT],[
24 AC_REQUIRE([AC_PROG_CC])dnl
25 AC_REQUIRE([AC_PROG_CXX])dnl
26 AC_REQUIRE([AC_PROG_CPP])dnl
27 AC_REQUIRE([AC_PROG_CXXCPP])dnl
28 AC_REQUIRE([CHECK_OPENGL])dnl
29
30 AC_CHECKING(for QT)
31 qt_ok=yes
32
33 AC_LANG_SAVE
34 AC_LANG_CPLUSPLUS
35
36 if test "x$QTDIR" = "x"
37 then
38    AC_MSG_RESULT(please define QTDIR variable)
39    qt_ok=no
40 fi
41
42 if  test "x$qt_ok" = "xyes"
43 then
44   if test -f ${QTDIR}/bin/moc
45   then
46     MOC=${QTDIR}/bin/moc
47   else
48     AC_PATH_PROG(MOC, moc)
49   fi
50   if test "x$MOC" = "x"
51   then
52     qt_ok=no
53     AC_MSG_RESULT(moc qt-compiler not in PATH variable)
54   else
55     qt_ok=yes
56     AC_MSG_RESULT(moc found)
57   fi
58 fi
59
60 if  test "x$qt_ok" = "xyes"
61 then
62   if test -f ${QTDIR}/bin/uic
63   then
64     UIC=${QTDIR}/bin/uic
65   else
66     AC_PATH_PROG(UIC, uic)
67   fi
68   if test "x$UIC" = "x"
69   then
70     qt_ok=no
71     AC_MSG_RESULT(uic qt-interface compiler not in PATH variable)
72   else
73     qt_ok=yes
74     AC_MSG_RESULT(uic found)
75   fi
76 fi
77
78 AC_SUBST(QTDIR)
79 QT_ROOT=$QTDIR
80
81 if  test "x$qt_ok" = "xyes"
82 then
83
84   CPPFLAGS_old=$CPPFLAGS
85   CPPFLAGS="$CPPFLAGS -I$QTDIR/include"
86
87   AC_LANG_CPLUSPLUS
88   AC_CHECK_HEADER(qaction.h,qt_ok=yes ,qt_ok=no)
89
90   CPPFLAGS=$CPPFLAGS_old
91
92   if  test "x$qt_ok" = "xno"
93   then
94     AC_MSG_WARN(qt headers not found, or too old qt version, in $QTDIR/include)
95     AC_MSG_WARN(QTDIR environment variable may be wrong)
96   else
97     QT_INCLUDES="-I${QT_ROOT}/include -DQT_THREAD_SUPPORT"
98     QT_MT_INCLUDES="-I${QT_ROOT}/include -DQT_THREAD_SUPPORT"
99   fi
100 fi
101
102 if  test "x$qt_ok" = "xyes"
103 then
104   AC_MSG_CHECKING(linking qt library)
105   LIBS_old=$LIBS
106   LIBS="$LIBS -L$QTDIR/lib -lqt-mt $OGL_LIBS"
107
108   CXXFLAGS_old=$CXXFLAGS
109   CXXFLAGS="$CXXFLAGS -I$QTDIR/include"
110
111   AC_CACHE_VAL(salome_cv_lib_qt,[
112     AC_TRY_LINK(
113 #include <qapplication.h>
114 ,   int n;
115     char **s;
116     QApplication a(n, s);
117     a.exec();,
118     eval "salome_cv_lib_qt=yes",eval "salome_cv_lib_qt=no")
119   ])
120   qt_ok="$salome_cv_lib_qt"
121
122   if  test "x$qt_ok" = "xno"
123   then
124     AC_MSG_RESULT(unable to link with qt library)
125     AC_MSG_RESULT(QTDIR environment variable may be wrong)
126   else
127     AC_MSG_RESULT(yes)
128        QT_LIBS="-L$QTDIR/lib -lqt-mt"
129     QT_MT_LIBS="-L$QTDIR/lib -lqt-mt"
130   fi
131
132   LIBS=$LIBS_old
133   CXXFLAGS=$CXXFLAGS_old
134
135 fi
136
137 AC_SUBST(MOC)
138 AC_SUBST(UIC)
139
140 AC_SUBST(QT_ROOT)
141 AC_SUBST(QT_INCLUDES)
142 AC_SUBST(QT_LIBS)
143 AC_SUBST(QT_MT_LIBS)
144
145 AC_LANG_RESTORE
146
147 AC_MSG_RESULT(for qt: $qt_ok)
148
149 # Save cache
150 AC_CACHE_SAVE
151
152 ])dnl
153 dnl