Salome HOME
ab5348319f74ebd2bcf6e7cfd168e4f63b5791bd
[tools/hxx2salome.git] / 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 AC_REQUIRE([AC_LINKER_OPTIONS])dnl
30
31 AC_CHECKING(for Qt)
32
33 if test "x$OpenGL_ok" != "xyes" ; then
34    AC_MSG_WARN(Qt needs OpenGL correct configuration, check configure output)
35 fi
36
37 qt_ok=yes
38
39 AC_LANG_SAVE
40 AC_LANG_CPLUSPLUS
41
42 if test "x$QTDIR" = "x"
43 then
44    AC_MSG_RESULT(please define QTDIR variable)
45    qt_ok=no
46 else
47    AC_MSG_RESULT(QTDIR is $QTDIR)
48    qt_inc_ok=no
49    QTINC=""
50    AC_CHECK_FILE(${QTDIR}/include/qt3/qglobal.h,QTINC="/qt3",QTINC="")
51    QT_VERS=`grep "QT_VERSION_STR" ${QTDIR}/include${QTINC}/qglobal.h | sed -e 's%^#define QT_VERSION_STR\([[:space:]]*\)%%g' -e 's%\"%%g'`
52    AC_MSG_RESULT(Qt version is $QT_VERS)
53    QT_VERS="Qt_"`echo $QT_VERS | sed -e 's%\"%%g' -e 's%\.%_%g'`
54 fi
55
56 if  test "x$qt_ok" = "xyes"
57 then
58   if test -f ${QTDIR}/bin/moc
59   then
60     MOC=${QTDIR}/bin/moc
61   else
62     AC_PATH_PROG(MOC, moc)
63   fi
64   if test "x$MOC" = "x"
65   then
66     qt_ok=no
67     AC_MSG_RESULT(moc qt-compiler not in PATH variable)
68   else
69     qt_ok=yes
70     AC_MSG_RESULT(moc found)
71   fi
72 fi
73
74 if  test "x$qt_ok" = "xyes"
75 then
76   if test -f ${QTDIR}/bin/uic
77   then
78     UIC=${QTDIR}/bin/uic
79   else
80     AC_PATH_PROG(UIC, uic)
81   fi
82   if test "x$UIC" = "x"
83   then
84     qt_ok=no
85     AC_MSG_RESULT(uic qt-interface compiler not in PATH variable)
86   else
87     qt_ok=yes
88     AC_MSG_RESULT(uic found)
89   fi
90 fi
91
92 AC_SUBST(QTDIR)
93 QT_ROOT=$QTDIR
94
95 if  test "x$qt_ok" = "xyes"
96 then
97   CPPFLAGS_old=$CPPFLAGS
98   CPPFLAGS="$CPPFLAGS -I$QTDIR/include${QTINC}"
99
100   AC_LANG_CPLUSPLUS
101   AC_CHECK_HEADER(qaction.h,qt_ok=yes ,qt_ok=no)
102
103   CPPFLAGS=$CPPFLAGS_old
104
105   AC_MSG_CHECKING(include of qt headers)
106
107   if  test "x$qt_ok" = "xno"
108   then
109     AC_MSG_RESULT(qt headers not found, or too old qt version, in $QTDIR/include)
110     AC_MSG_RESULT(QTDIR environment variable may be wrong)
111   else
112     AC_MSG_RESULT(yes)
113     QT_INCLUDES="-I${QT_ROOT}/include${QTINC} -DQT_THREAD_SUPPORT -DQT_CLEAN_NAMESPACE"
114     QT_MT_INCLUDES="-I${QT_ROOT}/include${QTINC} -DQT_THREAD_SUPPORT -DQT_CLEAN_NAMESPACE"
115   fi
116 fi
117
118 if  test "x$qt_ok" = "xyes"
119 then
120   AC_MSG_CHECKING(linking qt library)
121   LIBS_old=$LIBS
122   if test "x$QTDIR" = "x/usr"
123   then
124     LIBS="$LIBS -lqt-mt $OGL_LIBS"
125   else
126     LIBS="$LIBS -L$QTDIR/lib${LIB_LOCATION_SUFFIX} -lqt-mt $OGL_LIBS"
127   fi
128
129   CXXFLAGS_old=$CXXFLAGS
130   CXXFLAGS="$CXXFLAGS $QT_INCLUDES"
131
132   AC_CACHE_VAL(salome_cv_lib_qt,[
133     AC_TRY_LINK(
134 #include <qapplication.h>
135 ,   int n;
136     char **s;
137     QApplication a(n, s);
138     a.exec();,
139     eval "salome_cv_lib_qt=yes",eval "salome_cv_lib_qt=no")
140   ])
141   qt_ok="$salome_cv_lib_qt"
142
143   if  test "x$qt_ok" = "xno"
144   then
145     AC_MSG_RESULT(unable to link with qt library)
146     AC_MSG_RESULT(QTDIR environment variable may be wrong)
147   else
148     AC_MSG_RESULT(yes)
149     if test "x$QTDIR" = "x/usr"
150     then
151          QT_LIBS=" -lqt-mt"
152       QT_MT_LIBS=" -lqt-mt"
153     else
154          QT_LIBS="-L$QTDIR/lib${LIB_LOCATION_SUFFIX} -lqt-mt"
155       QT_MT_LIBS="-L$QTDIR/lib${LIB_LOCATION_SUFFIX} -lqt-mt"
156     fi
157   fi
158
159   LIBS=$LIBS_old
160   CXXFLAGS=$CXXFLAGS_old
161
162 fi
163
164 AC_SUBST(MOC)
165 AC_SUBST(UIC)
166
167 AC_SUBST(QT_ROOT)
168 AC_SUBST(QT_INCLUDES)
169 AC_SUBST(QT_MT_INCLUDES)
170 AC_SUBST(QT_LIBS)
171 AC_SUBST(QT_MT_LIBS)
172 AC_SUBST(QT_VERS)
173
174 AC_LANG_RESTORE
175
176 AC_MSG_RESULT(for Qt: $qt_ok)
177
178 # Save cache
179 AC_CACHE_SAVE
180
181 ])dnl
182 dnl