1# - try to find VPR 2.2 library
2# Requires Boost 1.33.1 or greater (including filesystem and signals libraries)
3# (and thus FindBoost.cmake from 2.8rc3 or newer, preferably)
4# Requires NSPR4 (and PLC4) on Windows
5# Requires pthreads on Unix (Mac or Linux)
6# Requires libuuid on Linux
7# Optionally uses Flagpoll and FindFlagpoll.cmake
8#
9# This library is a part of VR Juggler 3.0 - you probably want to use
10# find_package(VRJuggler30) instead, for an easy interface to this and
11# related scripts.  See FindVRJuggler30.cmake for more information.
12#
13#  VPR22_LIBRARY_DIR, library search path
14#  VPR22_INCLUDE_DIR, include search path
15#  VPR22_LIBRARY, the library to link against
16#  VPR22_FOUND, If false, do not try to use this library.
17#
18# Plural versions refer to this library and its dependencies, and
19# are recommended to be used instead, unless you have a good reason.
20#
21# Useful configuration variables you might want to add to your cache:
22#  VPR22_ROOT_DIR - A directory prefix to search
23#                   (a path that contains include/ as a subdirectory)
24#
25# This script will use Flagpoll, if found, to provide hints to the location
26# of this library, but does not use the compiler flags returned by Flagpoll
27# directly.
28#
29# The VJ_BASE_DIR environment variable is also searched (preferentially)
30# when searching for this component, so most sane build environments should
31# "just work."  Note that you need to manually re-run CMake if you change
32# this environment variable, because it cannot auto-detect this change
33# and trigger an automatic re-run.
34#
35# Original Author:
36# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
37# http://academic.cleardefinition.com
38# Iowa State University HCI Graduate Program/VRAC
39# Updated for VR Juggler 3.0 by:
40# Brandon Newendorp <brandon@newendorp.com>
41
42set(_HUMAN "VPR 2.2")
43set(_FP_PKG_NAME vpr)
44set(_RELEASE_NAMES)
45set(_DEBUG_NAMES)
46foreach(VER 2_2 2_2_0 2_2_1 2_2_2)
47	list(APPEND _RELEASE_NAMES ${_FP_PKG_NAME}-${VER})
48	list(APPEND _DEBUG_NAMES ${_FP_PKG_NAME}_d-${VER})
49endforeach()
50set(_DIR vpr-2.2)
51set(_HEADER vpr/vpr.h)
52
53include(SelectLibraryConfigurations)
54include(CreateImportedTarget)
55include(CleanLibraryList)
56include(CleanDirectoryList)
57
58if(VPR22_FIND_QUIETLY)
59	set(_FIND_FLAGS "QUIET")
60else()
61	set(_FIND_FLAGS "")
62endif()
63
64# Try flagpoll.
65find_package(Flagpoll QUIET)
66
67if(FLAGPOLL)
68	flagpoll_get_include_dirs(${_FP_PKG_NAME} NO_DEPS)
69	flagpoll_get_library_dirs(${_FP_PKG_NAME} NO_DEPS)
70	flagpoll_get_extra_libs(${_FP_PKG_NAME} NO_DEPS)
71endif()
72
73set(VPR22_ROOT_DIR
74	"${VPR22_ROOT_DIR}"
75	CACHE
76	PATH
77	"Root directory to search for VPR")
78if(DEFINED VRJUGGLER30_ROOT_DIR)
79	mark_as_advanced(VPR22_ROOT_DIR)
80endif()
81if(NOT VPR22_ROOT_DIR)
82	set(VPR22_ROOT_DIR "${VRJUGGLER30_ROOT_DIR}")
83endif()
84
85set(_ROOT_DIR "${VPR22_ROOT_DIR}")
86
87find_path(VPR22_INCLUDE_DIR
88	${_HEADER}
89	HINTS
90	"${_ROOT_DIR}"
91	${${_FP_PKG_NAME}_FLAGPOLL_INCLUDE_DIRS}
92	PATH_SUFFIXES
93	${_DIR}
94	include/${_DIR}
95	include/
96	DOC
97	"Path to ${_HUMAN} includes root")
98
99find_library(VPR22_LIBRARY_RELEASE
100	NAMES
101	${_RELEASE_NAMES}
102	HINTS
103	"${_ROOT_DIR}"
104	${${_FP_PKG_NAME}_FLAGPOLL_LIBRARY_DIRS}
105	PATH_SUFFIXES
106	${_VRJ_LIBSUFFIXES}
107	DOC
108	"${_HUMAN} release library full path")
109
110find_library(VPR22_LIBRARY_DEBUG
111	NAMES
112	${_DEBUG_NAMES}
113	HINTS
114	"${_ROOT_DIR}"
115	${${_FP_PKG_NAME}_FLAGPOLL_LIBRARY_DIRS}
116	PATH_SUFFIXES
117	${_VRJ_LIBDSUFFIXES}
118	DOC
119	"${_HUMAN} debug library full path")
120
121select_library_configurations(VPR22)
122
123# Dependencies
124set(_deps_libs)
125set(_deps_includes)
126set(_deps_check)
127if(COMMAND cmake_policy)
128	cmake_policy(SET CMP0011 NEW)
129	cmake_policy(SET CMP0012 NEW)
130endif()
131if((NOT Boost_FOUND)
132	OR (NOT Boost_FILESYSTEM_FOUND)
133	OR (NOT Boost_SIGNALS_FOUND)
134	OR (NOT Boost_SYSTEM_FOUND)
135	OR (NOT Boost_PROGRAM_OPTIONS_FOUND)
136	OR (NOT Boost_DATE_TIME_FOUND)
137	OR (NOT Boost_REGEX_FOUND))
138	if(VPR22_LIBRARY_RELEASE)
139		# Find Boost in the same place as VPR
140		get_filename_component(VPR22_LIBRARY_DIR
141			${VPR22_LIBRARY_RELEASE}
142			PATH)
143		set(BOOST_ROOT ${VPR22_LIBRARY_DIR}/../)
144
145		find_package(Boost
146			1.40.0
147			${_FIND_FLAGS}
148			COMPONENTS
149			filesystem
150			system
151			signals
152			program_options
153			date_time
154			regex)
155
156		mark_as_advanced(Boost_LIB_DIAGNOSTIC_DEFINITIONS)
157
158	endif()
159
160endif()
161
162list(APPEND
163	_deps_libs
164	${Boost_FILESYSTEM_LIBRARY}
165	${Boost_SYSTEM_LIBRARY}
166	${Boost_SIGNALS_LIBRARY}
167	${Boost_PROGRAM_OPTIONS_LIBRARY}
168	${Boost_DATE_TIME_LIBRARY}
169	${Boost_REGEX_LIBRARY})
170list(APPEND _deps_includes ${Boost_INCLUDE_DIRS})
171list(APPEND
172	_deps_check
173	Boost_FILESYSTEM_LIBRARY
174	Boost_SYSTEM_LIBRARY
175	Boost_SIGNALS_LIBRARY
176	Boost_PROGRAM_OPTIONS_LIBRARY
177	Boost_DATE_TIME_LIBRARY
178	Boost_REGEX_LIBRARY
179	Boost_INCLUDE_DIRS)
180
181if(NOT CPPDOM_FOUND)
182	find_package(CPPDOM ${_FIND_FLAGS})
183endif()
184
185list(APPEND _deps_libs ${CPPDOM_LIBRARIES})
186list(APPEND _deps_includes ${CPPDOM_INCLUDE_DIRS})
187list(APPEND _deps_check CPPDOM_LIBRARIES CPPDOM_INCLUDE_DIRS)
188
189if(UNIX AND NOT WIN32)
190	if(NOT THREADS_FOUND)
191		find_package(Threads ${_FIND_FLAGS})
192	endif()
193
194	list(APPEND _deps_check THREADS_FOUND)
195	list(APPEND _deps_libs ${CMAKE_THREAD_LIBS_INIT})
196
197	if(NOT APPLE)
198		find_library(VPR22_libuuid_LIBRARY NAMES uuid)
199		mark_as_advanced(VPR22_libuuid_LIBRARY)
200		if(VPR22_libuuid_LIBRARY)
201			list(APPEND _deps_libs ${VPR22_libuuid_LIBRARY})
202		endif()
203	endif()
204endif()
205
206# handle the QUIETLY and REQUIRED arguments and set xxx_FOUND to TRUE if
207# all listed variables are TRUE
208include(FindPackageHandleStandardArgs)
209find_package_handle_standard_args(VPR22
210	DEFAULT_MSG
211	VPR22_LIBRARY
212	VPR22_INCLUDE_DIR
213	${_deps_check})
214
215if(VPR22_FOUND)
216
217	set(VPR22_INCLUDE_DIRS ${VPR22_INCLUDE_DIR} ${_deps_includes})
218
219	clean_directory_list(VPR22_INCLUDE_DIRS)
220
221	if(VRJUGGLER30_CREATE_IMPORTED_TARGETS)
222		create_imported_target(VPR22 ${_deps_libs})
223	else()
224		clean_library_list(VPR22_LIBRARIES ${VPR22_LIBRARY} ${_deps_libs})
225	endif()
226
227	mark_as_advanced(VPR22_ROOT_DIR)
228endif()
229
230mark_as_advanced(VPR22_LIBRARY_RELEASE
231	VPR22_LIBRARY_DEBUG
232	VPR22_INCLUDE_DIR)
233