Skip to content

Commit

Permalink
Add option to use internal or external kissfft
Browse files Browse the repository at this point in the history
By default, ENABLE_INTERNAL_KISSFFT is ON for all architectures.
It is immutable on non-Unix systems because 'FindKissFFT.cmake'
relies on 'pkg-config' tool not available in Windows and Android.

If Kodi built with internal kissfft, the corresponding CMake search
module sets kissfft's include directory to the copied location
created by 'core_add_subdirs_from_filelist' macro expanded from
'cmake/treedata/common/externals.txt'.

If Kodi built with system kissfft, the module detects the presence
of header files and solib by 'pkg-config' and disables building the
'xbmc/contrib/kissfft' directory.

Signed-off-by: Vasyl Gello <[email protected]>
  • Loading branch information
basilgello committed Oct 20, 2021
1 parent 53d7223 commit a9f8d3f
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ if(UNIX)
option(ENABLE_INTERNAL_UDFREAD "Enable internal udfread?" OFF)
option(ENABLE_INTERNAL_SPDLOG "Enable internal spdlog?" OFF)
endif()
# prefer kissfft from xbmc/contrib but let use system one on unices
include(CMakeDependentOption)
cmake_dependent_option(ENABLE_INTERNAL_KISSFFT "Enable internal kissfft?" ON "UNIX" ON)
# System options
if(NOT WIN32)
option(WITH_ARCH "build with given arch" OFF)
Expand Down Expand Up @@ -134,6 +137,7 @@ set(required_deps ASS
fstrcmp
HarfBuzz
Iconv
KissFFT
LibDvd
Lzo2
OpenSSL>=1.1.0
Expand Down
46 changes: 46 additions & 0 deletions cmake/modules/FindKissFFT.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,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()
14 changes: 8 additions & 6 deletions xbmc/contrib/kissfft/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
set(SOURCES kiss_fft.c
kiss_fftr.c)
if(ENABLE_INTERNAL_KISSFFT)
set(SOURCES kiss_fft.c
kiss_fftr.c)

set(HEADERS _kiss_fft_guts.h
kiss_fft.h
kiss_fftr.h)
set(HEADERS _kiss_fft_guts.h
kiss_fft.h
kiss_fftr.h)

core_add_library(kissfft)
core_add_library(kissfft)
endif()
4 changes: 2 additions & 2 deletions xbmc/utils/rfft.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

#pragma once

#include "contrib/kissfft/kiss_fftr.h"

#include <vector>

#include <kissfft/kiss_fftr.h>

//! \brief Class performing a RFFT of interleaved stereo data.
class RFFT
{
Expand Down

0 comments on commit a9f8d3f

Please sign in to comment.