forked from rpavlik/cmake-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FindParasolid.cmake
305 lines (275 loc) · 6.9 KB
/
FindParasolid.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
305
# - try to find PARASOLID library
# Important note: If you are also using JtTk, do your
# find_package(JtTk)
# first, to avoid runtime PK_* errors!
#
# PARASOLID_LIBRARY_DIR, library search path
# PARASOLID_INCLUDE_DIR, include search path
# PARASOLID_{component}_LIBRARY, the library to link against
# PARASOLID_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.
#
# Requires these CMake modules:
# CheckVersion
# ListCombinations
# ProgramFilesGlob
# FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
#
# Original Author:
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
# 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(ListCombinations)
include(CheckVersion)
include(PrefixListGlob)
include(CleanDirectoryList)
if(WIN32)
include(ProgramFilesGlob)
endif()
set(PARASOLID_ROOT_DIR
"${PARASOLID_ROOT_DIR}"
CACHE
PATH
"Root directory to search for Parasolid")
file(TO_CMAKE_PATH "${PARASOLID_ROOT_DIR}" PARASOLID_ROOT_DIR)
# Do this by default
if(NOT DEFINED PARASOLID_NESTED_TARGETS)
set(PARASOLID_NESTED_TARGETS TRUE)
endif()
set(PARASOLID_NESTED_TARGETS
"${PARASOLID_NESTED_TARGETS}"
CACHE
BOOL
"Whether we should compile fg and frustrum as a part of the solution")
mark_as_advanced(PARASOLID_NESTED_TARGETS)
set(_nest_targets)
###
# Configure Parasolid
###
string(TOLOWER "${CMAKE_SYSTEM_NAME}" _lcsystem)
set(libsearchdirs)
if(WIN32)
if(CMAKE_SIZEOF_VOID_P MATCHES "8")
# 64-bit
program_files_fallback_glob(dirs "/Parasolid*/kernel/x64_win/base")
program_files_fallback_glob(dirs2 "/Parasolid/kernel/*/x64_win/base")
list(APPEND dirs ${dirs2})
else()
# 32-bit
program_files_glob(dirs "/Parasolid*/kernel/intel_nt/base")
program_files_fallback_glob(dirs2 "/Parasolid/kernel/*/intel_nt/base")
list(APPEND dirs ${dirs2})
endif()
list_combinations(libsearchdirs
PREFIXES
${dirs}
"${PARASOLID_ROOT_DIR}"
SUFFIXES
"/dll")
list(APPEND libsearchdirs ${dirs} "${PARASOLID_ROOT_DIR}")
elseif("${_lcsystem}" MATCHES "linux")
if(CMAKE_SIZEOF_VOID_P MATCHES "8")
# 64-bit
prefix_list_glob(libsearchdirs
"/Parasolid*/kernel/intel_linux/base_lx64"
"${PARASOLID_ROOT_DIR}"
"/usr"
"/usr/local"
"/usr/local/ugs")
else()
# 32-bit
prefix_list_glob(libsearchdirs
"/Parasolid*/kernel/intel_linux/base_lx32"
"${PARASOLID_ROOT_DIR}"
"/usr"
"/usr/local"
"/usr/local/ugs")
endif()
endif()
###
# Find the link library
###
find_library(PARASOLID_pskernel_LIBRARY
NAMES
pskernel
PATH_SUFFIXES
dll
shared_object
HINTS
${libsearchdirs}
PATHS
"${PARASOLID_ROOT_DIR}")
# Don't add this library to the default list of libraries
find_library(PARASOLID_pskernel_archive_LIBRARY
NAMES
pskernel_archive
pskernel_archive.lib
HINTS
${libsearchdirs}
PATHS
"${PARASOLID_ROOT_DIR}")
mark_as_advanced(PARASOLID_pskernel_archive_LIBRARY)
###
# Prepare for the rest of our search based off of where we found the link library
###
get_filename_component(PARASOLID_LIBRARY_DIR
"${PARASOLID_pskernel_LIBRARY}"
PATH)
# Setup include search path
get_filename_component(_includedir
"${PARASOLID_LIBRARY_DIR}/../include"
ABSOLUTE)
get_filename_component(_includedir2
"${PARASOLID_LIBRARY_DIR}/.."
ABSOLUTE)
set(includesearchdirs
"${PARASOLID_LIBRARY_DIR}"
"${_includedir}"
"${_includedir2}")
clean_directory_list(includesearchdirs)
###
# Find the headers
###
find_path(PARASOLID_INCLUDE_DIR
NAMES
parasolid_kernel.h
HINTS
${includesearchdirs}
PATHS
"${PARASOLID_ROOT_DIR}")
###
# Find remaining libs
###
# Default libs
foreach(lib fg frustrum)
find_library(PARASOLID_${lib}_LIBRARY
NAMES
${lib}
PATH_SUFFIXES
dll
HINTS
"${PARASOLID_LIBRARY_DIR}"
${libsearchdirs}
PATHS
"${PARASOLID_ROOT_DIR}")
endforeach()
if(PARASOLID_pskernel_LIBRARY OR PARASOLID_INCLUDE_DIR)
get_filename_component(_libdir "${PARASOLID_pskernel_LIBRARY}" PATH)
get_filename_component(_incdir "${PARASOLID_INCLUDE_DIR}" PATH)
if(PARASOLID_NESTED_TARGETS OR NOT PARASOLID_fg_LIBRARY)
find_file(PARASOLID_FG_C
NAMES
fg.c
HINTS
"${_libdir}"
"${_libdir}/.."
"${_incdir}")
if(PARASOLID_FG_C)
mark_as_advanced(PARASOLID_FG_C)
set(_nest_targets YES)
set(PARASOLID_fg_LIBRARY
"parasolid_fg_nested_target"
CACHE
STRING
"We will build the Parasolid fg lib."
FORCE)
endif()
endif()
if(PARASOLID_NESTED_TARGETS OR NOT PARASOLID_frustrum_LIBRARY)
find_file(PARASOLID_FRUSTRUM_C
NAMES
frustrum.c
HINTS
"${_libdir}"
"${_libdir}/.."
"${_incdir}")
if(PARASOLID_FRUSTRUM_C)
mark_as_advanced(PARASOLID_FRUSTRUM_C)
set(_nest_targets YES)
set(PARASOLID_frustrum_LIBRARY
"parasolid_frustrum_nested_target"
CACHE
STRING
"We will build the Parasolid frustrum lib."
FORCE)
endif()
endif()
endif()
# Non-default libs
foreach(lib testfr)
find_library(PARASOLID_${lib}_LIBRARY
NAMES
${lib}
PATH_SUFFIXES
dll
HINTS
${PARASOLID_LIBRARY_DIR}
${libsearchdirs}
PATHS
"${PARASOLID_ROOT_DIR}")
mark_as_advanced(PARASOLID_${lib}_LIBRARY)
endforeach()
###
# Find the DLL's
###
if(JTTK_FOUND AND JTTK_pskernel_DLL)
# If we have JtTk, must use the dll there or we'll have weird runtime errors
# in parasolid
set(PARASOLID_pskernel_DLL "${JTTK_pskernel_DLL}")
else()
# Find the unversioned DLL
set(dll pskernel)
find_file(PARASOLID_${dll}_DLL
NAMES
${dll}.dll
PATH_SUFFIXES
dll
HINTS
${PARASOLID_LIBRARY_DIR}
${libsearchdirs}
PATHS
"${PARASOLID_ROOT_DIR}")
list(APPEND PARASOLID_DLLS ${PARASOLID_${dll}_DLL})
mark_as_advanced(PARASOLID_${dll}_DLL)
endif()
# 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(Parasolid
DEFAULT_MSG
PARASOLID_pskernel_LIBRARY
PARASOLID_fg_LIBRARY
PARASOLID_frustrum_LIBRARY
PARASOLID_INCLUDE_DIR)
if(PARASOLID_FOUND)
# Recurse into the nested targets subdirectory if needed
if(_nest_targets)
get_filename_component(_moddir "${CMAKE_CURRENT_LIST_FILE}" PATH)
add_subdirectory("${_moddir}/nested_targets/Parasolid")
endif()
set(PARASOLID_INCLUDE_DIRS "${PARASOLID_INCLUDE_DIR}")
set(PARASOLID_LIBRARIES
"${PARASOLID_pskernel_LIBRARY}"
"${PARASOLID_fg_LIBRARY}"
"${PARASOLID_frustrum_LIBRARY}")
if(PARASOLID_pskernel_DLL)
get_filename_component(PARASOLID_RUNTIME_LIBRARY_DIRS
"${PARASOLID_pskernel_DLL}"
PATH)
endif()
mark_as_advanced(PARASOLID_ROOT_DIR)
endif()
mark_as_advanced(PARASOLID_pskernel_LIBRARY
PARASOLID_pskernel_archive_LIBRARY
PARASOLID_fg_LIBRARY
PARASOLID_frustrum_LIBRARY
PARASOLID_INCLUDE_DIR
PARASOLID_FRUSTRUM_C
PARASOLID_FG_C)