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