aboutsummaryrefslogtreecommitdiff
path: root/cmake/modules/FindKissFFT.cmake
blob: 08a7020f28c19cb26da55169562556cd971d8d81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#.rst:
# FindKissFFT
# ------------
# Finds the KissFFT as a Fast Fourier Transformation (FFT) library
#
# This will define the following variables:
#
# KISSFFT_FOUND        - System has KissFFT
# KISSFFT_INCLUDE_DIRS - the KissFFT include directory
# KISSFFT_LIBRARIES    - the KissFFT libraries
#

if(ENABLE_INTERNAL_KISSFFT)
  # KissFFT is located in xbmc/contrib/kissfft
  set(KISSFFT_FOUND TRUE)
  set(KISSFFT_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/xbmc/contrib")
  message(STATUS "Found KissFFT: ${KISSFFT_INCLUDE_DIRS}")
else()
  find_package(PkgConfig)
  if(PKG_CONFIG_FOUND)
    pkg_check_modules(PC_KISSFFT kissfft QUIET)
  endif()

  find_path(KISSFFT_INCLUDE_DIR kissfft/kiss_fft.h kissfft/kiss_fftr.h
                            PATHS ${PC_KISSFFT_INCLUDEDIR})
  find_library(KISSFFT_LIBRARY NAMES kissfft-float kissfft-int32 kissfft-int16 kissfft-simd
                            PATHS ${PC_KISSFFT_LIBDIR})

  # Check if all REQUIRED_VARS are satisfied and set KISSFFT_FOUND
  include(FindPackageHandleStandardArgs)
  find_package_handle_standard_args(KissFFT REQUIRED_VARS KISSFFT_INCLUDE_DIR KISSFFT_LIBRARY)

  if(KISSFFT_FOUND)
    set(KISSFFT_INCLUDE_DIRS ${KISSFFT_INCLUDE_DIR})
    set(KISSFFT_LIBRARIES ${KISSFFT_LIBRARY})

    if(NOT TARGET kissfft)
      add_library(kissfft UNKNOWN IMPORTED)
      set_target_properties(kissfft PROPERTIES
                            IMPORTED_LOCATION "${KISSFFT_LIBRARY}"
                            INTERFACE_INCLUDE_DIRECTORIES "${KISSFFT_INCLUDE_DIR}")
    endif()
  endif()

  mark_as_advanced(KISSFFT_INCLUDE_DIR KISSFFT_LIBRARY)
endif()