1# - try to find JCCL 1.2 library
2# Requires VPR 2.0 (thus FindVPR20.cmake)
3# Optionally uses Flagpoll and FindFlagpoll.cmake
4#
5# This library is a part of VR Juggler 2.2 - you probably want to use
6# find_package(VRJuggler22) instead, for an easy interface to this and
7# related scripts.  See FindVRJuggler22.cmake for more information.
8#
9#  JCCL12_LIBRARY_DIR, library search path
10#  JCCL12_INCLUDE_DIR, include search path
11#  JCCL12_LIBRARY, the library to link against
12#  JCCL12_FOUND, If false, do not try to use this library.
13#
14# Plural versions refer to this library and its dependencies, and
15# are recommended to be used instead, unless you have a good reason.
16#
17# Useful configuration variables you might want to add to your cache:
18#  JCCL12_ROOT_DIR - A directory prefix to search
19#                    (a path that contains include/ as a subdirectory)
20#
21# This script will use Flagpoll, if found, to provide hints to the location
22# of this library, but does not use the compiler flags returned by Flagpoll
23# directly.
24#
25# The VJ_BASE_DIR environment variable is also searched (preferentially)
26# when searching for this component, so most sane build environments should
27# "just work."  Note that you need to manually re-run CMake if you change
28# this environment variable, because it cannot auto-detect this change
29# and trigger an automatic re-run.
30#
31# Original Author:
32# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
33# http://academic.cleardefinition.com
34# Iowa State University HCI Graduate Program/VRAC
35#
36# Copyright Iowa State University 2009-2010.
37# Distributed under the Boost Software License, Version 1.0.
38# (See accompanying file LICENSE_1_0.txt or copy at
39# http://www.boost.org/LICENSE_1_0.txt)
40
41
42set(_HUMAN "JCCL 1.2")
43set(_RELEASE_NAMES jccl-1_2 libjccl-1_2)
44set(_DEBUG_NAMES jccl_d-1_2 libjccl_d-1_2)
45set(_DIR jccl-1.2)
46set(_HEADER jccl/jcclConfig.h)
47set(_FP_PKG_NAME jccl)
48
49include(SelectLibraryConfigurations)
50include(CreateImportedTarget)
51include(CleanLibraryList)
52include(CleanDirectoryList)
53
54if(JCCL12_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_include_dirs(${_FP_PKG_NAME} NO_DEPS)
65	flagpoll_get_library_dirs(${_FP_PKG_NAME} NO_DEPS)
66endif()
67
68set(JCCL12_ROOT_DIR
69	"${JCCL12_ROOT_DIR}"
70	CACHE
71	PATH
72	"Root directory to search for JCCL")
73if(DEFINED VRJUGGLER22_ROOT_DIR)
74	mark_as_advanced(JCCL12_ROOT_DIR)
75endif()
76if(NOT JCCL12_ROOT_DIR)
77	set(JCCL12_ROOT_DIR "${VRJUGGLER22_ROOT_DIR}")
78endif()
79
80set(_ROOT_DIR ${JCCL12_ROOT_DIR})
81
82find_path(JCCL12_INCLUDE_DIR
83	${_HEADER}
84	HINTS
85	"${_ROOT_DIR}"
86	${${_FP_PKG_NAME}_FLAGPOLL_INCLUDE_DIRS}
87	PATH_SUFFIXES
88	${_DIR}
89	include/${_DIR}
90	include/
91	DOC
92	"Path to ${_HUMAN} includes root")
93
94find_library(JCCL12_LIBRARY_RELEASE
95	NAMES
96	${_RELEASE_NAMES}
97	HINTS
98	"${_ROOT_DIR}"
99	${${_FP_PKG_NAME}_FLAGPOLL_LIBRARY_DIRS}
100	PATH_SUFFIXES
101	${_VRJ_LIBSUFFIXES}
102	DOC
103	"${_HUMAN} release library full path")
104
105find_library(JCCL12_LIBRARY_DEBUG
106	NAMES
107	${_DEBUG_NAMES}
108	HINTS
109	"${_ROOT_DIR}"
110	${${_FP_PKG_NAME}_FLAGPOLL_LIBRARY_DIRS}
111	PATH_SUFFIXES
112	${_VRJ_LIBDSUFFIXES}
113	DOC
114	"${_HUMAN} debug library full path")
115
116select_library_configurations(JCCL12)
117
118# Dependency
119if(NOT VPR20_FOUND)
120	find_package(VPR20 ${_FIND_FLAGS})
121endif()
122
123# handle the QUIETLY and REQUIRED arguments and set xxx_FOUND to TRUE if
124# all listed variables are TRUE
125include(FindPackageHandleStandardArgs)
126find_package_handle_standard_args(JCCL12
127	DEFAULT_MSG
128	JCCL12_LIBRARY
129	JCCL12_INCLUDE_DIR
130	VPR20_FOUND
131	VPR20_LIBRARIES
132	VPR20_INCLUDE_DIR)
133
134if(JCCL12_FOUND)
135	set(_DEPS ${VPR20_LIBRARIES})
136
137	set(JCCL12_INCLUDE_DIRS ${JCCL12_INCLUDE_DIR})
138	list(APPEND JCCL12_INCLUDE_DIRS ${VPR20_INCLUDE_DIRS})
139	clean_directory_list(JCCL12_INCLUDE_DIRS)
140
141	if(VRJUGGLER22_CREATE_IMPORTED_TARGETS)
142		create_imported_target(JCCL12 ${_DEPS})
143	else()
144		clean_library_list(JCCL12_LIBRARIES)
145	endif()
146
147	mark_as_advanced(JCCL12_ROOT_DIR)
148endif()
149
150mark_as_advanced(JCCL12_LIBRARY_RELEASE
151	JCCL12_LIBRARY_DEBUG
152	JCCL12_INCLUDE_DIR)
153