Salome HOME
Update copyrights
[modules/jobmanager.git] / m4 / i2_check_qt4.m4
index 355c3898a7958e2a059f5f59672120b5a638af1f..6d0a7471ff42fefba04f4be4f07af7f3e4397122 100644 (file)
@@ -1,21 +1,22 @@
-dnl  Copyright (C) 2006-2008  CEA/DEN, EDF R&D
+dnl Copyright (C) 2009-2019  CEA/DEN, EDF R&D
 dnl
-dnl  This library is free software; you can redistribute it and/or
-dnl  modify it under the terms of the GNU Lesser General Public
-dnl  License as published by the Free Software Foundation; either
-dnl  version 2.1 of the License.
+dnl This library is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU Lesser General Public
+dnl License as published by the Free Software Foundation; either
+dnl version 2.1 of the License, or (at your option) any later version.
 dnl
-dnl  This library is distributed in the hope that it will be useful,
-dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-dnl  Lesser General Public License for more details.
+dnl This library is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+dnl Lesser General Public License for more details.
 dnl
-dnl  You should have received a copy of the GNU Lesser General Public
-dnl  License along with this library; if not, write to the Free Software
-dnl  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+dnl You should have received a copy of the GNU Lesser General Public
+dnl License along with this library; if not, write to the Free Software
+dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 dnl
-dnl  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+dnl See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 dnl
+
 dnl the following variables are exported:
 dnl  QT_MOC
 dnl  QT_UIC
@@ -28,6 +29,7 @@ dnl qt4 is searched in the following order
 dnl   path given with --with-qt4 options
 dnl   presence of QTDIR variable
 dnl   /usr
+dnl when HAS_GUI is false (no salome gui) and nothing is said for qt4, qt4 is not checked
 dnl usages
 dnl ./configure --prefix=/home/prascle/partage/maquettes/install 
 dnl ./configure --prefix=/home/prascle/partage/maquettes/install --with-qt4
