]> SALOME platform Git repositories - modules/geom.git/blob - adm_local/unix/config_files/check_OpenCV.m4
Salome HOME
Update copyrights 2014.
[modules/geom.git] / adm_local / unix / config_files / check_OpenCV.m4
1 dnl Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
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 dnl  File   : check_OpenCV.m4
21 dnl  Author : Renaud NEDELEC, Open CASCADE S.A.S (renaud.nedelec@opencascade.com)
22 dnl
23 AC_DEFUN([CHECK_OPENCV],[
24
25 AC_REQUIRE([AC_PROG_CXX])dnl
26 AC_REQUIRE([AC_PROG_CXXCPP])dnl
27
28 AC_CHECKING([for OPENCV product])
29
30 AC_LANG_SAVE
31 AC_LANG_C
32
33 OPENCV_INCLUDES=""
34 OPENCV_LIBS=""
35
36 AC_ARG_WITH([opencv],
37         [  --with-opencv=DIR       root directory path of OPENCV installation])
38
39 opencv_ok=no
40
41 if test "$with_opencv" != "no" ; then
42   if test "$with_opencv" == "yes" || test "$with_opencv" == "auto"; then
43     OPENCV_HOME=""
44   else
45     OPENCV_HOME="$with_opencv"
46   fi
47
48   if test "$OPENCV_HOME" == "" ; then
49     if test "x$OPENCV_INSTALL_DIR" != "x" ; then
50       OPENCV_HOME=$OPENCV_INSTALL_DIR
51     fi
52   fi
53
54   if test "x$OPENCV_HOME" != "x"; then
55
56     LOCAL_INCLUDES="-I$OPENCV_HOME/include -I$OPENCV_HOME/include/opencv"
57     LOCAL_LIBS="-L$OPENCV_HOME/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann"
58
59     CPPFLAGS_old="$CPPFLAGS"
60     CXXFLAGS_old="$CXXFLAGS"
61     CPPFLAGS="$LOCAL_INCLUDES $CPPFLAGS"
62     CXXFLAGS="$LOCAL_INCLUDES $CXXFLAGS"
63
64     AC_MSG_CHECKING([for OPENCV library])
65
66     LDFLAGS_old="$LDFLAGS"
67     LDFLAGS="-L. $LOCAL_LIBS $LDFLAGS"
68
69     LDFLAGS="$LDFLAGS_old"
70     
71     opencv_ok=yes
72
73     AC_MSG_RESULT([$opencv_ok])
74
75     CPPFLAGS="$CPPFLAGS_old"
76     CXXFLAGS="$CXXFLAGS_old"
77
78   fi
79 fi
80
81 if test "x$opencv_ok" == xno ; then
82   AC_MSG_RESULT([for OPENCV: no])
83   AC_MSG_WARN([OPENCV includes or libraries are not found or are not properly installed])
84   AC_MSG_WARN([Use --with-opencv option to define OPENCV installation.])
85 else
86   OPENCV_INCLUDES=$LOCAL_INCLUDES
87   OPENCV_LIBS=$LOCAL_LIBS
88   AC_MSG_RESULT([for OPENCV: yes])
89 fi
90
91 AM_CONDITIONAL(WITH_OPENCV, [test x"$opencv_ok" = xyes])
92
93 AC_SUBST(OPENCV_INCLUDES)
94 AC_SUBST(OPENCV_LIBS)
95
96 AC_LANG_RESTORE
97
98 ])dnl