1# - try to find Haption VirtuoseAPI library and include files
2#
3#  VIRTUOSEAPI_INCLUDE_DIRS, where to find headers
4#  VIRTUOSEAPI_LIBRARIES, the libraries to link against
5#  VIRTUOSEAPI_FOUND, If false, do not try to use this library
6#  VIRTUOSEAPI_RUNTIME_LIBRARY_DIRS, path to DLL/SO for runtime use.
7#  VIRTUOSEAPI_RUNTIME_LIBRARIES, runtime libraries you might want to install
8
9set(VIRTUOSEAPI_ROOT_DIR
10	"${VIRTUOSEAPI_ROOT_DIR}"
11	CACHE
12	PATH
13	"Path to search for VirtuoseAPI")
14
15set(_dirs)
16if(WIN32)
17	include(ProgramFilesGlob)
18	program_files_fallback_glob(_dirs "/VirtuoseAPI_v*/")
19endif()
20
21find_path(VIRTUOSEAPI_INCLUDE_DIR
22	virtuoseAPI.h
23	VirtuoseAPI.h
24	PATHS
25	${_dirs}
26	HINTS
27	"${VIRTUOSEAPI_ROOT_DIR}")
28
29set(_suffixes)
30if(WIN32)
31	set(_lib_name virtuoseDLL)
32	set(_runtime_name virtuoseAPI.dll)
33
34	if(CMAKE_SIZEOF_VOID_P EQUAL 8)
35		set(_suffixes win64)
36	else()
37		set(_suffixes win32)
38	endif()
39elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
40	set(_lib_name virtuose)
41	set(_runtime_name virtuoseAPI.so)
42
43	if(CMAKE_SIZEOF_VOID_P EQUAL 8)
44		set(_suffixes linux-64b)
45	else()
46		set(_suffixes linux linux-2.6)
47	endif()
48endif()
49
50if(_suffixes)
51	find_library(VIRTUOSEAPI_LIBRARY
52		NAMES
53		${_lib_name}
54		PATHS
55		${_dirs}
56		HINTS
57		"${VIRTUOSEAPI_ROOT_DIR}"
58		PATH_SUFFIXES
59		${_suffixes})
60	find_file(VIRTUOSEAPI_RUNTIME_LIBRARY
61		NAMES
62		${_runtime_name}
63		PATHS
64		${_dirs}
65		HINTS
66		"${VIRTUOSEAPI_ROOT_DIR}"
67		PATH_SUFFIXES
68		${_suffixes})
69endif()
70
71# handle the QUIETLY and REQUIRED arguments and set xxx_FOUND to TRUE if
72# all listed variables are TRUE
73include(FindPackageHandleStandardArgs)
74find_package_handle_standard_args(VirtuoseAPI
75	DEFAULT_MSG
76	VIRTUOSEAPI_LIBRARY
77	VIRTUOSEAPI_RUNTIME_LIBRARY
78	VIRTUOSEAPI_INCLUDE_DIR)
79
80if(VIRTUOSEAPI_FOUND)
81	set(VIRTUOSEAPI_LIBRARIES "${VIRTUOSEAPI_LIBRARY}")
82	set(VIRTUOSEAPI_RUNTIME_LIBRARIES "${VIRTUOSEAPI_RUNTIME_LIBRARY}")
83	set(VIRTUOSEAPI_INCLUDE_DIRS "${VIRTUOSEAPI_INCLUDE_DIR}")
84	get_filename_component(VIRTUOSEAPI_RUNTIME_LIBRARY_DIRS
85		"${VIRTUOSEAPI_RUNTIME_LIBRARY}"
86		PATH)
87
88	mark_as_advanced(VIRTUOSEAPI_ROOT_DIR)
89endif()
90
91mark_as_advanced(VIRTUOSEAPI_LIBRARY
92	VIRTUOSEAPI_RUNTIME_LIBRARY
93	VIRTUOSEAPI_INCLUDE_DIR)
94