Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 1 | # - Find the FFTW library |
| 2 | # |
| 3 | # Usage: |
| 4 | # find_package(FFTW [REQUIRED] [QUIET] ) |
| 5 | # |
| 6 | # It sets the following variables: |
| 7 | # FFTW_FOUND ... true if fftw is found on the system |
| 8 | # FFTW_LIBRARIES ... full path to fftw library |
| 9 | # FFTW_INCLUDES ... fftw include directory |
| 10 | # |
| 11 | # The following variables will be checked by the function |
| 12 | # FFTW_USE_STATIC_LIBS ... if true, only static libraries are found |
| 13 | # FFTW_ROOT ... if set, the libraries are exclusively searched |
| 14 | # under this path |
| 15 | # FFTW_LIBRARY ... fftw library to use |
| 16 | # FFTW_INCLUDE_DIR ... fftw include directory |
| 17 | # |
| 18 | |
| 19 | #If environment variable FFTWDIR is specified, it has same effect as FFTW_ROOT |
| 20 | if( NOT FFTW_ROOT AND ENV{FFTWDIR} ) |
| 21 | set( FFTW_ROOT $ENV{FFTWDIR} ) |
| 22 | endif() |
| 23 | |
| 24 | # Check if we can use PkgConfig |
| 25 | find_package(PkgConfig) |
| 26 | |
| 27 | #Determine from PKG |
| 28 | if( PKG_CONFIG_FOUND AND NOT FFTW_ROOT ) |
| 29 | pkg_check_modules( PKG_FFTW QUIET "fftw3" ) |
| 30 | endif() |
| 31 | |
| 32 | #Check whether to search static or dynamic libs |
| 33 | set( CMAKE_FIND_LIBRARY_SUFFIXES_SAV ${CMAKE_FIND_LIBRARY_SUFFIXES} ) |
| 34 | |
| 35 | if( ${FFTW_USE_STATIC_LIBS} ) |
| 36 | set( CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX} ) |
| 37 | else() |
| 38 | set( CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_SHARED_LIBRARY_SUFFIX} ) |
| 39 | endif() |
| 40 | |
| 41 | if( FFTW_ROOT ) |
| 42 | |
| 43 | #find libs |
| 44 | find_library( |
| 45 | FFTW_LIB |
| 46 | NAMES "fftw3" |
| 47 | PATHS ${FFTW_ROOT} |
| 48 | PATH_SUFFIXES "lib" "lib64" |
| 49 | NO_DEFAULT_PATH |
| 50 | ) |
| 51 | |
| 52 | find_library( |
| 53 | FFTWF_LIB |
| 54 | NAMES "fftw3f" |
| 55 | PATHS ${FFTW_ROOT} |
| 56 | PATH_SUFFIXES "lib" "lib64" |
| 57 | NO_DEFAULT_PATH |
| 58 | ) |
| 59 | |
| 60 | find_library( |
| 61 | FFTWL_LIB |
| 62 | NAMES "fftw3l" |
| 63 | PATHS ${FFTW_ROOT} |
| 64 | PATH_SUFFIXES "lib" "lib64" |
| 65 | NO_DEFAULT_PATH |
| 66 | ) |
| 67 | |
| 68 | #find includes |
| 69 | find_path( |
| 70 | FFTW_INCLUDES |
| 71 | NAMES "fftw3.h" |
| 72 | PATHS ${FFTW_ROOT} |
| 73 | PATH_SUFFIXES "include" |
| 74 | NO_DEFAULT_PATH |
| 75 | ) |
| 76 | |
| 77 | else() |
| 78 | |
| 79 | find_library( |
| 80 | FFTW_LIB |
| 81 | NAMES "fftw3" |
| 82 | PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR} |
| 83 | ) |
| 84 | |
| 85 | find_library( |
| 86 | FFTWF_LIB |
| 87 | NAMES "fftw3f" |
| 88 | PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR} |
| 89 | ) |
| 90 | |
| 91 | |
| 92 | find_library( |
| 93 | FFTWL_LIB |
| 94 | NAMES "fftw3l" |
| 95 | PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR} |
| 96 | ) |
| 97 | |
| 98 | find_path( |
| 99 | FFTW_INCLUDES |
| 100 | NAMES "fftw3.h" |
| 101 | PATHS ${PKG_FFTW_INCLUDE_DIRS} ${INCLUDE_INSTALL_DIR} |
| 102 | ) |
| 103 | |
| 104 | endif( FFTW_ROOT ) |
| 105 | |
| 106 | set(FFTW_LIBRARIES ${FFTW_LIB} ${FFTWF_LIB}) |
| 107 | |
| 108 | if(FFTWL_LIB) |
| 109 | set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTWL_LIB}) |
| 110 | endif() |
| 111 | |
| 112 | set( CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_SAV} ) |
| 113 | |
| 114 | include(FindPackageHandleStandardArgs) |
| 115 | find_package_handle_standard_args(FFTW DEFAULT_MSG |
| 116 | FFTW_INCLUDES FFTW_LIBRARIES) |
| 117 | |
| 118 | mark_as_advanced(FFTW_INCLUDES FFTW_LIBRARIES FFTW_LIB FFTWF_LIB FFTWL_LIB) |
| 119 | |