Salome HOME
PR: first version from Antony GEAY, with directory restructuration
[modules/yacs.git] / 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
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 fi
40
41 if  test "x$qt_ok" = "xyes"
42 then
43   if test -f ${QTDIR}/bin/moc
44   then
45     MOC=${QTDIR}/bin/moc
46   else
47     AC_PATH_PROG(MOC, moc)
48   fi
49   if test "x$MOC" = "x"
50   then
51     qt_ok=no
52     AC_MSG_RESULT(moc qt-compiler not in PATH variable)
53   else
54     qt_ok=yes
55     AC_MSG_RESULT(moc found)
56   fi
57 fi
58
59 if  test "x$qt_ok" = "xyes"
60 then
61   if test -f ${QTDIR}/bin/uic
62   then
63     UIC=${QTDIR}/bin/uic
64   else
65     AC_PATH_PROG(UIC, uic)
66   fi
67   if test "x$UIC" = "x"
68   then
69     qt_ok=no
70     AC_MSG_RESULT(uic qt-interface compiler not in PATH variable)
71   else
72     qt_ok=yes
73     AC_MSG_RESULT(uic found)
74   fi
75 fi
76
77 AC_SUBST(QTDIR)
78 QT_ROOT=$QTDIR
79
80 if  test "x$qt_ok" = "xyes"
81 then
82   AC_MSG_CHECKING(include of qt headers)
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_RESULT(qt headers not found, or too old qt version, in $QTDIR/include)
95     AC_MSG_RESULT(QTDIR environment variable may be wrong)
96   else
97     AC_MSG_RESULT(yes)
98        QT_INCLUDES="-I${QT_ROOT}/include -DQT_THREAD_SUPPORT"
99     QT_MT_INCLUDES="-I${QT_ROOT}/include -DQT_THREAD_SUPPORT"
100   fi
101 fi
102
103 if  test "x$qt_ok" = "xyes"
104 then
105   AC_MSG_CHECKING(linking qt library)
106   LIBS_old=$LIBS
107   LIBS="$LIBS -L$QTDIR/lib -lqt-mt $OGL_LIBS"
108
109   CXXFLAGS_old=$CXXFLAGS
110   CXXFLAGS="$CXXFLAGS -I$QTDIR/include"
111
112   AC_CACHE_VAL(salome_cv_lib_qt,[
113     AC_TRY_LINK(
114 #include <qapplication.h>
115 ,   int n;
116     char **s;
117     QApplication a(n, s);
118     a.exec();,
119     eval "salome_cv_lib_qt=yes",eval "salome_cv_lib_qt=no")
120   ])
121   qt_ok="$salome_cv_lib_qt"
122
123   if  test "x$qt_ok" = "xno"
124   then
125     AC_MSG_RESULT(unable to link with qt library)
126     AC_MSG_RESULT(QTDIR environment variable may be wrong)
127   else
128     AC_MSG_RESULT(yes)
129        QT_LIBS="-L$QTDIR/lib -lqt-mt"
130     QT_MT_LIBS="-L$QTDIR/lib -lqt-mt"
131   fi
132
133   LIBS=$LIBS_old
134   CXXFLAGS=$CXXFLAGS_old
135
136 fi
137
138 AC_SUBST(MOC)
139 AC_SUBST(UIC)
140
141 AC_SUBST(QT_ROOT)
142 AC_SUBST(QT_INCLUDES)
143 AC_SUBST(QT_LIBS)
144 AC_SUBST(QT_MT_LIBS)
145
146 AC_LANG_RESTORE
147
148 AC_MSG_RESULT(for qt: $qt_ok)
149
150 # Save cache
151 AC_CACHE_SAVE
152
153 ])dnl
154 dnl