1# - try to find WiiUse library
2#
3# Cache Variables: (probably not for direct use in your scripts)
4#  WIIUSE_INCLUDE_DIR
5#  WIIUSE_LIBRARY
6#
7# Non-cache variables you might use in your CMakeLists.txt:
8#  WIIUSE_FOUND
9#  WIIUSE_INCLUDE_DIRS
10#  WIIUSE_LIBRARIES
11#  WIIUSE_RUNTIME_LIBRARIES - aka the dll for installing
12#  WIIUSE_RUNTIME_LIBRARY_DIRS
13#
14# Requires these CMake modules:
15#  FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
16#
17# Original Author:
18# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
19# http://academic.cleardefinition.com
20# Iowa State University HCI Graduate Program/VRAC
21#
22# Copyright Iowa State University 2009-2010.
23# Distributed under the Boost Software License, Version 1.0.
24# (See accompanying file LICENSE_1_0.txt or copy at
25# http://www.boost.org/LICENSE_1_0.txt)
26
27set(WIIUSE_ROOT_DIR
28	"${WIIUSE_ROOT_DIR}"
29	CACHE
30	PATH
31	"Directory to search for WiiUse")
32
33if(CMAKE_SIZEOF_VOID_P MATCHES "8")
34	set(_LIBSUFFIXES /lib64 /lib)
35else()
36	set(_LIBSUFFIXES /lib)
37endif()
38
39find_library(WIIUSE_LIBRARY
40	NAMES
41	wiiuse
42	PATHS
43	"${WIIUSE_ROOT_DIR}"
44	PATH_SUFFIXES
45	"${_LIBSUFFIXES}")
46
47get_filename_component(_libdir "${WIIUSE_LIBRARY}" PATH)
48
49find_path(WIIUSE_INCLUDE_DIR
50	NAMES
51	wiiuse.h
52	HINTS
53	"${_libdir}"
54	"${_libdir}/.."
55	PATHS
56	"${WIIUSE_ROOT_DIR}"
57	PATH_SUFFIXES
58	include/)
59
60set(_deps_check)
61if(WIN32)
62	find_file(WIIUSE_RUNTIME_LIBRARY
63		NAMES
64		wiiuse.dll
65		HINTS
66		"${_libdir}"
67		"${_libdir}/.."
68		PATH_SUFFIXES
69		bin)
70
71	set(WIIUSE_RUNTIME_LIBRARIES "${WIIUSE_RUNTIME_LIBRARY}")
72	get_filename_component(WIIUSE_RUNTIME_LIBRARY_DIRS
73		"${WIIUSE_RUNTIME_LIBRARY}"
74		PATH)
75	list(APPEND _deps_check WIIUSE_RUNTIME_LIBRARY)
76else()
77	set(WIIUSE_RUNTIME_LIBRARY "${WIIUSE_LIBRARY}")
78	set(WIIUSE_RUNTIME_LIBRARIES "${WIIUSE_RUNTIME_LIBRARY}")
79	get_filename_component(WIIUSE_RUNTIME_LIBRARY_DIRS
80		"${WIIUSE_LIBRARY}"
81		PATH)
82endif()
83
84include(FindPackageHandleStandardArgs)
85find_package_handle_standard_args(WiiUse
86	DEFAULT_MSG
87	WIIUSE_LIBRARY
88	WIIUSE_INCLUDE_DIR
89	${_deps_check})
90
91if(WIIUSE_FOUND)
92	set(WIIUSE_LIBRARIES "${WIIUSE_LIBRARY}")
93	set(WIIUSE_INCLUDE_DIRS "${WIIUSE_INCLUDE_DIR}")
94	mark_as_advanced(WIIUSE_ROOT_DIR)
95endif()
96
97mark_as_advanced(WIIUSE_INCLUDE_DIR
98	WIIUSE_LIBRARY
99	WIIUSE_RUNTIME_LIBRARY)
100