1############################################################################
2# FindGLX.txt
3# Copyright (C) 2014  Belledonne Communications, Grenoble France
4#
5############################################################################
6#
7# This program is free software; you can redistribute it and/or
8# modify it under the terms of the GNU General Public License
9# as published by the Free Software Foundation; either version 2
10# of the License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# 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# - Find the GLX include file and library
24#
25#  GLX_FOUND - system has GLX
26#  GLX_INCLUDE_DIRS - the GLX include directory
27#  GLX_LIBRARIES - The libraries needed to use GLX
28
29include(CheckIncludeFile)
30include(CheckSymbolExists)
31
32set(_GLX_ROOT_PATHS
33	${CMAKE_INSTALL_PREFIX}
34)
35
36find_path(GLX_INCLUDE_DIRS
37	NAMES GL/gl.h
38	HINTS _GLX_ROOT_PATHS
39	PATH_SUFFIXES include
40)
41if(GLX_INCLUDE_DIRS)
42	check_include_file(GL/gl.h HAVE_GL_GL_H "-I${GLX_INCLUDE_DIRS}")
43	check_include_file(GL/glx.h HAVE_GL_GLX_H "-I${GLX_INCLUDE_DIRS}")
44endif()
45
46find_library(GL_LIBRARY
47	NAMES GL
48	HINTS _GLX_ROOT_PATHS
49	PATH_SUFFIXES bin lib
50)
51find_library(GLEW_LIBRARY
52	NAMES GLEW
53	HINTS _GLX_ROOT_PATHS
54	PATH_SUFFIXES bin lib
55)
56set(GLX_LIBRARIES ${GL_LIBRARY} ${GLEW_LIBRARY})
57
58if(GLX_LIBRARIES)
59	# TODO: check symbols in gl and glew
60endif()
61
62include(FindPackageHandleStandardArgs)
63find_package_handle_standard_args(GLX
64	DEFAULT_MSG
65	GLX_INCLUDE_DIRS HAVE_GL_GL_H HAVE_GL_GLX_H GLX_LIBRARIES
66)
67
68mark_as_advanced(GLX_INCLUDE_DIRS HAVE_GL_GL_H HAVE_GL_GLX_H GLX_LIBRARIES)
69