Salome HOME
Update EDF build_options for master future 9.5.0
[tools/configuration.git] / cmake / FindOpenCV.cmake
1 #########################################################################
2 # Copyright (C) 2007-2020  CEA/DEN, EDF R&D, OPEN CASCADE
3 #
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
8 #
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 # Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20
21 # - Find OpenCV
22 # Sets the following variables:
23 #   OpenCV_FOUND        - found flag
24 #   OpenCV_INCLUDE_DIRS - path to the OpenCV include directories
25 #   OpenCV_LIBS         - path to the OpenCV libraries to be linked against
26 #
27
28 IF(NOT OpenCV_FIND_QUIETLY)
29   MESSAGE(STATUS "Check for OpenCV ...")
30 ENDIF()
31
32 FIND_PATH(OpenCV_INCLUDE_DIRS cv.h PATH_SUFFIXES opencv)
33 IF(OpenCV_INCLUDE_DIRS)
34   SET(_OpenCV_INCLUDE_DIR_TMP "${OpenCV_INCLUDE_DIRS}/../opencv2")
35   GET_FILENAME_COMPONENT(_OpenCV_INCLUDE_DIR_TMP "${_OpenCV_INCLUDE_DIR_TMP}" REALPATH)
36   LIST(APPEND OpenCV_INCLUDE_DIRS ${_OpenCV_INCLUDE_DIR_TMP})
37 ENDIF()
38
39 SET(OpenCV_LIB_COMPONENTS videostab;video;ts;superres;stitching;photo;ocl;objdetect;ml;legacy;imgproc;highgui;gpu;flann;features2d;core;objdetect;imgcodecs;shape)
40
41 FOREACH(_compo ${OpenCV_LIB_COMPONENTS})
42   FIND_LIBRARY(OpenCV_${_compo} opencv_${_compo})
43   IF(OpenCV_${_compo})
44     LIST(APPEND OpenCV_LIBRARIES ${OpenCV_${_compo}})
45   ENDIF()
46 ENDFOREACH()
47 IF(OpenCV_LIBRARIES AND OpenCV_INCLUDE_DIRS)
48   IF(NOT OpenCV_LIBS)
49     SET(OpenCV_LIBS ${OpenCV_LIBRARIES})
50   ENDIF()
51   SET(OpenCV_FOUND 1)  
52
53   IF(NOT OpenCV_FIND_QUIETLY)
54     MESSAGE("OpenCV found !")
55   ENDIF()
56 ELSE()
57   IF(NOT OpenCV_FIND_QUIETLY)
58     MESSAGE("Could not find OpenCV ...")
59   ENDIF()
60 ENDIF()