Debian Codegraph @

cmake/FindFFTW3.cmake

raw
1 # - Try to find FFTW3.
2 # Usage: find_package(FFTW3 [COMPONENTS [single double long-double threads]])
3 #
4 # Variables used by this module:
5 # FFTW3_ROOT_DIR - FFTW3 root directory
6 # Variables defined by this module:
7 # FFTW3_FOUND - system has FFTW3
8 # FFTW3_INCLUDE_DIR - the FFTW3 include directory (cached)
9 # FFTW3_INCLUDE_DIRS - the FFTW3 include directories
10 # (identical to FFTW3_INCLUDE_DIR)
11 # FFTW3[FL]?_LIBRARY - the FFTW3 library - double, single(F),
12 # long-double(L) precision (cached)
13 # FFTW3[FL]?_THREADS_LIBRARY - the threaded FFTW3 library - double, single(F),
14 # long-double(L) precision (cached)
15 # FFTW3_LIBRARIES - list of all FFTW3 libraries found
16
17 # Copyright (C) 2009-2010
18 # ASTRON (Netherlands Institute for Radio Astronomy)
19 # P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
20 #
21 # This file is part of the LOFAR software suite.
22 # The LOFAR software suite is free software: you can redistribute it and/or
23 # modify it under the terms of the GNU General Public License as published
24 # by the Free Software Foundation, either version 3 of the License, or
25 # (at your option) any later version.
26 #
27 # The LOFAR software suite is distributed in the hope that it will be useful,
28 # but WITHOUT ANY WARRANTY; without even the implied warranty of
29 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 # GNU General Public License for more details.
31 #
32 # You should have received a copy of the GNU General Public License along
33 # with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>.
34 #
35 # $Id: FindFFTW3.cmake 15918 2010-06-25 11:12:42Z loose $
36
37 # Use double precision by default.
38 if(FFTW3_FIND_COMPONENTS MATCHES "^$")
39 set(_components double)
40 else()
41 set(_components ${FFTW3_FIND_COMPONENTS})
42 endif()
43
44 # Loop over each component.
45 set(_libraries)
46 foreach(_comp ${_components})
47 if(_comp STREQUAL "single")
48 list(APPEND _libraries fftw3f)
49 elseif(_comp STREQUAL "double")
50 list(APPEND _libraries fftw3)
51 elseif(_comp STREQUAL "long-double")
52 list(APPEND _libraries fftw3l)
53 elseif(_comp STREQUAL "threads")
54 set(_use_threads ON)
55 else()
56 message(FATAL_ERROR "FindFFTW3: unknown component `${_comp}' specified. "
57 "Valid components are `single', `double', `long-double', and `threads'.")
58 endif()
59 endforeach()
60
61 # If using threads, we need to link against threaded libraries as well.
62 if(_use_threads)
63 set(_thread_libs)
64 foreach(_lib ${_libraries})
65 list(APPEND _thread_libs ${_lib}_threads)
66 endforeach()
67 set(_libraries ${_thread_libs} ${_libraries})
68 endif()
69
70 # Keep a list of variable names that we need to pass on to
71 # find_package_handle_standard_args().
72 set(_check_list)
73
74 # Search for all requested libraries.
75 if (WIN32)
76
77 foreach(_lib ${_libraries})
78 string(TOUPPER ${_lib} _LIB)
79
80 find_library(${_LIB}_LIBRARY lib${_lib}-3 ${_lib}
81 HINTS $ENV{FFTW3_ROOT_DIR} PATH_SUFFIXES lib)
82 mark_as_advanced(${_LIB}_LIBRARY)
83 list(APPEND FFTW3_LIBRARIES ${${_LIB}_LIBRARY})
84 list(APPEND _check_list ${_LIB}_LIBRARY)
85 endforeach()
86
87 message(STATUS "FFTW3 WINDOWS libraries: " ${FFTW3_LIBRARIES})
88
89 else ()
90 foreach(_lib ${_libraries})
91
92 string(TOUPPER ${_lib} _LIB)
93
94 find_library(${_LIB}_LIBRARY ${_lib}
95 HINTS $ENV{FFTW3_ROOT_DIR} PATH_SUFFIXES lib)
96 mark_as_advanced(${_LIB}_LIBRARY)
97 list(APPEND FFTW3_LIBRARIES ${${_LIB}_LIBRARY})
98 list(APPEND _check_list ${_LIB}_LIBRARY)
99 endforeach()
100
101 message(STATUS "FFTW3 UNIX libraries: " ${FFTW3_LIBRARIES})
102 endif ()
103
104 # Search for the header file.
105 find_path(FFTW3_INCLUDE_DIR fftw3.h
106 HINTS $ENV{FFTW3_ROOT_DIR} PATH_SUFFIXES include)
107 mark_as_advanced(FFTW3_INCLUDE_DIR)
108 list(APPEND _check_list FFTW3_INCLUDE_DIR)
109
110 # Handle the QUIETLY and REQUIRED arguments and set FFTW3_FOUND to TRUE if
111 # all listed variables are TRUE
112 include(FindPackageHandleStandardArgs)
113 find_package_handle_standard_args(FFTW3 DEFAULT_MSG ${_check_list})