2021-08-02 17:37:07 +02:00
|
|
|
cmake_minimum_required(VERSION 3.1)
|
2021-09-01 17:46:54 +02:00
|
|
|
project(SoundTouch VERSION 2.3.1 LANGUAGES CXX)
|
2021-08-02 17:37:07 +02:00
|
|
|
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
2021-08-20 20:56:12 +02:00
|
|
|
if(MSVC)
|
2021-09-01 17:46:54 +02:00
|
|
|
set(COMPILE_DEFINITIONS /O2 /fp:fast)
|
2021-08-20 20:56:12 +02:00
|
|
|
set(COMPILE_OPTIONS )
|
|
|
|
else()
|
|
|
|
set(COMPILE_OPTIONS -Ofast)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
#####################
|
|
|
|
# SoundTouch library
|
|
|
|
|
2021-08-02 17:37:07 +02:00
|
|
|
add_library(SoundTouch
|
|
|
|
source/SoundTouch/AAFilter.cpp
|
|
|
|
source/SoundTouch/BPMDetect.cpp
|
|
|
|
source/SoundTouch/cpu_detect_x86.cpp
|
|
|
|
source/SoundTouch/FIFOSampleBuffer.cpp
|
|
|
|
source/SoundTouch/FIRFilter.cpp
|
|
|
|
source/SoundTouch/InterpolateCubic.cpp
|
|
|
|
source/SoundTouch/InterpolateLinear.cpp
|
|
|
|
source/SoundTouch/InterpolateShannon.cpp
|
|
|
|
source/SoundTouch/mmx_optimized.cpp
|
|
|
|
source/SoundTouch/PeakFinder.cpp
|
|
|
|
source/SoundTouch/RateTransposer.cpp
|
|
|
|
source/SoundTouch/SoundTouch.cpp
|
|
|
|
source/SoundTouch/sse_optimized.cpp
|
|
|
|
source/SoundTouch/TDStretch.cpp
|
|
|
|
)
|
|
|
|
target_include_directories(SoundTouch PUBLIC
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
|
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
2021-08-20 20:56:12 +02:00
|
|
|
)
|
2021-08-02 17:37:07 +02:00
|
|
|
|
2021-08-20 20:56:12 +02:00
|
|
|
target_compile_definitions(SoundTouch PRIVATE ${COMPILE_DEFINITIONS})
|
|
|
|
target_compile_options(SoundTouch PRIVATE ${COMPILE_OPTIONS})
|
2021-08-02 17:37:07 +02:00
|
|
|
|
2021-08-30 10:01:38 +02:00
|
|
|
if(BUILD_SHARED_LIBS)
|
|
|
|
set_target_properties(SoundTouch PROPERTIES
|
|
|
|
VERSION ${CMAKE_PROJECT_VERSION}
|
|
|
|
)
|
|
|
|
if(WIN32)
|
|
|
|
set_target_properties(SoundTouch PROPERTIES
|
|
|
|
WINDOWS_EXPORT_ALL_SYMBOLS TRUE
|
|
|
|
)
|
|
|
|
else()
|
|
|
|
set_target_properties(SoundTouch PROPERTIES
|
|
|
|
SOVERSION ${PROJECT_VERSION_MAJOR}
|
|
|
|
)
|
|
|
|
endif()
|
2021-08-02 17:37:07 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
option(INTEGER_SAMPLES "Use integers instead of floats for samples" OFF)
|
|
|
|
if(INTEGER_SAMPLES)
|
|
|
|
target_compile_definitions(SoundTouch PRIVATE SOUNDTOUCH_INTEGER_SAMPLES)
|
|
|
|
else()
|
|
|
|
target_compile_definitions(SoundTouch PRIVATE SOUNDTOUCH_FLOAT_SAMPLES)
|
|
|
|
endif()
|
|
|
|
|
2021-08-21 11:58:27 +02:00
|
|
|
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(armv7.*|armv8.*)$")
|
|
|
|
set(NEON_CPU ON)
|
|
|
|
else()
|
|
|
|
set(NEON_CPU OFF)
|
2021-08-02 17:37:07 +02:00
|
|
|
endif()
|
2021-08-21 11:58:27 +02:00
|
|
|
|
|
|
|
option(NEON "Use ARM Neon SIMD instructions if in ARM CPU" ON)
|
|
|
|
if(${NEON} AND ${NEON_CPU})
|
2021-08-02 17:37:07 +02:00
|
|
|
target_compile_definitions(SoundTouch PRIVATE SOUNDTOUCH_USE_NEON)
|
2021-08-21 12:25:24 +02:00
|
|
|
target_compile_options(SoundTouch PRIVATE -mfpu=neon)
|
2021-08-02 17:37:07 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
install(
|
|
|
|
FILES
|
|
|
|
include/BPMDetect.h
|
|
|
|
include/FIFOSampleBuffer.h
|
|
|
|
include/FIFOSamplePipe.h
|
|
|
|
include/STTypes.h
|
|
|
|
include/SoundTouch.h
|
2021-09-01 17:46:54 +02:00
|
|
|
include/soundtouch_config.h
|
2021-08-02 17:37:07 +02:00
|
|
|
DESTINATION
|
|
|
|
"${CMAKE_INSTALL_INCLUDEDIR}/soundtouch"
|
|
|
|
)
|
|
|
|
|
|
|
|
install(TARGETS SoundTouch
|
|
|
|
EXPORT SoundTouchTargets
|
|
|
|
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
|
|
|
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
|
|
|
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
|
|
|
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
|
|
|
)
|
|
|
|
|
2021-08-20 20:56:12 +02:00
|
|
|
#######################
|
|
|
|
# soundstretch utility
|
|
|
|
|
2021-08-21 15:40:53 +02:00
|
|
|
option(SOUNDSTRETCH "Build soundstretch command line utility." ON)
|
|
|
|
if(SOUNDSTRETCH)
|
|
|
|
add_executable(soundstretch
|
|
|
|
source/SoundStretch/main.cpp
|
|
|
|
source/SoundStretch/RunParameters.cpp
|
|
|
|
source/SoundStretch/WavFile.cpp
|
|
|
|
)
|
|
|
|
target_include_directories(soundstretch PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
|
|
|
|
target_compile_definitions(soundstretch PRIVATE ${COMPILE_DEFINITIONS})
|
|
|
|
target_compile_options(soundstretch PRIVATE ${COMPILE_OPTIONS})
|
|
|
|
target_link_libraries(soundstretch PRIVATE SoundTouch)
|
2021-08-20 20:56:12 +02:00
|
|
|
|
2021-08-21 15:40:53 +02:00
|
|
|
install(TARGETS soundstretch
|
|
|
|
DESTINATION bin
|
|
|
|
)
|
|
|
|
endif()
|
2021-08-20 20:56:12 +02:00
|
|
|
|
|
|
|
########################
|
|
|
|
# SoundTouchDll library
|
|
|
|
|
|
|
|
option(SOUNDTOUCH_DLL "Build SoundTouchDLL C wrapper library" OFF)
|
|
|
|
if(SOUNDTOUCH_DLL)
|
|
|
|
add_library(SoundTouchDLL SHARED
|
|
|
|
source/SoundTouchDLL/SoundTouchDLL.cpp
|
|
|
|
source/SoundTouchDLL/SoundTouchDLL.rc
|
|
|
|
)
|
|
|
|
target_compile_options(SoundTouch PRIVATE -fPIC)
|
|
|
|
target_compile_options(SoundTouchDLL PRIVATE -fPIC ${COMPILE_OPTIONS})
|
|
|
|
set_target_properties(SoundTouchDLL PROPERTIES CXX_VISIBILITY_PRESET hidden)
|
|
|
|
target_include_directories(SoundTouchDLL PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
|
|
|
|
target_link_libraries(SoundTouchDLL PRIVATE SoundTouch)
|
|
|
|
install(FILES source/SoundTouchDLL/SoundTouchDLL.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/soundtouch")
|
|
|
|
install(TARGETS SoundTouchDLL EXPORT SoundTouchTargets)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
########################
|
|
|
|
|
2021-08-02 17:37:07 +02:00
|
|
|
# pkgconfig
|
|
|
|
set(prefix "${CMAKE_INSTALL_PREFIX}")
|
|
|
|
set(execprefix "\${prefix}")
|
|
|
|
set(libdir "\${prefix}/${CMAKE_INSTALL_LIBDIR}")
|
|
|
|
set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
|
|
|
|
set(VERSION "${CMAKE_PROJECT_VERSION}")
|
|
|
|
configure_file(soundtouch.pc.in "${CMAKE_CURRENT_BINARY_DIR}/soundtouch.pc" @ONLY)
|
|
|
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/soundtouch.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
|
|
|
|
|
|
|
# CMake config
|
|
|
|
include(CMakePackageConfigHelpers)
|
|
|
|
set(SOUNDTOUCH_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/SoundTouch")
|
|
|
|
install(
|
|
|
|
EXPORT SoundTouchTargets
|
|
|
|
FILE SoundTouchTargets.cmake
|
|
|
|
NAMESPACE SoundTouch::
|
|
|
|
DESTINATION "${SOUNDTOUCH_INSTALL_CMAKEDIR}"
|
|
|
|
)
|
|
|
|
configure_package_config_file(SoundTouchConfig.cmake.in
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/SoundTouchConfig.cmake"
|
|
|
|
INSTALL_DESTINATION "${SOUNDTOUCH_INSTALL_CMAKEDIR}"
|
|
|
|
)
|
|
|
|
write_basic_package_version_file(
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/SoundTouchConfigVersion.cmake"
|
|
|
|
VERSION "${CMAKE_PROJECT_VERSION}"
|
|
|
|
COMPATIBILITY SameMajorVersion
|
|
|
|
)
|
|
|
|
install(
|
|
|
|
FILES
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/SoundTouchConfig.cmake"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/SoundTouchConfigVersion.cmake"
|
|
|
|
DESTINATION "${SOUNDTOUCH_INSTALL_CMAKEDIR}"
|
|
|
|
)
|