Debian Codegraph @

cmake/FindFFTW3.cmake

raw
1 # Adapted from: https://github.com/wjakob/layerlab/blob/master/cmake/FindFFTW.cmake
2
3 # Copyright (c) 2015, Wenzel Jakob
4 # All rights reserved.
5 #
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions are met:
8 #
9 # * Redistributions of source code must retain the above copyright notice, this
10 # list of conditions and the following disclaimer.
11 #
12 # * Redistributions in binary form must reproduce the above copyright notice,
13 # this list of conditions and the following disclaimer in the documentation
14 # and/or other materials provided with the distribution.
15 #
16 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
27 # - Find FFTW3
28 # Find the native FFTW3 includes and library
29 #
30 # Cache variables:
31 #
32 # FFTW3_INCLUDE_DIR - where to find fftw3.h
33 # FFTW3_LIBRARY - Path to FFTW3 libray.
34 # FFTW3_ROOT - Root of FFTW3 installation.
35 #
36 # User variables:
37 #
38 # FFTW3_INCLUDE_DIRS - where to find fftw3.h
39 # FFTW3_LIBRARIES - List of libraries when using FFTW3.
40 # FFTW3_FOUND - True if FFTW3 found.
41
42
43 if(FFTW3_INCLUDE_DIR)
44 # Already in cache, be silent
45 set(FFTW3_FIND_QUIETLY TRUE)
46 endif(FFTW3_INCLUDE_DIR)
47
48 find_package(PkgConfig QUIET)
49 pkg_check_modules(PC_FFTW3 QUIET fftw3)
50
51 set(FFTW3_VERSION ${PC_FFTW3_VERSION})
52
53 find_path(FFTW3_INCLUDE_DIR fftw3.h
54 HINTS
55 ${PC_FFTW3_INCLUDEDIR}
56 ${PC_FFTW3_INCLUDE_DIRS}
57 ${FFTW3_ROOT})
58
59 find_library(FFTW3_LIBRARY NAMES fftw3
60 HINTS
61 ${PC_FFTW3_LIBDIR}
62 ${PC_FFTW3_LIBRARY_DIRS}
63 ${FFTW3_ROOT})
64
65 # handle the QUIETLY and REQUIRED arguments and set FFTW3_FOUND to TRUE if
66 # all listed variables are TRUE
67 include(FindPackageHandleStandardArgs)
68 find_package_handle_standard_args(FFTW3
69 REQUIRED_VARS
70 FFTW3_LIBRARY
71 FFTW3_INCLUDE_DIR
72 VERSION_VAR
73 FFTW3_VERSION)
74
75 if(FFTW3_FOUND)
76 set(FFTW3_LIBRARIES ${FFTW3_LIBRARY})
77 set(FFTW3_INCLUDE_DIRS ${FFTW3_INCLUDE_DIR})
78
79 if(NOT TARGET FFTW3::fftw3)
80 add_library(FFTW3::fftw3 UNKNOWN IMPORTED)
81 set_target_properties(FFTW3::fftw3 PROPERTIES
82 INTERFACE_INCLUDE_DIRECTORIES "${FFTW3_INCLUDE_DIR}"
83 IMPORTED_LOCATION "${FFTW3_LIBRARY}"
84 )
85 endif()
86 endif()
87
88 mark_as_advanced(FFTW3_LIBRARY FFTW3_INCLUDE_DIR)