FindFFTW.cmake 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. #If environment variable FFTWDIR is specified, it has same effect as FFTW_ROOT
  19. if( NOT FFTW_ROOT AND ENV{FFTWDIR} )
  20. set( FFTW_ROOT $ENV{FFTWDIR} )
  21. endif()
  22. # Check if we can use PkgConfig
  23. include(CMakeFindDependencyMacro)
  24. find_dependency(PkgConfig)
  25. #Determine from PKG
  26. if( PKG_CONFIG_FOUND AND NOT FFTW_ROOT )
  27. pkg_check_modules( PKG_FFTW QUIET "fftw3" )
  28. endif()
  29. #Check whether to search static or dynamic libs
  30. set( CMAKE_FIND_LIBRARY_SUFFIXES_SAV ${CMAKE_FIND_LIBRARY_SUFFIXES} )
  31. if( ${FFTW_USE_STATIC_LIBS} )
  32. set( CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX} )
  33. else()
  34. set( CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_SHARED_LIBRARY_SUFFIX} )
  35. endif()
  36. if( FFTW_ROOT )
  37. #find libs
  38. find_library(
  39. FFTW_LIB
  40. NAMES "fftw3"
  41. PATHS ${FFTW_ROOT}
  42. PATH_SUFFIXES "lib" "lib64"
  43. NO_DEFAULT_PATH
  44. )
  45. find_library(
  46. FFTWF_LIB
  47. NAMES "fftw3f"
  48. PATHS ${FFTW_ROOT}
  49. PATH_SUFFIXES "lib" "lib64"
  50. NO_DEFAULT_PATH
  51. )
  52. find_library(
  53. FFTWL_LIB
  54. NAMES "fftw3l"
  55. PATHS ${FFTW_ROOT}
  56. PATH_SUFFIXES "lib" "lib64"
  57. NO_DEFAULT_PATH
  58. )
  59. #find includes
  60. find_path(
  61. FFTW_INCLUDES
  62. NAMES "fftw3.h"
  63. PATHS ${FFTW_ROOT}
  64. PATH_SUFFIXES "include"
  65. NO_DEFAULT_PATH
  66. )
  67. else()
  68. find_library(
  69. FFTW_LIB
  70. NAMES "fftw3"
  71. PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR}
  72. )
  73. find_library(
  74. FFTWF_LIB
  75. NAMES "fftw3f"
  76. PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR}
  77. )
  78. find_library(
  79. FFTWL_LIB
  80. NAMES "fftw3l"
  81. PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR}
  82. )
  83. find_path(
  84. FFTW_INCLUDES
  85. NAMES "fftw3.h"
  86. PATHS ${PKG_FFTW_INCLUDE_DIRS} ${INCLUDE_INSTALL_DIR}
  87. )
  88. endif()
  89. set(FFTW_LIBRARIES ${FFTW_LIB} ${FFTWF_LIB})
  90. if(FFTWL_LIB)
  91. set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTWL_LIB})
  92. endif()
  93. set( CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_SAV} )
  94. include(FindPackageHandleStandardArgs)
  95. find_package_handle_standard_args(FFTW DEFAULT_MSG
  96. FFTW_INCLUDES FFTW_LIBRARIES)
  97. mark_as_advanced(FFTW_INCLUDES FFTW_LIBRARIES FFTW_LIB FFTWF_LIB FFTWL_LIB)