1# - Try to find GLUI (GL User Interface)
2# Requires OpenGL and GLUT - searches for them using find_package
3# Once done, this will define
4#
5#	GLUI_INCLUDE_DIR, where to find GL/glui.h (or GLUI/glui.h on mac)
6#	GLUI_LIBRARY, the libraries to link against
7#	GLUI_FOUND, If false, do not try to use GLUI.
8#
9# Plural versions refer to this library and its dependencies, and
10# are recommended to be used instead, unless you have a good reason.
11#
12# Useful configuration variables you might want to add to your cache:
13#   GLUI_ROOT_DIR - A directory prefix to search
14#                  (usually a path that contains include/ as a subdirectory)
15#
16# Original Author:
17# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
18# http://academic.cleardefinition.com
19# Iowa State University HCI Graduate Program/VRAC
20#
21# Copyright Iowa State University 2009-2010.
22# Distributed under the Boost Software License, Version 1.0.
23# (See accompanying file LICENSE_1_0.txt or copy at
24# http://www.boost.org/LICENSE_1_0.txt)
25
26if(GLUI_FIND_QUIETLY)
27	find_package(OpenGL QUIET)
28	find_package(GLUT QUIET)
29else()
30	find_package(OpenGL)
31	find_package(GLUT)
32endif()
33
34if(OPENGL_FOUND AND GLUT_FOUND)
35	if(WIN32)
36		find_path(GLUI_INCLUDE_DIR
37			NAMES
38			GL/glui.h
39			PATHS
40			${GLUI_ROOT_PATH}/include
41			DOC
42			"GLUI include directory")
43		find_library(GLUI_LIBRARY
44			NAMES
45			glui
46			${GLUI_ROOT_DIR}/lib
47			${GLUI_ROOT_DIR}/Release
48			HINTS
49			${OPENGL_LIBRARY_DIR}
50			${OPENGL_INCLUDE_DIR}/../lib
51			DOC
52			"GLUI library")
53		find_library(GLUI_DEBUG_LIBRARY
54			NAMES
55			glui32
56			${GLUI_ROOT_DIR}/lib
57			${GLUI_ROOT_DIR}/Debug
58			HINTS
59			${OPENGL_LIBRARY_DIR}
60			${OPENGL_INCLUDE_DIR}/../lib
61			DOC
62			"GLUI debug library")
63	else()
64		find_library(GLUI_LIBRARY
65			NAMES
66			GLUI
67			glui
68			PATHS
69			${GLUI_ROOT_DIR}/lib64
70			${GLUI_ROOT_DIR}/lib
71			${GLUI_ROOT_DIR}
72			/usr/openwin/lib
73			HINTS
74			${OPENGL_LIBRARY_DIR}
75			${OPENGL_INCLUDE_DIR}/../lib64
76			${OPENGL_INCLUDE_DIR}/../lib
77			DOC
78			"GLUI library")
79
80		if(APPLE)
81			find_path(GLUI_INCLUDE_DIR
82				GLUI/glui.h
83				HINTS
84				${OPENGL_INCLUDE_DIR}
85				DOC
86				"GLUI include directory")
87		else()
88			find_path(GLUI_INCLUDE_DIR
89				GL/glui.h
90				PATHS
91				${GLUI_ROOT_DIR}/include
92				/usr/include/GL
93				/usr/openwin/share/include
94				/usr/openwin/include
95				/opt/graphics/OpenGL/include
96				/opt/graphics/OpenGL/contrib/libglui
97				DOC
98				"GLUI include directory")
99		endif()
100	endif()
101endif()
102
103# handle the QUIETLY and REQUIRED arguments and set xxx_FOUND to TRUE if
104# all listed variables are TRUE
105include(FindPackageHandleStandardArgs)
106find_package_handle_standard_args(GLUI
107	DEFAULT_MSG
108	GLUI_INCLUDE_DIR
109	GLUI_LIBRARY
110	GLUT_FOUND
111	OPENGL_FOUND)
112
113if(GLUI_FOUND)
114	if(WIN32 AND GLUI_LIBRARY AND GLUI_DEBUG_LIBRARY)
115		set(GLUI_LIBRARIES
116			optimized
117			${GLUI_LIBRARY}
118			debug
119			${GLUI_DEBUG_LIBRARY}
120			${GLUT_LIBRARIES}
121			${OPENGL_LIBRARIES})
122	else()
123		set(GLUI_LIBRARIES
124			${GLUI_LIBRARY}
125			${GLUT_LIBRARIES}
126			${OPENGL_LIBRARIES})
127	endif()
128	set(GLUI_INCLUDE_DIRS
129		${GLUI_INCLUDE_DIR}
130		${GLUT_INCLUDE_DIR}
131		${OPENGL_INCLUDE_DIR})
132endif()
133
134if(GLUI_LIBRARY AND GLUI_INCLUDE_DIR)
135	mark_as_advanced(GLUI_INCLUDE_DIR GLUI_LIBRARY GLUI_DEBUG_LIBRARY)
136endif()
137