aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasyl Gello <vasek.gello@gmail.com>2021-10-18 22:58:31 +0000
committerVasyl Gello <vasek.gello@gmail.com>2021-10-20 08:28:29 +0000
commita9f8d3f4b1d5141410916b904a7d1f5230306bb3 (patch)
treea5a5676bd5154df62ddb238cc33b87e9f2f58dfc
parent53d7223d27c188e5dfecf235edeb7f1383edd1dc (diff)
Add option to use internal or external kissfft
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 <vasek.gello@gmail.com>
-rw-r--r--CMakeLists.txt4
-rw-r--r--cmake/modules/FindKissFFT.cmake46
-rw-r--r--xbmc/contrib/kissfft/CMakeLists.txt14
-rw-r--r--xbmc/utils/rfft.h4
4 files changed, 60 insertions, 8 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2f6f1c3ae0..1e46f87255 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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)
@@ -134,6 +137,7 @@ set(required_deps ASS
fstrcmp
HarfBuzz
Iconv
+ KissFFT
LibDvd
Lzo2
OpenSSL>=1.1.0
diff --git a/cmake/modules/FindKissFFT.cmake b/cmake/modules/FindKissFFT.cmake
new file mode 100644
index 0000000000..08a7020f28
--- /dev/null
+++ b/cmake/modules/FindKissFFT.cmake
@@ -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()
diff --git a/xbmc/contrib/kissfft/CMakeLists.txt b/xbmc/contrib/kissfft/CMakeLists.txt
index 1a67376b04..e11a6f8026 100644
--- a/xbmc/contrib/kissfft/CMakeLists.txt
+++ b/xbmc/contrib/kissfft/CMakeLists.txt
@@ -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()
diff --git a/xbmc/utils/rfft.h b/xbmc/utils/rfft.h
index 0ec151d808..ce54d63a24 100644
--- a/xbmc/utils/rfft.h
+++ b/xbmc/utils/rfft.h
@@ -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
{