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