forked from rpavlik/cmake-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FindVPS.cmake
304 lines (273 loc) · 6.44 KB
/
FindVPS.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
# - try to find VPS library
#
# VPS_LIBRARY_DIR, library search path
# VPS_INCLUDE_DIR, include search path
# VPS_{component}_LIBRARY, the library to link against
# VPS_FOUND, If false, do not try to use this library.
#
# Plural versions refer to this library and its dependencies, and
# are recommended to be used instead, unless you have a good reason.
#
# Useful configuration variables you might want to add to your cache:
# VPS_ROOT_DIR - A directory prefix to search
# (a path that contains include/ as a subdirectory)
#
# Original Author:
# 2009-2010 Ryan Pavlik <[email protected]> <[email protected]>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright Iowa State University 2009-2010.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
include(SelectLibraryConfigurations)
include(ListCombinations)
include(CheckVersion)
include(ListFilter)
set(VPS_ROOT_DIR
"${VPS_ROOT_DIR}"
CACHE
PATH
"Root directory to search for VPS")
# Try the config file mode.
find_package(VPS QUIET NO_MODULE)
if(VPS_FOUND)
mark_as_advanced(VPS_DIR VPS_ROOT_DIR)
return()
endif()
if(NOT BITS)
if(CMAKE_SIZEOF_VOID_P MATCHES "8")
set(BITS 64)
else()
set(BITS 32)
endif()
endif()
set(_vpslibnames)
set(_grviewerlibnames)
###
# Cray MTA(Multi-Threaded Architecture) family: CMake build not tested
if("${CMAKE_SYSTEM_NAME}" STREQUAL "MTX")
set(VPS_PLATFORM MTX)
set(_VPS_FLAGS_32 "-pl all.pl -par")
set(_VPS_FLAGS_64 "-pl all.pl -par")
###
# Linux
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
set(VPS_PLATFORM LINUX)
set(_VPS_FLAGS_32 "-O2 -Wno-write-strings")
set(_VPS_FLAGS_64 "-m64 -O3 -ffast-math -funroll-all-loops -Wno-write-strings")
###
# IBM-AIX: CMake build not tested
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "AIX")
set(VPS_PLATFORM AIX)
set(_VPS_FLAGS_32 "-q32")
set(_VPS_FLAGS_64 "-q64")
###
# HP-UX: CMake build not tested
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "HP-UX")
set(VPS_PLATFORM HPUX)
set(_VPS_FLAGS_32 "-O")
###
# SunOS: CMake build not tested
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")
set(VPS_PLATFORM SOLARIS)
set(_VPS_FLAGS_32 "-O")
###
# IRIX: CMake build not tested
elseif("${CMAKE_SYSTEM_NAME}" MATCHES "IRIX")
set(VPS_PLATFORM IRIX)
set(_VPS_FLAGS_32 "-O2 -OPT")
set(_VPS_FLAGS_64 "-64 -O2 -OPT")
###
# Mac OS X
elseif(APPLE AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
set(VPS_PLATFORM MACOSX)
set(_VPS_FLAGS_32 "-O2 -lm -lobjc -lstdc++ -Wno-write-strings")
set(_VPS_FLAGS_64 "-m64 -O3 -ffast-math -funroll-all-loops -lm -lobjc -lstdc++ -Wno-write-strings")
###
# Windows
elseif(WIN32)
set(VPS_PLATFORM WINDOWS)
set(_VPS_FLAGS_32 "-O2")
set(_VPS_FLAGS_64 "-O2")
if(MSVC)
set(DEFS_32 -D_CRT_SECURE_NO_DEPRECATE)
set(DEFS_64 -D_CRT_SECURE_NO_DEPRECATE)
if(MSVC60)
set(VPS_CRT "VC6")
elseif(MSVC70)
set(VPS_CRT "VC7")
elseif(MSVC71)
set(VPS_CRT "VC71")
elseif(MSVC80)
set(VPS_CRT "VC8")
elseif(MSVC90)
set(VPS_CRT "VC9")
elseif(MSVC10)
set(VPS_CRT "VC10")
else()
set(VPS_CRT "VC")
endif()
endif()
endif()
if(WIN32 AND MSVC)
set(PLATFORM win${BITS})
set(_threadsuffix Mt)
if(MSVC71)
set(VC_VER vc71)
set(VC_VER_LONG vc71)
elseif(MSVC80)
set(VC_SHORT VC8)
set(VC_LONG MSVC80)
elseif(MSVC90)
set(VC_SHORT VC9)
set(VC_LONG MSVC90)
endif()
list(APPEND
_vpslibnames
"Vps${VC_SHORT}_${BITS}"
"Vps${VC_SHORT}_${BITS}${_threadsuffix}")
endif()
list(APPEND _vpslibnames "Vps${VPS_PLATFORM}${VPS_CRT}_${BITS}")
list(APPEND
_grviewerlibnames
"Viewer"
"GrViewer${VPS_PLATFORM}${VPS_CRT}_${BITS}")
###
# Configure VPS
###
set(_incsearchdirs)
set(_libsearchdirs)
if(WIN32)
include(ProgramFilesGlob)
program_files_glob(_dirs "/VPS*/")
program_files_glob(_dirs2 "/VPS/*/")
list(APPEND _dirs ${_dirs2})
endif()
list_combinations(_libsearchdirs
PREFIXES
"${VPS_ROOT_DIR}"
"${_dirs}"
SUFFIXES
"/lib"
"/Viewer")
list_combinations(_libsearchdirs2
PREFIXES
${_libsearchdirs}
SUFFIXES
"/Release"
"/RelWithDebInfo"
"/MinSizeRel"
"/Debug")
clean_directory_list(_libsearchdirs ${_libsearchdirs2})
list_combinations(_incsearchdirs
PREFIXES
"${VPS_ROOT_DIR}"
"${_dirs}"
SUFFIXES
"/include"
"/include/vps"
"/src"
"/../src"
"/Viewer"
"/../Viewer")
clean_directory_list(_incsearchdirs)
# If a version was specified, the least we can do is remove any directories
# from our search that contain too low of versions
if(VPS_FIND_VERSION)
set(_badversions)
foreach(_dir ${_libsearchdirs})
string(REGEX MATCH "([0-9]).([0-9]).([0-9])" _ver "${_dir}")
if(_ver)
string(REGEX
REPLACE
"([0-9]).([0-9]).([0-9])"
"\\1.\\2.\\3"
_verstd
"${_ver}")
check_version(_result VPS "${_verstd}")
if(NOT _result)
list(APPEND _badversions "${_verstd}")
endif()
endif()
endforeach()
foreach(_badver ${_badversions})
list_filter_out(_libsearchdirs ${_badver} ${_libsearchdirs})
list_filter_out(_incsearchdirs ${_badver} ${_incsearchdirs})
endforeach()
endif()
if(_libsearchdirs)
list(SORT _libsearchdirs)
list(REVERSE _libsearchdirs)
endif()
if(_incsearchdirs)
list(SORT _incsearchdirs)
list(REVERSE _incsearchdirs)
endif()
find_library(VPS_vps_LIBRARY
NAMES
${_vpslibnames}
PATH_SUFFIXES
LP
HINTS
${_libsearchdirs}
PATHS
${VPS_ROOT_DIR}
${VPS_ROOT_DIR}/src
${VPS_ROOT_DIR}/lib)
find_path(VPS_vps_INCLUDE_DIR
NAMES
Vps.h
HINTS
${_incsearchdirs}
PATHS
${VPS_ROOT_DIR}
PATH_SUFFIXES
include
include/vps
src)
find_library(VPS_grviewer_LIBRARY
NAMES
${_grviewerlibnames}
HINTS
${_libsearchdirs}
PATHS
${VPS_ROOT_DIR}
PATH_SUFFIXES
lib
Viewer)
find_path(VPS_grviewer_INCLUDE_DIR
NAMES
grViewerLib.h
HINTS
${_incsearchdirs}
PATHS
${VPS_ROOT_DIR}
PATH_SUFFIXES
include
include/vps
Viewer)
mark_as_advanced(VPS_vps_LIBRARY
VPS_vps_INCLUDE_DIR
VPS_grviewer_LIBRARY
VPS_grviewer_INCLUDE_DIR)
# handle the QUIETLY and REQUIRED arguments and set xxx_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(VPS
DEFAULT_MSG
VPS_vps_LIBRARY
VPS_vps_INCLUDE_DIR)
if(VPS_FOUND)
set(VPS_vps_INCLUDE_DIRS "${VPS_vps_INCLUDE_DIR}")
set(VPS_INCLUDE_DIRS "${VPS_vps_INCLUDE_DIR}")
set(VPS_grviewer_INCLUDE_DIRS
"${VPS_vps_INCLUDE_DIR}"
"${VPS_grviewer_INCLUDE_DIR}")
set(VPS_LIBRARIES "${VPS_vps_LIBRARY}")
set(VPS_grviewer_LIBRARIES
"${VPS_vps_LIBRARY}"
"${VPS_grviewer_LIBRARY}")
mark_as_advanced(VPS_ROOT_DIR VPS_DIR)
endif()