|
| 1 | +#[=======================================================================[.rst: |
| 2 | +FindFFTW3 |
| 3 | +-------- |
| 4 | +
|
| 5 | +Finds the FFTW3 library. |
| 6 | +
|
| 7 | +Imported Targets |
| 8 | +^^^^^^^^^^^^^^^^ |
| 9 | +
|
| 10 | +This module provides the following imported targets, if found: |
| 11 | +
|
| 12 | +``FFTW3::fftw3`` |
| 13 | + The FFTW3 library |
| 14 | +
|
| 15 | +Result Variables |
| 16 | +^^^^^^^^^^^^^^^^ |
| 17 | +
|
| 18 | +This will define the following variables: |
| 19 | +
|
| 20 | +``FFTW3_FOUND`` |
| 21 | + True if the system has the FFTW3 library. |
| 22 | +``FFTW3_INCLUDE_DIRS`` |
| 23 | + Include directories needed to use FFTW3. |
| 24 | +``FFTW3_LIBRARIES`` |
| 25 | + Libraries needed to link to FFTW3. |
| 26 | +
|
| 27 | +Cache Variables |
| 28 | +^^^^^^^^^^^^^^^ |
| 29 | +
|
| 30 | +The following cache variables may also be set: |
| 31 | +
|
| 32 | +``FFTW3_INCLUDE_DIR`` |
| 33 | + The directory containing ``fftw3.h``. |
| 34 | +``FFTW3_LIBRARY`` |
| 35 | + The path to the FFTW3 library. |
| 36 | +
|
| 37 | +#]=======================================================================] |
| 38 | + |
| 39 | +find_package(PkgConfig QUIET) |
| 40 | +if(PkgConfig_FOUND) |
| 41 | + pkg_check_modules(PC_Fftw3 QUIET fftw3) |
| 42 | +endif() |
| 43 | + |
| 44 | +find_path(FFTW3_INCLUDE_DIR |
| 45 | + NAMES fftw3.h |
| 46 | + HINTS ${PC_Fftw3_INCLUDE_DIRS} |
| 47 | + DOC "FFTW3 include directory") |
| 48 | +mark_as_advanced(FFTW3_INCLUDE_DIR) |
| 49 | + |
| 50 | +find_library(FFTW3_LIBRARY |
| 51 | + NAMES fftw3 fftw-3.3 |
| 52 | + HINTS ${PC_Fftw3_LIBRARY_DIRS} |
| 53 | + DOC "FFTW3 library" |
| 54 | +) |
| 55 | +mark_as_advanced(FFTW3_LIBRARY) |
| 56 | + |
| 57 | +if(DEFINED PC_Fftw3_VERSION AND NOT PC_Fftw3_VERSION STREQUAL "") |
| 58 | + set(FFTW3_VERSION "${PC_Fftw3_VERSION}") |
| 59 | +endif() |
| 60 | + |
| 61 | +include(FindPackageHandleStandardArgs) |
| 62 | +find_package_handle_standard_args( |
| 63 | + FFTW3 |
| 64 | + REQUIRED_VARS FFTW3_LIBRARY FFTW3_INCLUDE_DIR |
| 65 | + VERSION_VAR FFTW3_VERSION |
| 66 | +) |
| 67 | + |
| 68 | +if(FFTW3_FOUND) |
| 69 | + set(FFTW3_LIBRARIES "${FFTW3_LIBRARY}") |
| 70 | + set(FFTW3_INCLUDE_DIRS "${FFTW3_INCLUDE_DIR}") |
| 71 | + set(FFTW3_DEFINITIONS ${PC_Fftw3_CFLAGS_OTHER}) |
| 72 | + |
| 73 | + if(NOT TARGET FFTW3::fftw3) |
| 74 | + add_library(FFTW3::fftw3 UNKNOWN IMPORTED) |
| 75 | + set_target_properties(FFTW3::fftw3 |
| 76 | + PROPERTIES |
| 77 | + IMPORTED_LOCATION "${FFTW3_LIBRARY}" |
| 78 | + INTERFACE_COMPILE_OPTIONS "${PC_Fftw3_CFLAGS_OTHER}" |
| 79 | + INTERFACE_INCLUDE_DIRECTORIES "${FFTW3_INCLUDE_DIR}" |
| 80 | + ) |
| 81 | + endif() |
| 82 | +endif() |
0 commit comments