1# - try to find PARASOLID library 2# Important note: If you are also using JtTk, do your 3# find_package(JtTk) 4# first, to avoid runtime PK_* errors! 5# 6# PARASOLID_LIBRARY_DIR, library search path 7# PARASOLID_INCLUDE_DIR, include search path 8# PARASOLID_{component}_LIBRARY, the library to link against 9# PARASOLID_FOUND, If false, do not try to use this library. 10# 11# Plural versions refer to this library and its dependencies, and 12# are recommended to be used instead, unless you have a good reason. 13# 14# Requires these CMake modules: 15# CheckVersion 16# ListCombinations 17# ProgramFilesGlob 18# FindPackageHandleStandardArgs (known included with CMake >=2.6.2) 19# 20# Original Author: 21# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net> 22# http://academic.cleardefinition.com 23# Iowa State University HCI Graduate Program/VRAC 24# 25# Copyright Iowa State University 2009-2010. 26# Distributed under the Boost Software License, Version 1.0. 27# (See accompanying file LICENSE_1_0.txt or copy at 28# http://www.boost.org/LICENSE_1_0.txt) 29 30include(ListCombinations) 31include(CheckVersion) 32include(PrefixListGlob) 33include(CleanDirectoryList) 34if(WIN32) 35 include(ProgramFilesGlob) 36endif() 37 38set(PARASOLID_ROOT_DIR 39 "${PARASOLID_ROOT_DIR}" 40 CACHE 41 PATH 42 "Root directory to search for Parasolid") 43 44file(TO_CMAKE_PATH "${PARASOLID_ROOT_DIR}" PARASOLID_ROOT_DIR) 45 46# Do this by default 47if(NOT DEFINED PARASOLID_NESTED_TARGETS) 48 set(PARASOLID_NESTED_TARGETS TRUE) 49endif() 50 51set(PARASOLID_NESTED_TARGETS 52 "${PARASOLID_NESTED_TARGETS}" 53 CACHE 54 BOOL 55 "Whether we should compile fg and frustrum as a part of the solution") 56mark_as_advanced(PARASOLID_NESTED_TARGETS) 57 58set(_nest_targets) 59 60### 61# Configure Parasolid 62### 63 64string(TOLOWER "${CMAKE_SYSTEM_NAME}" _lcsystem) 65set(libsearchdirs) 66if(WIN32) 67 if(CMAKE_SIZEOF_VOID_P MATCHES "8") 68 # 64-bit 69 program_files_fallback_glob(dirs "/Parasolid*/kernel/x64_win/base") 70 program_files_fallback_glob(dirs2 "/Parasolid/kernel/*/x64_win/base") 71 list(APPEND dirs ${dirs2}) 72 else() 73 # 32-bit 74 program_files_glob(dirs "/Parasolid*/kernel/intel_nt/base") 75 program_files_fallback_glob(dirs2 "/Parasolid/kernel/*/intel_nt/base") 76 list(APPEND dirs ${dirs2}) 77 endif() 78 79 list_combinations(libsearchdirs 80 PREFIXES 81 ${dirs} 82 "${PARASOLID_ROOT_DIR}" 83 SUFFIXES 84 "/dll") 85 list(APPEND libsearchdirs ${dirs} "${PARASOLID_ROOT_DIR}") 86elseif("${_lcsystem}" MATCHES "linux") 87 if(CMAKE_SIZEOF_VOID_P MATCHES "8") 88 # 64-bit 89 prefix_list_glob(libsearchdirs 90 "/Parasolid*/kernel/intel_linux/base_lx64" 91 "${PARASOLID_ROOT_DIR}" 92 "/usr" 93 "/usr/local" 94 "/usr/local/ugs") 95 else() 96 # 32-bit 97 prefix_list_glob(libsearchdirs 98 "/Parasolid*/kernel/intel_linux/base_lx32" 99 "${PARASOLID_ROOT_DIR}" 100 "/usr" 101 "/usr/local" 102 "/usr/local/ugs") 103 endif() 104endif() 105 106### 107# Find the link library 108### 109find_library(PARASOLID_pskernel_LIBRARY 110 NAMES 111 pskernel 112 PATH_SUFFIXES 113 dll 114 shared_object 115 HINTS 116 ${libsearchdirs} 117 PATHS 118 "${PARASOLID_ROOT_DIR}") 119 120 121# Don't add this library to the default list of libraries 122find_library(PARASOLID_pskernel_archive_LIBRARY 123 NAMES 124 pskernel_archive 125 pskernel_archive.lib 126 HINTS 127 ${libsearchdirs} 128 PATHS 129 "${PARASOLID_ROOT_DIR}") 130mark_as_advanced(PARASOLID_pskernel_archive_LIBRARY) 131 132 133### 134# Prepare for the rest of our search based off of where we found the link library 135### 136get_filename_component(PARASOLID_LIBRARY_DIR 137 "${PARASOLID_pskernel_LIBRARY}" 138 PATH) 139 140# Setup include search path 141get_filename_component(_includedir 142 "${PARASOLID_LIBRARY_DIR}/../include" 143 ABSOLUTE) 144get_filename_component(_includedir2 145 "${PARASOLID_LIBRARY_DIR}/.." 146 ABSOLUTE) 147set(includesearchdirs 148 "${PARASOLID_LIBRARY_DIR}" 149 "${_includedir}" 150 "${_includedir2}") 151clean_directory_list(includesearchdirs) 152 153### 154# Find the headers 155### 156find_path(PARASOLID_INCLUDE_DIR 157 NAMES 158 parasolid_kernel.h 159 HINTS 160 ${includesearchdirs} 161 PATHS 162 "${PARASOLID_ROOT_DIR}") 163 164### 165# Find remaining libs 166### 167 168# Default libs 169foreach(lib fg frustrum) 170 find_library(PARASOLID_${lib}_LIBRARY 171 NAMES 172 ${lib} 173 PATH_SUFFIXES 174 dll 175 HINTS 176 "${PARASOLID_LIBRARY_DIR}" 177 ${libsearchdirs} 178 PATHS 179 "${PARASOLID_ROOT_DIR}") 180 181endforeach() 182 183if(PARASOLID_pskernel_LIBRARY OR PARASOLID_INCLUDE_DIR) 184 get_filename_component(_libdir "${PARASOLID_pskernel_LIBRARY}" PATH) 185 get_filename_component(_incdir "${PARASOLID_INCLUDE_DIR}" PATH) 186 187 if(PARASOLID_NESTED_TARGETS OR NOT PARASOLID_fg_LIBRARY) 188 find_file(PARASOLID_FG_C 189 NAMES 190 fg.c 191 HINTS 192 "${_libdir}" 193 "${_libdir}/.." 194 "${_incdir}") 195 if(PARASOLID_FG_C) 196 mark_as_advanced(PARASOLID_FG_C) 197 set(_nest_targets YES) 198 set(PARASOLID_fg_LIBRARY 199 "parasolid_fg_nested_target" 200 CACHE 201 STRING 202 "We will build the Parasolid fg lib." 203 FORCE) 204 endif() 205 endif() 206 207 if(PARASOLID_NESTED_TARGETS OR NOT PARASOLID_frustrum_LIBRARY) 208 find_file(PARASOLID_FRUSTRUM_C 209 NAMES 210 frustrum.c 211 HINTS 212 "${_libdir}" 213 "${_libdir}/.." 214 "${_incdir}") 215 if(PARASOLID_FRUSTRUM_C) 216 mark_as_advanced(PARASOLID_FRUSTRUM_C) 217 set(_nest_targets YES) 218 set(PARASOLID_frustrum_LIBRARY 219 "parasolid_frustrum_nested_target" 220 CACHE 221 STRING 222 "We will build the Parasolid frustrum lib." 223 FORCE) 224 endif() 225 endif() 226 227endif() 228 229# Non-default libs 230foreach(lib testfr) 231 find_library(PARASOLID_${lib}_LIBRARY 232 NAMES 233 ${lib} 234 PATH_SUFFIXES 235 dll 236 HINTS 237 ${PARASOLID_LIBRARY_DIR} 238 ${libsearchdirs} 239 PATHS 240 "${PARASOLID_ROOT_DIR}") 241 mark_as_advanced(PARASOLID_${lib}_LIBRARY) 242endforeach() 243 244### 245# Find the DLL's 246### 247 248if(JTTK_FOUND AND JTTK_pskernel_DLL) 249 # If we have JtTk, must use the dll there or we'll have weird runtime errors 250 # in parasolid 251 set(PARASOLID_pskernel_DLL "${JTTK_pskernel_DLL}") 252else() 253 # Find the unversioned DLL 254 set(dll pskernel) 255 find_file(PARASOLID_${dll}_DLL 256 NAMES 257 ${dll}.dll 258 PATH_SUFFIXES 259 dll 260 HINTS 261 ${PARASOLID_LIBRARY_DIR} 262 ${libsearchdirs} 263 PATHS 264 "${PARASOLID_ROOT_DIR}") 265 list(APPEND PARASOLID_DLLS ${PARASOLID_${dll}_DLL}) 266 mark_as_advanced(PARASOLID_${dll}_DLL) 267endif() 268 269# handle the QUIETLY and REQUIRED arguments and set xxx_FOUND to TRUE if 270# all listed variables are TRUE 271include(FindPackageHandleStandardArgs) 272find_package_handle_standard_args(Parasolid 273 DEFAULT_MSG 274 PARASOLID_pskernel_LIBRARY 275 PARASOLID_fg_LIBRARY 276 PARASOLID_frustrum_LIBRARY 277 PARASOLID_INCLUDE_DIR) 278 279if(PARASOLID_FOUND) 280 # Recurse into the nested targets subdirectory if needed 281 if(_nest_targets) 282 get_filename_component(_moddir "${CMAKE_CURRENT_LIST_FILE}" PATH) 283 add_subdirectory("${_moddir}/nested_targets/Parasolid") 284 endif() 285 286 set(PARASOLID_INCLUDE_DIRS "${PARASOLID_INCLUDE_DIR}") 287 set(PARASOLID_LIBRARIES 288 "${PARASOLID_pskernel_LIBRARY}" 289 "${PARASOLID_fg_LIBRARY}" 290 "${PARASOLID_frustrum_LIBRARY}") 291 if(PARASOLID_pskernel_DLL) 292 get_filename_component(PARASOLID_RUNTIME_LIBRARY_DIRS 293 "${PARASOLID_pskernel_DLL}" 294 PATH) 295 endif() 296 mark_as_advanced(PARASOLID_ROOT_DIR) 297endif() 298 299mark_as_advanced(PARASOLID_pskernel_LIBRARY 300 PARASOLID_pskernel_archive_LIBRARY 301 PARASOLID_fg_LIBRARY 302 PARASOLID_frustrum_LIBRARY 303 PARASOLID_INCLUDE_DIR 304 PARASOLID_FRUSTRUM_C 305 PARASOLID_FG_C) 306