1# - Try to find GMTL
2# Optionally uses Flagpoll and FindFlagpoll.cmake
3# Once done, this will define
4#
5#  GMTL_FOUND - system has GMTL
6#  GMTL_INCLUDE_DIR - the GMTL include directory
7#
8# Useful configuration variables you might want to add to your cache:
9#  GMTL_ROOT_DIR - A directory prefix to search
10#                  (a path that contains include/ as a subdirectory)
11#  GMTL_ADDITIONAL_VERSIONS - Additional versions (outside of 0.5.1 to 0.7.0)
12#                             to use when constructing search names and paths
13#
14# This script will use Flagpoll, if found, to provide hints to the location
15# of this library, but does not use the compiler flags returned by Flagpoll
16# directly.
17#
18# VR Juggler requires this package, so this Find script takes that into
19# account when determining where to search for the desired files.
20# The VJ_BASE_DIR environment variable is searched (preferentially)
21# when searching for this package, so most sane VR Juggler build environments
22# should "just work."  Note that you need to manually re-run CMake if you
23# change this environment variable, because it cannot auto-detect this change
24# and trigger an automatic re-run.
25#
26# Original Author:
27# 2009-2012 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
28# http://academic.cleardefinition.com
29# Iowa State University HCI Graduate Program/VRAC
30#
31# Copyright Iowa State University 2009-2012.
32# Distributed under the Boost Software License, Version 1.0.
33# (See accompanying file LICENSE_1_0.txt or copy at
34# http://www.boost.org/LICENSE_1_0.txt)
35
36set(_HUMAN "GMTL")
37set(_HEADER gmtl/gmtl.h)
38set(_FP_PKG_NAME gmtl)
39
40include(CheckVersion)
41
42set(GMTL_VERSIONS
43	${GMTL_ADDITIONAL_VERSIONS}
44	0.7.0
45	0.6.2
46	0.6.1
47	0.6.0
48	0.5.4
49	0.5.3
50	0.5.2
51	0.5.1)
52set(GMTL_DIRS)
53foreach(_version ${GMTL_VERSIONS})
54	check_version(_ver_ok GMTL ${_version})
55	if(_ver_ok)
56		list(APPEND GMTL_DIRS gmtl-${_version})
57		list(APPEND GMTL_HEADER_DIRS include/gmtl-${_version})
58	endif()
59endforeach()
60
61include(SelectLibraryConfigurations)
62include(CreateImportedTarget)
63include(CleanDirectoryList)
64
65# Try flagpoll.
66find_package(Flagpoll QUIET)
67
68if(FLAGPOLL)
69	flagpoll_get_include_dirs(${_FP_PKG_NAME})
70endif()
71
72set(GMTL_ROOT_DIR
73	"${GMTL_ROOT_DIR}"
74	CACHE
75	PATH
76	"Root directory to search for GMTL")
77if(DEFINED VRJUGGLER22_ROOT_DIR)
78	mark_as_advanced(GMTL_ROOT_DIR)
79endif()
80if(NOT GMTL_ROOT_DIR)
81	set(GMTL_ROOT_DIR "${VRJUGGLER22_ROOT_DIR}")
82endif()
83
84set(_ROOT_DIR "${GMTL_ROOT_DIR}")
85
86# Include dir
87find_path(GMTL_INCLUDE_DIR
88	NAMES
89	${_HEADER}
90	HINTS
91	"${_ROOT_DIR}"
92	${${_FP_PKG_NAME}_FLAGPOLL_INCLUDE_DIRS}
93	PATHS
94	PATH_SUFFIXES
95	${GMTL_DIRS}
96	${GMTL_HEADER_DIRS}
97	include/
98	DOC
99	"GMTL include path")
100
101# handle the QUIETLY and REQUIRED arguments and set xxx_FOUND to TRUE if
102# all listed variables are TRUE
103include(FindPackageHandleStandardArgs)
104find_package_handle_standard_args(GMTL DEFAULT_MSG GMTL_INCLUDE_DIR)
105
106if(GMTL_FOUND)
107	set(GMTL_INCLUDE_DIRS "${GMTL_INCLUDE_DIR}")
108	mark_as_advanced(GMTL_ROOT_DIR)
109endif()
110
111mark_as_advanced(GMTL_INCLUDE_DIR)
112