-
Notifications
You must be signed in to change notification settings - Fork 9
/
FindFFTW.cmake
419 lines (365 loc) · 11.8 KB
/
FindFFTW.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
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
# - Find the FFTW library
#
# Original version of this file:
# Copyright (c) 2015, Wenzel Jakob
# https://github.com/wjakob/layerlab/blob/master/cmake/FindFFTW.cmake, commit 4d58bfdc28891b4f9373dfe46239dda5a0b561c6
# Modifications:
# Copyright (c) 2017, Patrick Bos
#
# Usage:
# find_package(FFTW [REQUIRED] [QUIET] [COMPONENTS component1 ... componentX] )
#
# It sets the following variables:
# FFTW_FOUND ... true if fftw is found on the system
# FFTW_[component]_LIB_FOUND ... true if the component is found on the system (see components below)
# FFTW_LIBRARIES ... full paths to all found fftw libraries
# FFTW_[component]_LIB ... full path to one of the components (see below)
# FFTW_INCLUDE_DIRS ... fftw include directory paths
#
# The following variables will be checked by the function
# FFTW_USE_STATIC_LIBS ... if true, only static libraries are found, otherwise both static and shared.
# FFTW_ROOT ... if set, the libraries are exclusively searched
# under this path
#
# This package supports the following components:
# FLOAT_LIB
# DOUBLE_LIB
# LONGDOUBLE_LIB
# FLOAT_THREADS_LIB
# DOUBLE_THREADS_LIB
# LONGDOUBLE_THREADS_LIB
# FLOAT_OPENMP_LIB
# DOUBLE_OPENMP_LIB
# LONGDOUBLE_OPENMP_LIB
#
# TODO (maybe): extend with ExternalProject download + build option
# TODO: put on conda-forge
if( NOT FFTW_ROOT AND DEFINED ENV{FFTWDIR} )
set( FFTW_ROOT $ENV{FFTWDIR} )
endif()
# Check if we can use PkgConfig
find_package(PkgConfig)
#Determine from PKG
if( PKG_CONFIG_FOUND AND NOT FFTW_ROOT )
pkg_check_modules( PKG_FFTW QUIET "fftw3" )
endif()
#Check whether to search static or dynamic libs
set( CMAKE_FIND_LIBRARY_SUFFIXES_SAV ${CMAKE_FIND_LIBRARY_SUFFIXES} )
if( ${FFTW_USE_STATIC_LIBS} )
set( CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX} )
else()
set( CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_SAV} )
endif()
if( FFTW_ROOT )
# find libs
find_library(
FFTW_DOUBLE_LIB
NAMES "fftw3" libfftw3-3
PATHS ${FFTW_ROOT}
PATH_SUFFIXES "lib" "lib64"
NO_DEFAULT_PATH
)
find_library(
FFTW_DOUBLE_THREADS_LIB
NAMES "fftw3_threads"
PATHS ${FFTW_ROOT}
PATH_SUFFIXES "lib" "lib64"
NO_DEFAULT_PATH
)
find_library(
FFTW_DOUBLE_OPENMP_LIB
NAMES "fftw3_omp"
PATHS ${FFTW_ROOT}
PATH_SUFFIXES "lib" "lib64"
NO_DEFAULT_PATH
)
find_library(
FFTW_DOUBLE_MPI_LIB
NAMES "fftw3_mpi"
PATHS ${FFTW_ROOT}
PATH_SUFFIXES "lib" "lib64"
NO_DEFAULT_PATH
)
find_library(
FFTW_FLOAT_LIB
NAMES "fftw3f" libfftw3f-3
PATHS ${FFTW_ROOT}
PATH_SUFFIXES "lib" "lib64"
NO_DEFAULT_PATH
)
find_library(
FFTW_FLOAT_THREADS_LIB
NAMES "fftw3f_threads"
PATHS ${FFTW_ROOT}
PATH_SUFFIXES "lib" "lib64"
NO_DEFAULT_PATH
)
find_library(
FFTW_FLOAT_OPENMP_LIB
NAMES "fftw3f_omp"
PATHS ${FFTW_ROOT}
PATH_SUFFIXES "lib" "lib64"
NO_DEFAULT_PATH
)
find_library(
FFTW_FLOAT_MPI_LIB
NAMES "fftw3f_mpi"
PATHS ${FFTW_ROOT}
PATH_SUFFIXES "lib" "lib64"
NO_DEFAULT_PATH
)
find_library(
FFTW_LONGDOUBLE_LIB
NAMES "fftw3l" libfftw3l-3
PATHS ${FFTW_ROOT}
PATH_SUFFIXES "lib" "lib64"
NO_DEFAULT_PATH
)
find_library(
FFTW_LONGDOUBLE_THREADS_LIB
NAMES "fftw3l_threads"
PATHS ${FFTW_ROOT}
PATH_SUFFIXES "lib" "lib64"
NO_DEFAULT_PATH
)
find_library(
FFTW_LONGDOUBLE_OPENMP_LIB
NAMES "fftw3l_omp"
PATHS ${FFTW_ROOT}
PATH_SUFFIXES "lib" "lib64"
NO_DEFAULT_PATH
)
find_library(
FFTW_LONGDOUBLE_MPI_LIB
NAMES "fftw3l_mpi"
PATHS ${FFTW_ROOT}
PATH_SUFFIXES "lib" "lib64"
NO_DEFAULT_PATH
)
#find includes
find_path(FFTW_INCLUDE_DIRS
NAMES "fftw3.h"
PATHS ${FFTW_ROOT}
PATH_SUFFIXES "include"
NO_DEFAULT_PATH
)
else()
find_library(
FFTW_DOUBLE_LIB
NAMES "fftw3"
PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR}
)
find_library(
FFTW_DOUBLE_THREADS_LIB
NAMES "fftw3_threads"
PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR}
)
find_library(
FFTW_DOUBLE_OPENMP_LIB
NAMES "fftw3_omp"
PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR}
)
find_library(
FFTW_DOUBLE_MPI_LIB
NAMES "fftw3_mpi"
PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR}
)
find_library(
FFTW_FLOAT_LIB
NAMES "fftw3f"
PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR}
)
find_library(
FFTW_FLOAT_THREADS_LIB
NAMES "fftw3f_threads"
PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR}
)
find_library(
FFTW_FLOAT_OPENMP_LIB
NAMES "fftw3f_omp"
PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR}
)
find_library(
FFTW_FLOAT_MPI_LIB
NAMES "fftw3f_mpi"
PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR}
)
find_library(
FFTW_LONGDOUBLE_LIB
NAMES "fftw3l"
PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR}
)
find_library(
FFTW_LONGDOUBLE_THREADS_LIB
NAMES "fftw3l_threads"
PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR}
)
find_library(FFTW_LONGDOUBLE_OPENMP_LIB
NAMES "fftw3l_omp"
PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR}
)
find_library(FFTW_LONGDOUBLE_MPI_LIB
NAMES "fftw3l_mpi"
PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR}
)
find_path(FFTW_INCLUDE_DIRS
NAMES "fftw3.h"
PATHS ${PKG_FFTW_INCLUDE_DIRS} ${INCLUDE_INSTALL_DIR}
)
endif( FFTW_ROOT )
#--------------------------------------- components
if (FFTW_DOUBLE_LIB)
set(FFTW_DOUBLE_LIB_FOUND TRUE)
set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_DOUBLE_LIB})
add_library(FFTW::Double INTERFACE IMPORTED)
set_target_properties(FFTW::Double
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${FFTW_DOUBLE_LIB}"
)
else()
set(FFTW_DOUBLE_LIB_FOUND FALSE)
endif()
if (FFTW_FLOAT_LIB)
set(FFTW_FLOAT_LIB_FOUND TRUE)
set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_FLOAT_LIB})
add_library(FFTW::Float INTERFACE IMPORTED)
set_target_properties(FFTW::Float
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${FFTW_FLOAT_LIB}"
)
else()
set(FFTW_FLOAT_LIB_FOUND FALSE)
endif()
if (FFTW_LONGDOUBLE_LIB)
set(FFTW_LONGDOUBLE_LIB_FOUND TRUE)
set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_LONGDOUBLE_LIB})
add_library(FFTW::LongDouble INTERFACE IMPORTED)
set_target_properties(FFTW::LongDouble
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${FFTW_LONGDOUBLE_LIB}"
)
else()
set(FFTW_LONGDOUBLE_LIB_FOUND FALSE)
endif()
if (FFTW_DOUBLE_THREADS_LIB)
set(FFTW_DOUBLE_THREADS_LIB_FOUND TRUE)
set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_DOUBLE_THREADS_LIB})
add_library(FFTW::DoubleThreads INTERFACE IMPORTED)
set_target_properties(FFTW::DoubleThreads
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${FFTW_DOUBLE_THREADS_LIB}"
)
else()
set(FFTW_DOUBLE_THREADS_LIB_FOUND FALSE)
endif()
if (FFTW_FLOAT_THREADS_LIB)
set(FFTW_FLOAT_THREADS_LIB_FOUND TRUE)
set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_FLOAT_THREADS_LIB})
add_library(FFTW::FloatThreads INTERFACE IMPORTED)
set_target_properties(FFTW::FloatThreads
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${FFTW_FLOAT_THREADS_LIB}"
)
else()
set(FFTW_FLOAT_THREADS_LIB_FOUND FALSE)
endif()
if (FFTW_LONGDOUBLE_THREADS_LIB)
set(FFTW_LONGDOUBLE_THREADS_LIB_FOUND TRUE)
set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_LONGDOUBLE_THREADS_LIB})
add_library(FFTW::LongDoubleThreads INTERFACE IMPORTED)
set_target_properties(FFTW::LongDoubleThreads
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${FFTW_LONGDOUBLE_THREADS_LIB}"
)
else()
set(FFTW_LONGDOUBLE_THREADS_LIB_FOUND FALSE)
endif()
if (FFTW_DOUBLE_OPENMP_LIB)
set(FFTW_DOUBLE_OPENMP_LIB_FOUND TRUE)
set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_DOUBLE_OPENMP_LIB})
add_library(FFTW::DoubleOpenMP INTERFACE IMPORTED)
set_target_properties(FFTW::DoubleOpenMP
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${FFTW_DOUBLE_OPENMP_LIB}"
)
else()
set(FFTW_DOUBLE_OPENMP_LIB_FOUND FALSE)
endif()
if (FFTW_FLOAT_OPENMP_LIB)
set(FFTW_FLOAT_OPENMP_LIB_FOUND TRUE)
set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_FLOAT_OPENMP_LIB})
add_library(FFTW::FloatOpenMP INTERFACE IMPORTED)
set_target_properties(FFTW::FloatOpenMP
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${FFTW_FLOAT_OPENMP_LIB}"
)
else()
set(FFTW_FLOAT_OPENMP_LIB_FOUND FALSE)
endif()
if (FFTW_LONGDOUBLE_OPENMP_LIB)
set(FFTW_LONGDOUBLE_OPENMP_LIB_FOUND TRUE)
set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_LONGDOUBLE_OPENMP_LIB})
add_library(FFTW::LongDoubleOpenMP INTERFACE IMPORTED)
set_target_properties(FFTW::LongDoubleOpenMP
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${FFTW_LONGDOUBLE_OPENMP_LIB}"
)
else()
set(FFTW_LONGDOUBLE_OPENMP_LIB_FOUND FALSE)
endif()
if (FFTW_DOUBLE_MPI_LIB)
set(FFTW_DOUBLE_MPI_LIB_FOUND TRUE)
set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_DOUBLE_MPI_LIB})
add_library(FFTW::DoubleMPI INTERFACE IMPORTED)
set_target_properties(FFTW::DoubleMPI
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${FFTW_DOUBLE_MPI_LIB}"
)
else()
set(FFTW_DOUBLE_MPI_LIB_FOUND FALSE)
endif()
if (FFTW_FLOAT_MPI_LIB)
set(FFTW_FLOAT_MPI_LIB_FOUND TRUE)
set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_FLOAT_MPI_LIB})
add_library(FFTW::FloatMPI INTERFACE IMPORTED)
set_target_properties(FFTW::FloatMPI
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${FFTW_FLOAT_MPI_LIB}"
)
else()
set(FFTW_FLOAT_MPI_LIB_FOUND FALSE)
endif()
if (FFTW_LONGDOUBLE_MPI_LIB)
set(FFTW_LONGDOUBLE_MPI_LIB_FOUND TRUE)
set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_LONGDOUBLE_MPI_LIB})
add_library(FFTW::LongDoubleMPI INTERFACE IMPORTED)
set_target_properties(FFTW::LongDoubleMPI
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${FFTW_LONGDOUBLE_MPI_LIB}"
)
else()
set(FFTW_LONGDOUBLE_MPI_LIB_FOUND FALSE)
endif()
#--------------------------------------- end components
set( CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_SAV} )
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(FFTW
REQUIRED_VARS FFTW_INCLUDE_DIRS
HANDLE_COMPONENTS
)
mark_as_advanced(
FFTW_INCLUDE_DIRS
FFTW_LIBRARIES
FFTW_FLOAT_LIB
FFTW_DOUBLE_LIB
FFTW_LONGDOUBLE_LIB
FFTW_FLOAT_THREADS_LIB
FFTW_DOUBLE_THREADS_LIB
FFTW_LONGDOUBLE_THREADS_LIB
FFTW_FLOAT_OPENMP_LIB
FFTW_DOUBLE_OPENMP_LIB
FFTW_LONGDOUBLE_OPENMP_LIB
FFTW_FLOAT_MPI_LIB
FFTW_DOUBLE_MPI_LIB
FFTW_LONGDOUBLE_MPI_LIB
)