summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Klotz <uklotz@mixxx.org>2020-06-13 10:46:44 +0200
committerUwe Klotz <uklotz@mixxx.org>2020-06-13 11:01:16 +0200
commitd3ea9bd1314596dcdc7e510b35c4a9636452c302 (patch)
tree59efeadd9ebf4c402f1fa67a2ba105e6267c5b0f
parentcb10cc03ed088874019073debc211e17c6416890 (diff)
CMake: Link libSoundTouch dynamically if v2.1.1 is available
-rw-r--r--CMakeLists.txt44
-rw-r--r--build/depends.py6
-rw-r--r--cmake/modules/FindSoundTouch.cmake86
-rw-r--r--src/analyzer/plugins/analyzersoundtouchbeats.cpp2
-rw-r--r--src/engine/bufferscalers/enginebufferscalest.cpp4
-rw-r--r--src/util/version.cpp7
6 files changed, 120 insertions, 29 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 885e93cd7d..b96559f921 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1795,24 +1795,32 @@ if(WIN32)
endif()
# SoundTouch
-add_library(SoundTouch STATIC EXCLUDE_FROM_ALL
- lib/soundtouch/AAFilter.cpp
- lib/soundtouch/BPMDetect.cpp
- lib/soundtouch/FIFOSampleBuffer.cpp
- lib/soundtouch/FIRFilter.cpp
- lib/soundtouch/InterpolateCubic.cpp
- lib/soundtouch/InterpolateLinear.cpp
- lib/soundtouch/InterpolateShannon.cpp
- lib/soundtouch/PeakFinder.cpp
- lib/soundtouch/RateTransposer.cpp
- lib/soundtouch/SoundTouch.cpp
- lib/soundtouch/TDStretch.cpp
- lib/soundtouch/cpu_detect_x86.cpp
- lib/soundtouch/mmx_optimized.cpp
- lib/soundtouch/sse_optimized.cpp
-)
-target_include_directories(SoundTouch SYSTEM PUBLIC lib/soundtouch)
-target_link_libraries(mixxx-lib PUBLIC SoundTouch)
+find_package(SoundTouch)
+cmake_dependent_option(SoundTouch_STATIC "Link libSoundTouch statically" OFF "SoundTouch_FOUND" ON)
+if(SoundTouch_STATIC)
+ message(STATUS "Preparing internal libSoundTouch")
+ add_library(SoundTouch STATIC EXCLUDE_FROM_ALL
+ lib/soundtouch/AAFilter.cpp
+ lib/soundtouch/BPMDetect.cpp
+ lib/soundtouch/FIFOSampleBuffer.cpp
+ lib/soundtouch/FIRFilter.cpp
+ lib/soundtouch/InterpolateCubic.cpp
+ lib/soundtouch/InterpolateLinear.cpp
+ lib/soundtouch/InterpolateShannon.cpp
+ lib/soundtouch/PeakFinder.cpp
+ lib/soundtouch/RateTransposer.cpp
+ lib/soundtouch/SoundTouch.cpp
+ lib/soundtouch/TDStretch.cpp
+ lib/soundtouch/cpu_detect_x86.cpp
+ lib/soundtouch/mmx_optimized.cpp
+ lib/soundtouch/sse_optimized.cpp
+ )
+ target_include_directories(SoundTouch SYSTEM PUBLIC lib)
+ target_link_libraries(mixxx-lib PUBLIC SoundTouch)
+else()
+ message(STATUS "Linking libSoundTouch dynamically")
+ target_link_libraries(mixxx-lib PUBLIC SoundTouch::SoundTouch)
+endif()
# TagLib
find_package(Taglib REQUIRED)
diff --git a/build/depends.py b/build/depends.py
index 68a648d973..cbc8a7a88b 100644
--- a/build/depends.py
+++ b/build/depends.py
@@ -557,7 +557,7 @@ class SoundTouch(Dependence):
if build.platform_is_linux or build.platform_is_bsd:
# Try using system lib
- if conf.CheckForPKG('soundtouch', '2.0.0'):
+ if conf.CheckForPKG('soundtouch', '2.1.1'):
# System Lib found
if not conf.CheckLib(['SoundTouch']):
raise Exception(
@@ -566,7 +566,9 @@ class SoundTouch(Dependence):
self.INTERNAL_LINK = False
if self.INTERNAL_LINK:
- env.Append(CPPPATH=['#' + self.SOUNDTOUCH_INTERNAL_PATH])
+ # The system includes all start with <soundtouch/...>, i.e.
+ # we must omit the "soundtouch" path component here!
+ env.Append(CPPPATH=['#/lib'])
# Prevents circular import.
from .features import Optimize
diff --git a/cmake/modules/FindSoundTouch.cmake b/cmake/modules/FindSoundTouch.cmake
new file mode 100644
index 0000000000..a9d92d5f43
--- /dev/null
+++ b/cmake/modules/FindSoundTouch.cmake
@@ -0,0 +1,86 @@
+# This file is part of Mixxx, Digital DJ'ing software.
+# Copyright (C) 2001-2020 Mixxx Development Team
+# Distributed under the GNU General Public Licence (GPL) version 2 or any later
+# later version. See the LICENSE file for details.
+
+#[=======================================================================[.rst:
+FindSoundTouch
+--------------
+
+Finds the SoundTouch library.
+
+Imported Targets
+^^^^^^^^^^^^^^^^
+
+This module provides the following imported targets, if found:
+
+``SoundTouch::SoundTouch``
+ The SoundTouch library
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+This will define the following variables:
+
+``SoundTouch_FOUND``
+ True if the system has the SoundTouch library.
+``SoundTouch_INCLUDE_DIRS``
+ Include directories needed to use SoundTouch.
+``SoundTouch_LIBRARIES``
+ Libraries needed to link to SoundTouch.
+``SoundTouch_DEFINITIONS``
+ Compile definitions needed to use SoundTouch.
+
+Cache Variables
+^^^^^^^^^^^^^^^
+
+The following cache variables may also be set:
+
+``SoundTouch_INCLUDE_DIR``
+ The directory containing ``soundtouch/SoundTouch.h``.
+``SoundTouch_LIBRARY``
+ The path to the SoundTouch library.
+
+#]=======================================================================]
+
+find_package(PkgConfig QUIET)
+if(PkgConfig_FOUND)
+ pkg_check_modules(PC_SoundTouch QUIET SoundTouch>=2.1.1)
+endif()
+
+find_path(SoundTouch_INCLUDE_DIR
+ NAMES soundtouch/SoundTouch.h
+ PATHS ${PC_SoundTouch_INCLUDE_DIRS}
+ DOC "SoundTouch include directory")
+mark_as_advanced(SoundTouch_INCLUDE_DIR)
+
+find_library(SoundTouch_LIBRARY
+ NAMES SoundTouch
+ PATHS ${PC_SoundTouch_LIBRARY_DIRS}
+ DOC "SoundTouch library"
+)
+mark_as_advanced(SoundTouch_LIBRARY)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(
+ SoundTouch
+ DEFAULT_MSG
+ SoundTouch_LIBRARY
+ SoundTouch_INCLUDE_DIR
+)
+
+if(SoundTouch_FOUND)
+ set(SoundTouch_LIBRARIES "${SoundTouch_LIBRARY}")
+ set(SoundTouch_INCLUDE_DIRS "${SoundTouch_INCLUDE_DIR}")
+ set(SoundTouch_DEFINITIONS ${PC_SoundTouch_CFLAGS_OTHER})
+
+ if(NOT TARGET SoundTouch::SoundTouch)
+ add_library(SoundTouch::SoundTouch UNKNOWN IMPORTED)
+ set_target_properties(SoundTouch::SoundTouch
+ PROPERTIES
+ IMPORTED_LOCATION "${SoundTouch_LIBRARY}"
+ INTERFACE_COMPILE_OPTIONS "${PC_SoundTouch_CFLAGS_OTHER}"
+ INTERFACE_INCLUDE_DIRECTORIES "${SoundTouch_INCLUDE_DIR}"
+ )
+ endif()
+endif()
diff --git a/src/analyzer/plugins/analyzersoundtouchbeats.cpp b/src/analyzer/plugins/analyzersoundtouchbeats.cpp
index ec227060b0..8d122a3b29 100644
--- a/src/analyzer/plugins/analyzersoundtouchbeats.cpp
+++ b/src/analyzer/plugins/analyzersoundtouchbeats.cpp
@@ -1,6 +1,6 @@
#include "analyzer/plugins/analyzersoundtouchbeats.h"
-#include <BPMDetect.h>
+#include <soundtouch/BPMDetect.h>
#include "analyzer/constants.h"
#include "util/sample.h"
diff --git a/src/engine/bufferscalers/enginebufferscalest.cpp b/src/engine/bufferscalers/enginebufferscalest.cpp
index f2090230d7..88ed71f338 100644
--- a/src/engine/bufferscalers/enginebufferscalest.cpp
+++ b/src/engine/bufferscalers/enginebufferscalest.cpp
@@ -1,9 +1,7 @@
#include "engine/bufferscalers/enginebufferscalest.h"
// Fixes redefinition warnings from SoundTouch.
-#undef TRUE
-#undef FALSE
-#include <SoundTouch.h>
+#include <soundtouch/SoundTouch.h>
#include "control/controlobject.h"
#include "engine/engineobject.h"
diff --git a/src/util/version.cpp b/src/util/version.cpp
index c8223ba33c..f33c199a39 100644
--- a/src/util/version.cpp
+++ b/src/util/version.cpp
@@ -1,16 +1,13 @@
#include "util/version.h"
+#include <soundtouch/SoundTouch.h>
+
#include <QCoreApplication>
#include <QStandardPaths>
#include <QStringList>
#include <QtDebug>
#include <QtGlobal>
-// Fixes redefinition warnings from SoundTouch.
-#undef TRUE
-#undef FALSE
-#include <SoundTouch.h>
-
// shout.h checks for WIN32 to see if we are on Windows.
#ifdef WIN64
#define WIN32