FindFFTW.cmake (2783B)
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 include(CMakeFindDependencyMacro) 26 find_dependency(PkgConfig) 27 28 #Determine from PKG 29 if( PKG_CONFIG_FOUND AND NOT FFTW_ROOT ) 30 pkg_check_modules( PKG_FFTW QUIET "fftw3" ) 31 endif() 32 33 #Check whether to search static or dynamic libs 34 set( CMAKE_FIND_LIBRARY_SUFFIXES_SAV ${CMAKE_FIND_LIBRARY_SUFFIXES} ) 35 36 if( ${FFTW_USE_STATIC_LIBS} ) 37 set( CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX} ) 38 else() 39 set( CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_SHARED_LIBRARY_SUFFIX} ) 40 endif() 41 42 if( FFTW_ROOT ) 43 44 #find libs 45 find_library( 46 FFTW_LIB 47 NAMES "fftw3" 48 PATHS ${FFTW_ROOT} 49 PATH_SUFFIXES "lib" "lib64" 50 NO_DEFAULT_PATH 51 ) 52 53 find_library( 54 FFTWF_LIB 55 NAMES "fftw3f" 56 PATHS ${FFTW_ROOT} 57 PATH_SUFFIXES "lib" "lib64" 58 NO_DEFAULT_PATH 59 ) 60 61 find_library( 62 FFTWL_LIB 63 NAMES "fftw3l" 64 PATHS ${FFTW_ROOT} 65 PATH_SUFFIXES "lib" "lib64" 66 NO_DEFAULT_PATH 67 ) 68 69 #find includes 70 find_path( 71 FFTW_INCLUDES 72 NAMES "fftw3.h" 73 PATHS ${FFTW_ROOT} 74 PATH_SUFFIXES "include" 75 NO_DEFAULT_PATH 76 ) 77 78 else() 79 80 find_library( 81 FFTW_LIB 82 NAMES "fftw3" 83 PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR} 84 ) 85 86 find_library( 87 FFTWF_LIB 88 NAMES "fftw3f" 89 PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR} 90 ) 91 92 93 find_library( 94 FFTWL_LIB 95 NAMES "fftw3l" 96 PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR} 97 ) 98 99 find_path( 100 FFTW_INCLUDES 101 NAMES "fftw3.h" 102 PATHS ${PKG_FFTW_INCLUDE_DIRS} ${INCLUDE_INSTALL_DIR} 103 ) 104 105 endif() 106 107 set(FFTW_LIBRARIES ${FFTW_LIB} ${FFTWF_LIB}) 108 109 if(FFTWL_LIB) 110 set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTWL_LIB}) 111 endif() 112 113 set( CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_SAV} ) 114 115 include(FindPackageHandleStandardArgs) 116 find_package_handle_standard_args(FFTW DEFAULT_MSG 117 FFTW_INCLUDES FFTW_LIBRARIES) 118 119 mark_as_advanced(FFTW_INCLUDES FFTW_LIBRARIES FFTW_LIB FFTWF_LIB FFTWL_LIB) 120