FindFFTW.cmake 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # FindFFTW.cmake - Try to find FFTW3
  2. # Copyright (c) 2018 Lukas W <lukaswhl/at/gmail.com>
  3. # This file is MIT licensed.
  4. # See http://opensource.org/licenses/MIT
  5. # Try pkgconfig for hints
  6. find_package(PkgConfig QUIET)
  7. if(NOT FFTW_FIND_COMPONENTS)
  8. set(FFTW_FIND_COMPONENTS fftw3f fftw3 fftwl)
  9. endif()
  10. if(PKG_CONFIG_FOUND)
  11. pkg_check_modules(FFTW_PKG QUIET fftw>=3.0.0)
  12. pkg_check_modules(FFTW3_PKG QUIET fftw3>=3.0.0)
  13. endif()
  14. find_path(FFTW_INCLUDE_DIR
  15. NAMES fftw3.h
  16. PATHS ${FFTW_PKG_INCLUDE_DIRS} ${FFTW3_PKG_INCLUDE_DIRS}
  17. )
  18. set(check_list)
  19. foreach(comp ${FFTW_FIND_COMPONENTS})
  20. string(TOUPPER ${comp} COMP)
  21. if(PKG_CONFIG_FOUND)
  22. pkg_check_modules(${COMP}_PKG QUIET ${comp}>=3.0.0)
  23. endif()
  24. find_library(${COMP}_LIBRARY
  25. NAMES ${comp}
  26. PATHS ${comp}_PKG_LIBRARY_DIRS
  27. )
  28. list(APPEND check_list ${COMP}_LIBRARY)
  29. set(${COMP}_LIBRARIES ${${COMP}_LIBRARY} CACHE FILEPATH "${COMP} library path")
  30. set(${COMP}_INCLUDE_DIRS ${FFTW_INCLUDE_DIR} CACHE PATH "${COMP} include path")
  31. mark_as_advanced(${COMP}_LIBRARIES ${COMP}_INCLUDE_DIRS)
  32. endforeach()
  33. find_package(PackageHandleStandardArgs)
  34. find_package_handle_standard_args(FFTW DEFAULT_MSG FFTW_INCLUDE_DIR ${check_list})
  35. set(FFTW_INCLUDE_DIRS ${FFTW_INCLUDE_DIR})
  36. mark_as_advanced(FFTW_LIBRARY FFTW_LIBRARIES FFTW_INCLUDE_DIR FFTW_INCLUDE_DIRS ${check_list})