Salome HOME
updated copyright message
[modules/yacs.git] / src / wrappergen / src / HXX2SALOME_GENERIC_CLASS_NAME_SRC / adm_local / unix / config_files / check_qt.m4
1 dnl Copyright (C) 2006-2023  CEA/DEN, EDF R&D
2 dnl
3 dnl This library is free software; you can redistribute it and/or
4 dnl modify it under the terms of the GNU Lesser General Public
5 dnl License as published by the Free Software Foundation; either
6 dnl version 2.1 of the License, or (at your option) any later version.
7 dnl
8 dnl This library is distributed in the hope that it will be useful,
9 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
10 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 dnl Lesser General Public License for more details.
12 dnl
13 dnl You should have received a copy of the GNU Lesser General Public
14 dnl License along with this library; if not, write to the Free Software
15 dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 dnl
17 dnl See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 dnl
19
20 AC_DEFUN([CHECK_QT],[
21 AC_REQUIRE([AC_PROG_CC])dnl
22 AC_REQUIRE([AC_PROG_CXX])dnl
23 AC_REQUIRE([AC_PROG_CPP])dnl
24 AC_REQUIRE([AC_PROG_CXXCPP])dnl
25 AC_REQUIRE([CHECK_OPENGL])dnl
26 AC_REQUIRE([AC_LINKER_OPTIONS])dnl
27
28 AC_CHECKING(for Qt)
29
30 if test "x$OpenGL_ok" != "xyes" ; then
31    AC_MSG_WARN(Qt needs OpenGL correct configuration, check configure output)
32 fi
33
34 qt_ok=yes
35
36 AC_LANG_SAVE
37 AC_LANG_CPLUSPLUS
38
39 if test "x$QTDIR" = "x"
40 then
41    AC_MSG_RESULT(please define QTDIR variable)
42    qt_ok=no
43 else
44    AC_MSG_RESULT(QTDIR is $QTDIR)
45    qt_inc_ok=no
46    QTINC=""
47    AC_CHECK_FILE(${QTDIR}/include/qt3/qglobal.h,QTINC="/qt3",QTINC="")
48    QT_VERS=`grep "QT_VERSION_STR" ${QTDIR}/include${QTINC}/qglobal.h | sed -e 's%^#define QT_VERSION_STR\([[:space:]]*\)%%g' -e 's%\"%%g'`
49    AC_MSG_RESULT(Qt version is $QT_VERS)
50    QT_VERS="Qt_"`echo $QT_VERS | sed -e 's%\"%%g' -e 's%\.%_%g'`
51 fi
52
53 if  test "x$qt_ok" = "xyes"
54 then
55   if test -f ${QTDIR}/bin/moc
56   then
57     MOC=${QTDIR}/bin/moc
58   else
59     AC_PATH_PROG(MOC, moc)
60   fi
61   if test "x$MOC" = "x"
62   then
63     qt_ok=no
64     AC_MSG_RESULT(moc qt-compiler not in PATH variable)
65   else
66     qt_ok=yes
67     AC_MSG_RESULT(moc found)
68   fi
69 fi
70
71 if  test "x$qt_ok" = "xyes"
72 then
73   if test -f ${QTDIR}/bin/uic
74   then
75     UIC=${QTDIR}/bin/uic
76   else
77     AC_PATH_PROG(UIC, uic)
78   fi
79   if test "x$UIC" = "x"
80   then
81     qt_ok=no
82     AC_MSG_RESULT(uic qt-interface compiler not in PATH variable)
83   else
84     qt_ok=yes
85     AC_MSG_RESULT(uic found)
86   fi
87 fi
88
89 AC_SUBST(QTDIR)
90 QT_ROOT=$QTDIR
91
92 if  test "x$qt_ok" = "xyes"
93 then
94   CPPFLAGS_old=$CPPFLAGS
95   CPPFLAGS="$CPPFLAGS -I$QTDIR/include${QTINC}"
96
97   AC_LANG_CPLUSPLUS
98   AC_CHECK_HEADER(qaction.h,qt_ok=yes ,qt_ok=no)
99
100   CPPFLAGS=$CPPFLAGS_old
101
102   AC_MSG_CHECKING(include of qt headers)
103
104   if  test "x$qt_ok" = "xno"
105   then
106     AC_MSG_RESULT(qt headers not found, or too old qt version, in $QTDIR/include)
107     AC_MSG_RESULT(QTDIR environment variable may be wrong)
108   else
109     AC_MSG_RESULT(yes)
110     QT_INCLUDES="-I${QT_ROOT}/include${QTINC} -DQT_THREAD_SUPPORT -DQT_CLEAN_NAMESPACE"
111     QT_MT_INCLUDES="-I${QT_ROOT}/include${QTINC} -DQT_THREAD_SUPPORT -DQT_CLEAN_NAMESPACE"
112   fi
113 fi
114
115 if  test "x$qt_ok" = "xyes"
116 then
117   AC_MSG_CHECKING(linking qt library)
118   LIBS_old=$LIBS
119   if test "x$QTDIR" = "x/usr"
120   then
121     LIBS="$LIBS -lqt-mt $OGL_LIBS"
122   else
123     LIBS="$LIBS -L$QTDIR/lib${LIB_LOCATION_SUFFIX} -lqt-mt $OGL_LIBS"
124   fi
125
126   CXXFLAGS_old=$CXXFLAGS
127   CXXFLAGS="$CXXFLAGS $QT_INCLUDES"
128
129   AC_CACHE_VAL(salome_cv_lib_qt,[
130     AC_TRY_LINK(
131 #include <qapplication.h>
132 ,   int n;
133     char **s;
134     QApplication a(n, s);
135     a.exec();,
136     eval "salome_cv_lib_qt=yes",eval "salome_cv_lib_qt=no")
137   ])
138   qt_ok="$salome_cv_lib_qt"
139
140   if  test "x$qt_ok" = "xno"
141   then
142     AC_MSG_RESULT(unable to link with qt library)
143     AC_MSG_RESULT(QTDIR environment variable may be wrong)
144   else
145     AC_MSG_RESULT(yes)
146     if test "x$QTDIR" = "x/usr"
147     then
148          QT_LIBS=" -lqt-mt"
149       QT_MT_LIBS=" -lqt-mt"
150     else
151          QT_LIBS="-L$QTDIR/lib${LIB_LOCATION_SUFFIX} -lqt-mt"
152       QT_MT_LIBS="-L$QTDIR/lib${LIB_LOCATION_SUFFIX} -lqt-mt"
153     fi
154   fi
155
156   LIBS=$LIBS_old
157   CXXFLAGS=$CXXFLAGS_old
158
159 fi
160
161 AC_SUBST(MOC)
162 AC_SUBST(UIC)
163
164 AC_SUBST(QT_ROOT)
165 AC_SUBST(QT_INCLUDES)
166 AC_SUBST(QT_MT_INCLUDES)
167 AC_SUBST(QT_LIBS)
168 AC_SUBST(QT_MT_LIBS)
169 AC_SUBST(QT_VERS)
170
171 AC_LANG_RESTORE
172
173 AC_MSG_RESULT(for Qt: $qt_ok)
174
175 # Save cache
176 AC_CACHE_SAVE
177
178 ])dnl
179 dnl