FindV4L.cmake 2.53 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
############################################################################
# FindV4L.txt
# Copyright (C) 2014  Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
19
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
#
############################################################################
#
# - Find the V4L include file and library
#
#  V4L_FOUND - system has V4L
#  V4L_INCLUDE_DIRS - the V4L include directory
#  V4L_LIBRARIES - The libraries needed to use V4L

set(_V4L_ROOT_PATHS
	${CMAKE_INSTALL_PREFIX}
)

find_path(V4L1_INCLUDE_DIRS
	NAMES linux/videodev.h
	HINTS _V4L_ROOT_PATHS
	PATH_SUFFIXES include
)
if(V4L1_INCLUDE_DIRS)
	set(HAVE_LINUX_VIDEODEV_H 1)
endif()
find_path(V4L2_INCLUDE_DIRS
	NAMES linux/videodev2.h
	HINTS _V4L_ROOT_PATHS
	PATH_SUFFIXES include
)
if(V4L2_INCLUDE_DIRS)
	set(HAVE_LINUX_VIDEODEV2_H 1)
endif()

find_library(V4L1_LIBRARIES
	NAMES v4l1
	HINTS _V4L_ROOT_PATHS
	PATH_SUFFIXES bin lib
)
find_library(V4L2_LIBRARIES
	NAMES v4l2
	HINTS _V4L_ROOT_PATHS
	PATH_SUFFIXES bin lib
)
find_library(V4LCONVERT_LIBRARIES
	NAMES v4lconvert
	HINTS _V4L_ROOT_PATHS
	PATH_SUFFIXES bin lib
)

set(V4L_INCLUDE_DIRS )
67
if(V4L1_INCLUDE_DIRS)
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
	list(APPEND V4L_INCLUDE_DIRS ${V4L1_INCLUDE_DIRS})
endif()
if(V4L2_INCLUDE_DIRS)
	list(APPEND V4L_INCLUDE_DIRS ${V4L2_INCLUDE_DIRS})
endif()
set(V4L_LIBRARIES )
if(V4L1_LIBRARIES)
	list(APPEND V4L_LIBRARIES ${V4L1_LIBRARIES})
endif()
if(V4L2_LIBRARIES)
	list(APPEND V4L_LIBRARIES ${V4L2_LIBRARIES})
endif()
if(V4LCONVERT_LIBRARIES)
	list(APPEND V4L_LIBRARIES ${V4LCONVERT_LIBRARIES})
endif()
83 84 85 86 87 88
if(V4L_INCLUDE_DIRS)
	list(REMOVE_DUPLICATES V4L_INCLUDE_DIRS)
endif()
if(V4L_LIBRARIES)
	list(REMOVE_DUPLICATES V4L_LIBRARIES)
endif()
89 90 91 92 93 94 95 96

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(V4L
	DEFAULT_MSG
	V4L_INCLUDE_DIRS V4L_LIBRARIES
)

mark_as_advanced(V4L_INCLUDE_DIRS V4L_LIBRARIES)