@@ -42,6 +44,8 @@ AC_DEFUN([I2_CHECK_QT4],
   AC_REQUIRE([AC_PROG_CPP])
 
   qt_ok=no
+  qt4_wanted=yes
+  WITH_QT4=0
 
   # --- check if qt4 standard install directory is defined (with subdirectories bin lib include)
   qt4_install_path=""
@@ -60,34 +64,49 @@ AC_DEFUN([I2_CHECK_QT4],
     fi
   fi
 
-  # --- if qt4 standard install directory is not defined: QTDIR value if defined, or /usr
+  # --- if qt4 standard install directory is not defined
+  #       if HAS_GUI= 0: Qt4 not wanted
+  #       else: QTDIR value if defined, or /usr
   if test x${withval} = xnotset
   then
-    if test -z $QTDIR
+    if test x${HAS_GUI} = x0
     then
-      qt4_install_path="/usr"
+      qt4_wanted=no
+      AC_MSG_NOTICE([SALOME GUI not present, Qt4 not specified, skip detection])
     else
-      if test $QTDIR = /usr/lib/qt3 ; then
-        if test -d /usr/lib/qt4 ; then
-          AC_MSG_RESULT(it is strange for a qt4 installation !)
-          AC_MSG_RESULT(/usr/lib/qt4 is present)
-          AC_MSG_RESULT(replacing QTDIR by /usr/lib/qt4)
-          QTDIR=/usr/lib/qt4
+      if test -z $QTDIR
+      then
+        qt4_install_path="/usr"
+      else
+        if test $QTDIR = /usr/lib/qt3 ; then
+          if test -d /usr/lib/qt4 ; then
+            AC_MSG_RESULT(it is strange for a qt4 installation !)
+            AC_MSG_RESULT(/usr/lib/qt4 is present)
+            AC_MSG_RESULT(replacing QTDIR by /usr/lib/qt4)
+            QTDIR=/usr/lib/qt4
+          fi
         fi
+        qt4_install_path=$QTDIR
       fi
-      qt4_install_path=$QTDIR
     fi
   fi
   
   # --- if qt4 standard install directory is not wanted: --without-qt4 or --with-qt4=no
   if test x${withval} = xno
   then
-    qt4_install_path=""
+    qt4_wanted=no
+    AC_MSG_NOTICE([Qt4 is not wanted, skip detection])
   fi
 
   QT_DIR=${qt4_install_path}
   AC_SUBST(QT_DIR)
 
+  # ----------------------------------------------------------------------
+  # --- only when qt4 wanted (no explicit --without-qt4 nor --with-qt4=no)
+
+  if test x${qt4_wanted} = xyes
+  then
+
   # --- check if qt4 includes directory is defined
   qt4_include_path=""
   AC_ARG_WITH([qt4-includes],
@@ -146,11 +165,6 @@ AC_DEFUN([I2_CHECK_QT4],
     fi
   fi
 
-  WITH_QT4=0
-
-  AC_MSG_NOTICE(${qt4_include_path})
-  AC_MSG_NOTICE(${qt4_library_path})
-  AC_MSG_NOTICE(${qt4_tools_path})
 
   # test if qt4 is completely defined
   qt4_defined=yes
@@ -158,16 +172,22 @@ AC_DEFUN([I2_CHECK_QT4],
   then
     qt4_defined=no
     AC_MSG_NOTICE([No Qt4 include path defined])
+  else
+    AC_MSG_NOTICE([Qt4 include path is ${qt4_include_path}])
   fi
   if test x${qt4_library_path} = x
   then
     qt4_defined=no
     AC_MSG_NOTICE([No Qt4 library path defined])
+  else
+    AC_MSG_NOTICE([Qt4 library path is ${qt4_library_path}])
   fi
   if test x${qt4_tools_path} = x
   then
     qt4_defined=no
     AC_MSG_NOTICE([No Qt4 tools path defined])
+  else
+    AC_MSG_NOTICE([Qt4 tools   path is ${qt4_tools_path}])
   fi
 
   # saving values for compilation variables
@@ -218,7 +238,7 @@ AC_DEFUN([I2_CHECK_QT4],
     AC_SUBST(qt4_cppflags)
 
     # --- we test the library file presence and usability
-    if test x${qt4_library_path} = /usr/lib
+    if test x${qt4_library_path} = x/usr/lib
     then
       qt4_ldflags=""
     else
@@ -226,8 +246,7 @@ AC_DEFUN([I2_CHECK_QT4],
     fi
 
     AC_MSG_NOTICE([checking whether link with qt4 is working])
-    qt4_lib_name=QtGui
-    qt4_libs="-l$qt4_lib_name"
+    qt4_libs="-lQtCore -lQtGui"
     LDFLAGS="${LDFLAGS} ${qt4_ldflags}"
     LIBS="${LIBS} ${qt4_libs}"
     AC_LANG_PUSH(C++)
@@ -257,6 +276,15 @@ AC_DEFUN([I2_CHECK_QT4],
     AC_MSG_NOTICE([No Qt4 support])
   fi
 
+  # restoring saved values
+  CPPFLAGS=$saved_CPPFLAGS
+  LDFLAGS=$saved_LDFLAGS
+  LIBS=$saved_LIBS
+
+  fi
+  # --- end: only when qt4 wanted (no explicit --without-qt4 nor --with-qt4=no)
+  # ----------------------------------------------------------------------
+
   # Propagate test into atlocal
   AC_SUBST(WITH_QT4)
 
@@ -266,21 +294,21 @@ AC_DEFUN([I2_CHECK_QT4],
   # ... and into source files
   AC_DEFINE_UNQUOTED(HAS_QT4, $WITH_QT4, [Qt4 library])
 
-  # restoring saved values
-  CPPFLAGS=$saved_CPPFLAGS
-  LDFLAGS=$saved_LDFLAGS
-  LIBS=$saved_LIBS
-
 ])
 
 
 AC_DEFUN([I2_CHECK_QSCINTILLA],
 [
   AC_REQUIRE([I2_CHECK_QT4])
-
   qscintilla_ok=no
   WITH_QSCI4=0
 
+  # ----------------------------------------------------------------------
+  # --- check qscintilla only when qt4 OK
+
+  if test x${WITH_QT4} = x1
+  then
+
   # --- check if qsci4 includes directory is defined
   qsci4_include_path=""
   qsci4_cppflags=""
@@ -389,23 +417,30 @@ AC_DEFUN([I2_CHECK_QSCINTILLA],
       AC_SUBST(qsci4_libs)
       WITH_QSCI4=1
       qscintilla_ok=yes
-      # Propagate test into atlocal
-      AC_SUBST(WITH_QSCI4)
     fi
 
   else
     AC_MSG_NOTICE([no support for qscintilla for qt4])
   fi
 
+  # restoring saved values
+  CPPFLAGS=$saved_CPPFLAGS
+  LDFLAGS=$saved_LDFLAGS
+  LIBS=$saved_LIBS
+
+  else
+  # --- end: check qscintilla only when qt4 OK
+  # ----------------------------------------------------------------------
+    AC_MSG_NOTICE([qscintilla for qt4 not checked because Qt4 not wanted or not detected])
+  fi
+
+  # Propagate test into atlocal
+  AC_SUBST(WITH_QSCI4)
+  
   # Propagate test into Makefiles...
   AM_CONDITIONAL(WITH_QSCI4, test $WITH_QSCI4 = 1)
 
   # ... and into source files
   AC_DEFINE_UNQUOTED(HAS_QSCI4, $WITH_QSCI4, [QsciScintilla library])
 
-  # restoring saved values
-  CPPFLAGS=$saved_CPPFLAGS
-  LDFLAGS=$saved_LDFLAGS
-  LIBS=$saved_LIBS
-
 ])