1# - try to find VRJuggler 2.2 OpenGL library
2# Requires VRJ core 2.2 (thus FindVRJ22.cmake)
3# Requires OpenGL.
4# Optionally uses Flagpoll and FindFlagpoll.cmake
5#
6# This library is a part of VR Juggler 2.2 - you probably want to use
7# find_package(VRJuggler22) instead, for an easy interface to this and
8# related scripts.  See FindVRJuggler22.cmake for more information.
9#
10#  VRJOGL22_LIBRARY_DIR, library search path
11#  VRJOGL22_INCLUDE_DIRS, include search path for dependencies
12#  VRJOGL22_LIBRARY, the library to link against
13#  VRJOGL22_FOUND, If false, do not try to use this library.
14#
15# Plural versions refer to this library and its dependencies, and
16# are recommended to be used instead, unless you have a good reason.
17#
18# Useful configuration variables you might want to add to your cache:
19#  VRJOGL22_ROOT_DIR - A directory prefix to search
20#                      (a path that contains include/ as a subdirectory)
21#
22# This script will use Flagpoll, if found, to provide hints to the location
23# of this library, but does not use the compiler flags returned by Flagpoll
24# directly.
25#
26# The VJ_BASE_DIR environment variable is also searched (preferentially)
27# when searching for this component, so most sane build environments should
28# "just work."  Note that you need to manually re-run CMake if you change
29# this environment variable, because it cannot auto-detect this change
30# and trigger an automatic re-run.
31#
32# Original Author:
33# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
34# http://academic.cleardefinition.com
35# Iowa State University HCI Graduate Program/VRAC
36#
37# Copyright Iowa State University 2009-2010.
38# Distributed under the Boost Software License, Version 1.0.
39# (See accompanying file LICENSE_1_0.txt or copy at
40# http://www.boost.org/LICENSE_1_0.txt)
41
42
43set(_HUMAN "VR Juggler 2.2 OpenGL Core")
44set(_RELEASE_NAMES vrj_ogl-2_2 libvrj_ogl-2_2)
45set(_DEBUG_NAMES vrj_ogl_d-2_2 libvrj_ogl_d-2_2)
46set(_DIR vrjuggler-2.2)
47set(_FP_PKG_NAME vrjuggler-opengl)
48
49include(SelectLibraryConfigurations)
50include(CreateImportedTarget)
51include(CleanLibraryList)
52include(CleanDirectoryList)
53
54if(VRJOGL22_FIND_QUIETLY)
55	set(_FIND_FLAGS "QUIET")
56else()
57	set(_FIND_FLAGS "")
58endif()
59
60# Try flagpoll.
61find_package(Flagpoll QUIET)
62
63if(FLAGPOLL)
64	flagpoll_get_library_dirs(${_FP_PKG_NAME} NO_DEPS)
65	flagpoll_get_library_names(${_FP_PKG_NAME} NO_DEPS)
66endif()
67
68set(VRJOGL22_ROOT_DIR
69	"${VRJOGL22_ROOT_DIR}"
70	CACHE
71	PATH
72	"Root directory to search for VRJOGL")
73if(DEFINED VRJUGGLER22_ROOT_DIR)
74	mark_as_advanced(VRJOGL22_ROOT_DIR)
75endif()
76if(NOT VRJOGL22_ROOT_DIR)
77	set(VRJOGL22_ROOT_DIR "${VRJUGGLER22_ROOT_DIR}")
78endif()
79
80set(_ROOT_DIR "${VRJOGL22_ROOT_DIR}")
81
82find_library(VRJOGL22_LIBRARY_RELEASE
83	NAMES
84	${_RELEASE_NAMES}
85	HINTS
86	"${_ROOT_DIR}"
87	${${_FP_PKG_NAME}_FLAGPOLL_LIBRARY_DIRS}
88	PATH_SUFFIXES
89	${_VRJ_LIBSUFFIXES}
90	DOC
91	"${_HUMAN} release library full path")
92
93find_library(VRJOGL22_LIBRARY_DEBUG
94	NAMES
95	${_DEBUG_NAMES}
96	HINTS
97	"${_ROOT_DIR}"
98	${${_FP_PKG_NAME}_FLAGPOLL_LIBRARY_DIRS}
99	PATH_SUFFIXES
100	${_VRJ_LIBDSUFFIXES}
101	DOC
102	"${_HUMAN} debug library full path")
103
104select_library_configurations(VRJOGL22)
105
106# Dependency
107if(NOT VRJ22_FOUND)
108	find_package(VRJ22 ${_FIND_FLAGS})
109endif()
110
111if(NOT OPENGL_FOUND)
112	find_package(OpenGL ${_FIND_FLAGS})
113endif()
114
115if(APPLE)
116	set(VRJOGL22_AppKit_LIBRARY
117		"-framework AppKit"
118		CACHE
119		STRING
120		"AppKit framework for OSX")
121	set(VRJOGL22_Cocoa_LIBRARY
122		"-framework Cocoa"
123		CACHE
124		STRING
125		"Cocoa framework for OSX")
126	mark_as_advanced(VRJOGL22_AppKit_LIBRARY VRJOGL22_Cocoa_LIBRARY)
127endif()
128
129# handle the QUIETLY and REQUIRED arguments and set xxx_FOUND to TRUE if
130# all listed variables are TRUE
131include(FindPackageHandleStandardArgs)
132find_package_handle_standard_args(VRJOGL22
133	DEFAULT_MSG
134	VRJOGL22_LIBRARY
135	VRJ22_FOUND
136	VRJ22_LIBRARIES
137	VRJ22_INCLUDE_DIRS
138	OPENGL_FOUND
139	OPENGL_LIBRARIES)
140
141if(VRJOGL22_FOUND)
142	set(_DEPS ${VRJ22_LIBRARIES} ${OPENGL_LIBRARIES})
143	if(APPLE)
144		list(APPEND
145			_DEPS
146			${VRJOGL22_AppKit_LIBRARY}
147			${VRJOGL22_Cocoa_LIBRARY})
148	endif()
149
150	set(VRJOGL22_INCLUDE_DIRS ${VRJ22_INCLUDE_DIRS} ${OPENGL_INCLUDE_DIRS})
151
152	if(VRJUGGLER22_CREATE_IMPORTED_TARGETS)
153		create_imported_target(VRJOGL22 ${_DEPS})
154	else()
155		clean_library_list(VRJOGL22_LIBRARIES ${_DEPS})
156	endif()
157
158	mark_as_advanced(VRJOGL22_ROOT_DIR)
159endif()
160
161mark_as_advanced(VRJOGL22_LIBRARY_RELEASE VRJOGL22_LIBRARY_DEBUG)
162