From 698958a34679b0f494462fd5bb0b0c3b5cd7898d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Micha=C3=ABl=20Celerier?= Date: Thu, 5 Sep 2019 16:47:18 +0200 Subject: [PATCH 01/27] Implement CMake build script --- CMakeLists.txt | 143 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..dff5bbcd --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,143 @@ +cmake_minimum_required(VERSION 3.15 FATAL_ERROR) +project(rubberband VERSION 2.1.1) + +option(RUBBERBAND_EXAMPLE "Build the Rubberband example app" OFF) + +### Dependencies ### +find_package(Threads REQUIRED) + +# FFTW3 +find_path(FFTW3_INCLUDEDIR fftw3.h) +find_library(FFTW3_LIBRARY fftw3) + +# libsamplerate +find_path(SAMPLERATE_INCLUDEDIR samplerate.h) +find_library(SAMPLERATE_LIBRARY samplerate) + +### Create our target ### +add_library(rubberband) + +### Handle general flags, include paths, etc ### +target_compile_options(rubberband + PRIVATE + $<$:-mmacosx-version-min=10.7> + $<$>,$>:-ffast-math -march=native -O3 -ftree-vectorize> +) + +target_compile_definitions(rubberband + PRIVATE + $<$:USE_PTHREADS> + $<$:HAVE_VDSP> + MALLOC_IS_ALIGNED + NO_THREAD_CHECKS + NO_TIMING +) + +target_include_directories(rubberband + PUBLIC + $ + $ + PRIVATE + $ +) + +target_link_libraries(rubberband + PRIVATE + Threads::Threads +) + +# Handle FFT library +if(FFTW3_INCLUDEDIR AND FFTW3_LIBRARY) + target_include_directories(rubberband + PRIVATE + ${FFTW3_INCLUDEDIR} + ) + target_compile_definitions(rubberband + PRIVATE + HAVE_FFTW3 + FFTW_DOUBLE_ONLY + ) + target_link_libraries(rubberband + PUBLIC + ${FFTW3_LIBRARY} + ) +else() + target_compile_definitions(rubberband + PRIVATE + USE_KISSFFT + ) + target_sources(rubberband + PRIVATE + src/kissfft/kiss_fft.c + src/kissfft/kiss_fftr.c + ) +endif() + +# Handle resampling library +if(SAMPLERATE_INCLUDEDIR AND SAMPLERATE_LIBRARY) + target_include_directories(rubberband + PRIVATE + ${SAMPLERATE_INCLUDEDIR} + ) + target_compile_definitions(rubberband + PRIVATE + HAVE_LIBSAMPLERATE + ) + target_link_libraries(rubberband + PUBLIC + ${SAMPLERATE_LIBRARY} + ) +else() + target_compile_definitions(rubberband + PRIVATE + USE_SPEEX + ) + target_sources(rubberband + PRIVATE + src/speex/resample.c + ) +endif() + +### Source files ### +target_sources(rubberband + PRIVATE + src/RubberBandStretcher.cpp + src/StretchCalculator.cpp + src/StretcherChannelData.cpp + src/StretcherImpl.cpp + src/StretcherProcess.cpp + src/audiocurves/CompoundAudioCurve.cpp + src/audiocurves/ConstantAudioCurve.cpp + src/audiocurves/HighFrequencyAudioCurve.cpp + src/audiocurves/PercussiveAudioCurve.cpp + src/audiocurves/SilentAudioCurve.cpp + src/audiocurves/SpectralDifferenceAudioCurve.cpp + src/base/Profiler.cpp + src/dsp/AudioCurveCalculator.cpp + src/dsp/FFT.cpp + src/dsp/Resampler.cpp + src/rubberband-c.cpp + src/system/Allocators.cpp + src/system/Thread.cpp + src/system/VectorOpsComplex.cpp + src/system/sysutils.cpp +) + +### Example ### +if(RUBBERBAND_EXAMPLE) + add_executable(rubberband_test main/main.cpp) + target_include_directories(rubberband_test PRIVATE src Threads::Threads) + target_link_libraries(rubberband_test PRIVATE rubberband -lsndfile) +endif() + +### Installation ### + +install( + TARGETS rubberband + EXPORT rubberband-exports + RUNTIME DESTINATION lib + ARCHIVE DESTINATION lib) + +install(EXPORT rubberband-exports + DESTINATION lib/cmake/rubberband) +export(EXPORT rubberband-exports) From 8df1fb04f89b1ef66097e4add70d1b3fad04a44e Mon Sep 17 00:00:00 2001 From: Arthur Date: Mon, 18 Nov 2019 18:42:52 +0100 Subject: [PATCH 02/27] Fix CMakeLists.txt for MSVC (tested with Community 2017) --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index dff5bbcd..f29fe58b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,9 @@ target_compile_definitions(rubberband PRIVATE $<$:USE_PTHREADS> $<$:HAVE_VDSP> + $<$>:__MSVC__ WIN32 _LIB NOMINMAX _USE_MATH_DEFINES USE_KISSFFT USE_SPEEX> + $<$,$>:NDEBUG> + $<$,$>:_DEBUG NO_TIMING NO_THREAD_CHECKS> MALLOC_IS_ALIGNED NO_THREAD_CHECKS NO_TIMING @@ -38,6 +41,7 @@ target_include_directories(rubberband $ $ PRIVATE + $ $ ) From d78ecf7b396dea540cfc35c562e9b104c7897c43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Micha=C3=ABl=20Celerier?= Date: Mon, 25 Nov 2019 18:45:53 +0100 Subject: [PATCH 03/27] Accelerate framework --- CMakeLists.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index f29fe58b..1e7ca204 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,11 @@ find_library(FFTW3_LIBRARY fftw3) find_path(SAMPLERATE_INCLUDEDIR samplerate.h) find_library(SAMPLERATE_LIBRARY samplerate) +# Accelerate framework +if(APPLE) + find_library(ACCELERATE_FRAMEWORK NAMES Accelerate) +endif() + ### Create our target ### add_library(rubberband) @@ -77,6 +82,14 @@ else() ) endif() +# Apple framework +if(APPLE) + target_link_libraries(rubberband + PRIVATE + "${ACCELERATE_FRAMEWORK}" + ) +endif() + # Handle resampling library if(SAMPLERATE_INCLUDEDIR AND SAMPLERATE_LIBRARY) target_include_directories(rubberband From 09e31f7070dc5ed60a880938571e50b7fa702deb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Micha=C3=ABl=20Celerier?= Date: Fri, 29 Nov 2019 19:47:19 +0100 Subject: [PATCH 04/27] Fixes for libsamplerate --- CMakeLists.txt | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e7ca204..b116a7c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,8 +11,10 @@ find_path(FFTW3_INCLUDEDIR fftw3.h) find_library(FFTW3_LIBRARY fftw3) # libsamplerate -find_path(SAMPLERATE_INCLUDEDIR samplerate.h) -find_library(SAMPLERATE_LIBRARY samplerate) +if(NOT TARGET samplerate) + find_path(SAMPLERATE_INCLUDEDIR samplerate.h) + find_library(SAMPLERATE_LIBRARY samplerate) +endif() # Accelerate framework if(APPLE) @@ -91,7 +93,17 @@ if(APPLE) endif() # Handle resampling library -if(SAMPLERATE_INCLUDEDIR AND SAMPLERATE_LIBRARY) +if(TARGET samplerate) + target_compile_definitions(rubberband + PRIVATE + HAVE_LIBSAMPLERATE + ) + + target_link_libraries(rubberband + PRIVATE + samplerate + ) +elseif(SAMPLERATE_INCLUDEDIR AND SAMPLERATE_LIBRARY) target_include_directories(rubberband PRIVATE ${SAMPLERATE_INCLUDEDIR} From d10e4fd2c914ec029d46bd943dd72f8ff8d1b104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Micha=C3=ABl=20Celerier?= Date: Sat, 21 Dec 2019 12:23:08 +0100 Subject: [PATCH 05/27] Do not build for 10.7 as it uses libstdc++ instead of libc++ not available in newer macOS --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b116a7c5..614589d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,7 @@ add_library(rubberband) ### Handle general flags, include paths, etc ### target_compile_options(rubberband PRIVATE - $<$:-mmacosx-version-min=10.7> + $<$:-mmacosx-version-min=10.11> $<$>,$>:-ffast-math -march=native -O3 -ftree-vectorize> ) From 3c2d2c578bd7e930151727da589d3caa42004f3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Micha=C3=ABl=20Celerier?= Date: Sun, 22 Mar 2020 23:07:55 +0100 Subject: [PATCH 06/27] Lower minimum CMake version --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 614589d5..152c2623 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.15 FATAL_ERROR) +cmake_minimum_required(VERSION 3.9 FATAL_ERROR) project(rubberband VERSION 2.1.1) option(RUBBERBAND_EXAMPLE "Build the Rubberband example app" OFF) @@ -58,7 +58,7 @@ target_link_libraries(rubberband ) # Handle FFT library -if(FFTW3_INCLUDEDIR AND FFTW3_LIBRARY) +if(0) target_include_directories(rubberband PRIVATE ${FFTW3_INCLUDEDIR} From 645e64f21bbe282002f25235f6fc6b5127a0a2d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Micha=C3=ABl=20Celerier?= Date: Tue, 24 Mar 2020 13:45:12 +0100 Subject: [PATCH 07/27] Do not force speex on win32 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 152c2623..9fe2ae08 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,7 @@ target_compile_definitions(rubberband PRIVATE $<$:USE_PTHREADS> $<$:HAVE_VDSP> - $<$>:__MSVC__ WIN32 _LIB NOMINMAX _USE_MATH_DEFINES USE_KISSFFT USE_SPEEX> + $<$>:__MSVC__ WIN32 _LIB NOMINMAX _USE_MATH_DEFINES USE_KISSFFT> $<$,$>:NDEBUG> $<$,$>:_DEBUG NO_TIMING NO_THREAD_CHECKS> MALLOC_IS_ALIGNED From e639056a2f977c92dca9d7ef3edb5898b38ca4f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Micha=C3=ABl=20Celerier?= Date: Wed, 24 Jun 2020 21:27:30 +0200 Subject: [PATCH 08/27] Fix cross-compilation to ARM --- CMakeLists.txt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9fe2ae08..5342fdf1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,16 @@ project(rubberband VERSION 2.1.1) option(RUBBERBAND_EXAMPLE "Build the Rubberband example app" OFF) ### Dependencies ### + +# ARM cross-compilers do not support march=native, only mtune=native +include(CheckCXXCompilerFlag) +check_cxx_compiler_flag("-march=native" MARCH_NATIVE_SUPPORTED) +if(MARCH_NATIVE_SUPPORTED) + set(MARCH_NATIVE_FLAG "-march=native") +else() + set(MARCH_NATIVE_FLAG) +endif() + find_package(Threads REQUIRED) # FFTW3 @@ -28,7 +38,7 @@ add_library(rubberband) target_compile_options(rubberband PRIVATE $<$:-mmacosx-version-min=10.11> - $<$>,$>:-ffast-math -march=native -O3 -ftree-vectorize> + $<$>,$>:-ffast-math ${MARCH_NATIVE_FLAG} -O3 -ftree-vectorize> ) target_compile_definitions(rubberband @@ -58,7 +68,7 @@ target_link_libraries(rubberband ) # Handle FFT library -if(0) +if(FFTW3_INCLUDEDIR AND FFTW3_LIBRARY) target_include_directories(rubberband PRIVATE ${FFTW3_INCLUDEDIR} From 8e09e4a2a9d54e627d5c80da89a0f4d2cdf8f65d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Micha=C3=ABl=20Celerier?= Date: Mon, 7 Sep 2020 22:13:50 +0200 Subject: [PATCH 09/27] Put -march=native flag behind a CMake option --- CMakeLists.txt | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5342fdf1..e606954b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,16 +2,20 @@ cmake_minimum_required(VERSION 3.9 FATAL_ERROR) project(rubberband VERSION 2.1.1) option(RUBBERBAND_EXAMPLE "Build the Rubberband example app" OFF) - +option(RUBBERBAND_OPTIMIZED "Build Rubberband optimized for the build machine's CPU" OFF) ### Dependencies ### # ARM cross-compilers do not support march=native, only mtune=native +set(MARCH_NATIVE_FLAG) + include(CheckCXXCompilerFlag) -check_cxx_compiler_flag("-march=native" MARCH_NATIVE_SUPPORTED) -if(MARCH_NATIVE_SUPPORTED) - set(MARCH_NATIVE_FLAG "-march=native") -else() - set(MARCH_NATIVE_FLAG) + +if(RUBBERBAND_OPTIMIZED) + check_cxx_compiler_flag("-march=native" MARCH_NATIVE_SUPPORTED) + if(MARCH_NATIVE_SUPPORTED) + set(MARCH_NATIVE_FLAG "-march=native") + else() + endif() endif() find_package(Threads REQUIRED) From 478936a96c1913ec2041308aa8e9583a55f124cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Micha=C3=ABl=20Celerier?= Date: Thu, 21 Jan 2021 12:01:04 +0100 Subject: [PATCH 10/27] Update CMakeLists.txt Co-authored-by: Jan Holthuis --- CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e606954b..b1b851e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -175,11 +175,13 @@ endif() ### Installation ### +include(GNUInstallDirs) install( TARGETS rubberband EXPORT rubberband-exports - RUNTIME DESTINATION lib - ARCHIVE DESTINATION lib) + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) install(EXPORT rubberband-exports DESTINATION lib/cmake/rubberband) From cc9540e7511c67c815e1d6d69d05a3d162a94725 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Thu, 21 Jan 2021 12:30:09 +0100 Subject: [PATCH 11/27] CMake: Add support for building windows DLL --- CMakeLists.txt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index b1b851e7..1229acf7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,6 +66,24 @@ target_include_directories(rubberband $ ) +if(WIN32) + target_compile_definitions(rubberband PRIVATE _WINDOWS) + if(CMAKE_SIZEOF_VOID_P EQUAL 4) + target_compile_definitions(rubberband PRIVATE WIN32) + endif() + + if(MSVC AND BUILD_SHARED_LIBS) + target_sources(rubberband PRIVATE + rubberband-dll/dllmain.cpp + rubberband-dll/rubberband-dll.cpp + rubberband-dll/stdafx.cpp + ) + target_include_directories(rubberband PRIVATE rubberband-dll) + target_compile_definitions(rubberband PRIVATE RUBBERBANDDLL_EXPORTS _USRDLL) + endif() + target_include_directories(rubberband PRIVATE $) +endif() + target_link_libraries(rubberband PRIVATE Threads::Threads From 15b2c29ed8f992192a54e3689f52aae9398c9458 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Thu, 21 Jan 2021 12:48:14 +0100 Subject: [PATCH 12/27] CMake: Install header files --- CMakeLists.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1229acf7..20fc53a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -199,7 +199,15 @@ install( EXPORT rubberband-exports RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" +) + +# Header files +install( + DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/rubberband" + TYPE INCLUDE +) install(EXPORT rubberband-exports DESTINATION lib/cmake/rubberband) From ba8b1cd61649d6fe24cd7b8c5908f3185309564b Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Thu, 21 Jan 2021 12:57:15 +0100 Subject: [PATCH 13/27] pkg-config: Use @PREFIX@ instead of %PREFIX% --- Makefile.in | 2 +- Makefile.osx | 2 +- rubberband.pc.in | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile.in b/Makefile.in index 3a70a71d..afdd2e2e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -189,7 +189,7 @@ install: all cp $(LADSPA_TARGET) $(DESTDIR)$(INSTALL_LADSPADIR) cp ladspa/ladspa-rubberband.cat $(DESTDIR)$(INSTALL_LADSPADIR) cp ladspa/ladspa-rubberband.rdf $(DESTDIR)$(INSTALL_LRDFDIR) - sed "s,%PREFIX%,$(PREFIX)," rubberband.pc.in \ + sed "s,@PREFIX@,$(PREFIX)," rubberband.pc.in \ > $(DESTDIR)$(INSTALL_PKGDIR)/rubberband.pc clean: diff --git a/Makefile.osx b/Makefile.osx index 62fea2f0..b45eea74 100644 --- a/Makefile.osx +++ b/Makefile.osx @@ -174,7 +174,7 @@ install: default cp $(LADSPA_TARGET) $(DESTDIR)$(INSTALL_LADSPADIR) cp ladspa/ladspa-rubberband.cat $(DESTDIR)$(INSTALL_LADSPADIR) cp ladspa/ladspa-rubberband.rdf $(DESTDIR)$(INSTALL_LRDFDIR) - sed "s,%PREFIX%,$(PREFIX)," rubberband.pc.in \ + sed "s,@PREFIX@,$(PREFIX)," rubberband.pc.in \ > $(DESTDIR)$(INSTALL_PKGDIR)/rubberband.pc clean: diff --git a/rubberband.pc.in b/rubberband.pc.in index ac96edd2..89da225b 100644 --- a/rubberband.pc.in +++ b/rubberband.pc.in @@ -1,4 +1,4 @@ -prefix=%PREFIX% +prefix=@PREFIX@ exec_prefix=${prefix} libdir=${exec_prefix}/lib includedir=${prefix}/include From ba3b4bc64a90fbddd8563926e7df42cfea59f62e Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Thu, 21 Jan 2021 13:03:00 +0100 Subject: [PATCH 14/27] CMake: Install pkgconfig file on Unix --- CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 20fc53a7..6c92d801 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -209,6 +209,16 @@ install( TYPE INCLUDE ) +# pkg-config file +if(UNIX) + set(PREFIX "${CMAKE_INSTALL_PREFIX}") + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/rubberband.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/rubberband.pc" @ONLY) + install( + FILES "${CMAKE_CURRENT_BINARY_DIR}/rubberband.pc" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig" + ) +endif() + install(EXPORT rubberband-exports DESTINATION lib/cmake/rubberband) export(EXPORT rubberband-exports) From 9231a576aa63e1df4759d7d617bc390ce1a5bf0e Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Thu, 21 Jan 2021 13:12:50 +0100 Subject: [PATCH 15/27] CMake: Add find_package() config --- CMakeLists.txt | 28 ++++++++++++++++++++++++---- rubberband-config.cmake.in | 9 +++++++++ 2 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 rubberband-config.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c92d801..41422ce2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -196,7 +196,7 @@ endif() include(GNUInstallDirs) install( TARGETS rubberband - EXPORT rubberband-exports + EXPORT rubberband-targets RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} @@ -219,6 +219,26 @@ if(UNIX) ) endif() -install(EXPORT rubberband-exports - DESTINATION lib/cmake/rubberband) -export(EXPORT rubberband-exports) +# CMake config +include(CMakePackageConfigHelpers) +set(RUBBERBAND_INSTALL_CMAKEDIR "lib/cmake/rubberband") +install( + EXPORT rubberband-targets + FILE rubberband-targets.cmake + NAMESPACE rubberband:: + DESTINATION "${RUBBERBAND_INSTALL_CMAKEDIR}" +) +configure_package_config_file(rubberband-config.cmake.in + "${CMAKE_CURRENT_BINARY_DIR}/rubberband-config.cmake" + INSTALL_DESTINATION "${RUBBERBAND_INSTALL_CMAKEDIR}" +) +write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/rubberband-config-version.cmake" + VERSION "${CMAKE_PROJECT_VERSION}" + COMPATIBILITY SameMajorVersion +) +install( + FILES + "${CMAKE_CURRENT_BINARY_DIR}/rubberband-config.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/rubberband-config-version.cmake" + DESTINATION "${RUBBERBAND_INSTALL_CMAKEDIR}" +) diff --git a/rubberband-config.cmake.in b/rubberband-config.cmake.in new file mode 100644 index 00000000..edf5a8fa --- /dev/null +++ b/rubberband-config.cmake.in @@ -0,0 +1,9 @@ +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) +find_dependency(FFTW3) +find_dependency(samplerate) + +include("${CMAKE_CURRENT_LIST_DIR}/rubberband-targets.cmake") + +check_required_components(rubberband) From bf1b5a2b2a37ad1c66a27ace7e7f01a952772fc7 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Thu, 21 Jan 2021 14:09:50 +0100 Subject: [PATCH 16/27] CMake: Remove wrong MSVC defines --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 41422ce2..ede13608 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,7 +49,7 @@ target_compile_definitions(rubberband PRIVATE $<$:USE_PTHREADS> $<$:HAVE_VDSP> - $<$>:__MSVC__ WIN32 _LIB NOMINMAX _USE_MATH_DEFINES USE_KISSFFT> + $<$>:__MSVC__ _LIB NOMINMAX _USE_MATH_DEFINES> $<$,$>:NDEBUG> $<$,$>:_DEBUG NO_TIMING NO_THREAD_CHECKS> MALLOC_IS_ALIGNED From 68b94838679b9b7d08f4d5a7945c8f8af274b6ff Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Thu, 21 Jan 2021 16:27:56 +0100 Subject: [PATCH 17/27] CMake: Clean up and rework dependency logic --- CMakeLists.txt | 258 +++++++++++++++---------------------- rubberband-config.cmake.in | 10 +- 2 files changed, 114 insertions(+), 154 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ede13608..ba8a6c62 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,70 +1,109 @@ cmake_minimum_required(VERSION 3.9 FATAL_ERROR) project(rubberband VERSION 2.1.1) -option(RUBBERBAND_EXAMPLE "Build the Rubberband example app" OFF) -option(RUBBERBAND_OPTIMIZED "Build Rubberband optimized for the build machine's CPU" OFF) -### Dependencies ### - -# ARM cross-compilers do not support march=native, only mtune=native -set(MARCH_NATIVE_FLAG) - -include(CheckCXXCompilerFlag) +option(BUILD_EXECUTABLE "Build the Rubberband executable" OFF) +option(OPTIMIZE "Build Rubberband optimized for the build machine's CPU" OFF) +option(USE_FFTW "Use FFTW instead of kissFFT" OFF) +option(USE_LIBSAMPLERATE "Use libsamplerate instead of Speex" ON) + +add_library(rubberband + src/RubberBandStretcher.cpp + src/StretchCalculator.cpp + src/StretcherChannelData.cpp + src/StretcherImpl.cpp + src/StretcherProcess.cpp + src/audiocurves/CompoundAudioCurve.cpp + src/audiocurves/ConstantAudioCurve.cpp + src/audiocurves/HighFrequencyAudioCurve.cpp + src/audiocurves/PercussiveAudioCurve.cpp + src/audiocurves/SilentAudioCurve.cpp + src/audiocurves/SpectralDifferenceAudioCurve.cpp + src/base/Profiler.cpp + src/dsp/AudioCurveCalculator.cpp + src/dsp/FFT.cpp + src/dsp/Resampler.cpp + src/rubberband-c.cpp + src/system/Allocators.cpp + src/system/Thread.cpp + src/system/VectorOpsComplex.cpp + src/system/sysutils.cpp +) -if(RUBBERBAND_OPTIMIZED) - check_cxx_compiler_flag("-march=native" MARCH_NATIVE_SUPPORTED) - if(MARCH_NATIVE_SUPPORTED) - set(MARCH_NATIVE_FLAG "-march=native") - else() - endif() -endif() +# +# Dependencies +# +# Threads find_package(Threads REQUIRED) +target_link_libraries(rubberband PRIVATE Threads::Threads) + +# FFTW / KissFFT +if(USE_FFTW) + message(STATUS "Using FFT library: fftw") + find_path(FFTW3_INCLUDEDIR fftw3.h REQUIRED) + find_library(FFTW3_LIBRARY fftw3 REQUIRED) + target_include_directories(rubberband PRIVATE ${FFTW3_INCLUDEDIR}) + target_link_libraries(rubberband PUBLIC ${FFTW3_LIBRARY}) + target_compile_definitions(rubberband PRIVATE HAVE_FFTW3 FFTW_DOUBLE_ONLY) +else() + message(STATUS "Using resampling library: kissfft") + target_compile_definitions(rubberband PRIVATE USE_KISSFFT) + target_sources(rubberband PRIVATE src/kissfft/kiss_fft.c src/kissfft/kiss_fftr.c) +endif() -# FFTW3 -find_path(FFTW3_INCLUDEDIR fftw3.h) -find_library(FFTW3_LIBRARY fftw3) - -# libsamplerate -if(NOT TARGET samplerate) - find_path(SAMPLERATE_INCLUDEDIR samplerate.h) - find_library(SAMPLERATE_LIBRARY samplerate) +# libsamplerate / Speex +if(USE_LIBSAMPLERATE) + message(STATUS "Using resampling library: libsamplerate") + find_path(SAMPLERATE_INCLUDEDIR samplerate.h REQUIRED) + find_library(SAMPLERATE_LIBRARY samplerate REQUIRED) + target_include_directories(rubberband PRIVATE ${SAMPLERATE_INCLUDEDIR}) + target_link_libraries(rubberband PUBLIC ${SAMPLERATE_LIBRARY}) + target_compile_definitions(rubberband PRIVATE HAVE_LIBSAMPLERATE) +else() + message(STATUS "Using resampling library: speex") + target_compile_definitions(rubberband PRIVATE USE_SPEEX) + target_sources(rubberband PRIVATE src/speex/resample.c) endif() # Accelerate framework if(APPLE) - find_library(ACCELERATE_FRAMEWORK NAMES Accelerate) + find_library(ACCELERATE_FRAMEWORK NAMES Accelerate REQUIRED) + target_link_libraries(rubberband PUBLIC ${ACCELERATE_FRAMEWORK}) endif() -### Create our target ### -add_library(rubberband) +# +# Handle general flags, include paths, etc. +# +include(CheckCXXCompilerFlag) + +if(OPTIMIZE) + check_cxx_compiler_flag("-march=native" MARCH_NATIVE_SUPPORTED) + if(MARCH_NATIVE_SUPPORTED AND NOT MSVC) + target_compile_options(rubberband PRIVATE -march=native) + endif() +endif() -### Handle general flags, include paths, etc ### -target_compile_options(rubberband +target_include_directories(rubberband + PUBLIC + $ + $ PRIVATE - $<$:-mmacosx-version-min=10.11> - $<$>,$>:-ffast-math ${MARCH_NATIVE_FLAG} -O3 -ftree-vectorize> + $ + $ ) target_compile_definitions(rubberband PRIVATE - $<$:USE_PTHREADS> - $<$:HAVE_VDSP> - $<$>:__MSVC__ _LIB NOMINMAX _USE_MATH_DEFINES> - $<$,$>:NDEBUG> - $<$,$>:_DEBUG NO_TIMING NO_THREAD_CHECKS> + $<$:USE_PTHREADS> MALLOC_IS_ALIGNED NO_THREAD_CHECKS NO_TIMING ) -target_include_directories(rubberband - PUBLIC - $ - $ - PRIVATE - $ - $ -) +if(APPLE) + target_compile_options(rubberband PRIVATE -mmacosx-version-min=10.11) + target_compile_definitions(rubberband PRIVATE HAVE_VDSP) +endif() if(WIN32) target_compile_definitions(rubberband PRIVATE _WINDOWS) @@ -72,127 +111,42 @@ if(WIN32) target_compile_definitions(rubberband PRIVATE WIN32) endif() - if(MSVC AND BUILD_SHARED_LIBS) - target_sources(rubberband PRIVATE + if(MSVC) + target_compile_definitions(rubberband PRIVATE + __MSVC__ + _LIB + NOMINMAX + _USE_MATH_DEFINES + $<$:NDEBUG> + $<$:_DEBUG NO_TIMING NO_THREAD_CHECKS> + ) + if(BUILD_SHARED_LIBS) + target_sources(rubberband + PRIVATE rubberband-dll/dllmain.cpp rubberband-dll/rubberband-dll.cpp rubberband-dll/stdafx.cpp ) target_include_directories(rubberband PRIVATE rubberband-dll) target_compile_definitions(rubberband PRIVATE RUBBERBANDDLL_EXPORTS _USRDLL) + endif() endif() target_include_directories(rubberband PRIVATE $) endif() -target_link_libraries(rubberband - PRIVATE - Threads::Threads -) - -# Handle FFT library -if(FFTW3_INCLUDEDIR AND FFTW3_LIBRARY) - target_include_directories(rubberband - PRIVATE - ${FFTW3_INCLUDEDIR} - ) - target_compile_definitions(rubberband - PRIVATE - HAVE_FFTW3 - FFTW_DOUBLE_ONLY - ) - target_link_libraries(rubberband - PUBLIC - ${FFTW3_LIBRARY} - ) -else() - target_compile_definitions(rubberband - PRIVATE - USE_KISSFFT - ) - target_sources(rubberband - PRIVATE - src/kissfft/kiss_fft.c - src/kissfft/kiss_fftr.c - ) -endif() - -# Apple framework -if(APPLE) - target_link_libraries(rubberband - PRIVATE - "${ACCELERATE_FRAMEWORK}" - ) -endif() - -# Handle resampling library -if(TARGET samplerate) - target_compile_definitions(rubberband - PRIVATE - HAVE_LIBSAMPLERATE - ) - - target_link_libraries(rubberband - PRIVATE - samplerate - ) -elseif(SAMPLERATE_INCLUDEDIR AND SAMPLERATE_LIBRARY) - target_include_directories(rubberband - PRIVATE - ${SAMPLERATE_INCLUDEDIR} - ) - target_compile_definitions(rubberband - PRIVATE - HAVE_LIBSAMPLERATE - ) - target_link_libraries(rubberband - PUBLIC - ${SAMPLERATE_LIBRARY} - ) -else() - target_compile_definitions(rubberband - PRIVATE - USE_SPEEX - ) - target_sources(rubberband - PRIVATE - src/speex/resample.c - ) -endif() - -### Source files ### -target_sources(rubberband - PRIVATE - src/RubberBandStretcher.cpp - src/StretchCalculator.cpp - src/StretcherChannelData.cpp - src/StretcherImpl.cpp - src/StretcherProcess.cpp - src/audiocurves/CompoundAudioCurve.cpp - src/audiocurves/ConstantAudioCurve.cpp - src/audiocurves/HighFrequencyAudioCurve.cpp - src/audiocurves/PercussiveAudioCurve.cpp - src/audiocurves/SilentAudioCurve.cpp - src/audiocurves/SpectralDifferenceAudioCurve.cpp - src/base/Profiler.cpp - src/dsp/AudioCurveCalculator.cpp - src/dsp/FFT.cpp - src/dsp/Resampler.cpp - src/rubberband-c.cpp - src/system/Allocators.cpp - src/system/Thread.cpp - src/system/VectorOpsComplex.cpp - src/system/sysutils.cpp -) - -### Example ### -if(RUBBERBAND_EXAMPLE) - add_executable(rubberband_test main/main.cpp) - target_include_directories(rubberband_test PRIVATE src Threads::Threads) - target_link_libraries(rubberband_test PRIVATE rubberband -lsndfile) +# +# Command-Line Program +# +if(BUILD_EXECUTABLE) + find_library(SNDFILE_LIBRARY sndfile REQUIRED) + add_executable(rubberband-program main/main.cpp) + target_include_directories(rubberband-program PRIVATE src Threads::Threads) + target_link_libraries(rubberband-program PRIVATE rubberband ${SNDFILE_LIBRARY}) endif() -### Installation ### - +# +# Installation +# include(GNUInstallDirs) install( TARGETS rubberband diff --git a/rubberband-config.cmake.in b/rubberband-config.cmake.in index edf5a8fa..6bb96c23 100644 --- a/rubberband-config.cmake.in +++ b/rubberband-config.cmake.in @@ -1,8 +1,14 @@ @PACKAGE_INIT@ include(CMakeFindDependencyMacro) -find_dependency(FFTW3) -find_dependency(samplerate) + +if(@USE_FFTW@) + find_dependency(FFTW3) +endif() + +if(@USE_LIBSAMPLERATE@) + find_dependency(samplerate) +endif() include("${CMAKE_CURRENT_LIST_DIR}/rubberband-targets.cmake") From 95f4e1e6ea0e47e69bf7009b3afc1c40531b1e6e Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Thu, 21 Jan 2021 17:27:37 +0100 Subject: [PATCH 18/27] CMake: Fix DLL build on Windows --- CMakeLists.txt | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ba8a6c62..a68b920c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -120,18 +120,8 @@ if(WIN32) $<$:NDEBUG> $<$:_DEBUG NO_TIMING NO_THREAD_CHECKS> ) - if(BUILD_SHARED_LIBS) - target_sources(rubberband - PRIVATE - rubberband-dll/dllmain.cpp - rubberband-dll/rubberband-dll.cpp - rubberband-dll/stdafx.cpp - ) - target_include_directories(rubberband PRIVATE rubberband-dll) - target_compile_definitions(rubberband PRIVATE RUBBERBANDDLL_EXPORTS _USRDLL) - endif() + set_target_properties(rubberband PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON) endif() - target_include_directories(rubberband PRIVATE $) endif() # From ecb03c83d9e52f08fb199a3d73697631cdcb2c54 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Thu, 21 Jan 2021 17:51:29 +0100 Subject: [PATCH 19/27] CMake: Add support for newer OSX_DEPLOYMENT_TARGET versions Co-authored-by: Be --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a68b920c..b6a3285a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -101,7 +101,9 @@ target_compile_definitions(rubberband ) if(APPLE) - target_compile_options(rubberband PRIVATE -mmacosx-version-min=10.11) + if(CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS 10.11) + message(FATAL_ERROR "macOS deployment target must be >= 10.11") + endif() target_compile_definitions(rubberband PRIVATE HAVE_VDSP) endif() From d534181afbaf3d924a253f1db684bc77dee85dea Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Thu, 21 Jan 2021 18:04:12 +0100 Subject: [PATCH 20/27] CMake: Add support for the JNI interface --- CMakeLists.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index b6a3285a..26990dab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.9 FATAL_ERROR) project(rubberband VERSION 2.1.1) option(BUILD_EXECUTABLE "Build the Rubberband executable" OFF) +option(BUILD_JNI "Build the Java Native Interface (JNI)" OFF) option(OPTIMIZE "Build Rubberband optimized for the build machine's CPU" OFF) option(USE_FFTW "Use FFTW instead of kissFFT" OFF) option(USE_LIBSAMPLERATE "Use libsamplerate instead of Speex" ON) @@ -29,6 +30,16 @@ add_library(rubberband src/system/sysutils.cpp ) +if(BUILD_JNI) + add_library(rubberband-jni src/jni/RubberBandStretcherJNI.cpp) + target_include_directories(rubberband-jni PRIVATE src) + + find_package(JNI REQUIRED) + target_include_directories(rubberband-jni PRIVATE ${JNI_INCLUDE_DIRS}) + target_link_libraries(rubberband-jni PRIVATE ${JNI_LIBRARIES}) +endif() + + # # Dependencies # From 7b2ac362177c6424fab4038ee1d7670a9fad3414 Mon Sep 17 00:00:00 2001 From: Be Date: Sat, 23 Jan 2021 20:40:39 -0600 Subject: [PATCH 21/27] CMake: fix include INSTALL_INTERFACE --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 26990dab..fb24d2ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,10 +94,11 @@ if(OPTIMIZE) endif() endif() +include(GNUInstallDirs) target_include_directories(rubberband PUBLIC $ - $ + $ PRIVATE $ $ @@ -150,7 +151,6 @@ endif() # # Installation # -include(GNUInstallDirs) install( TARGETS rubberband EXPORT rubberband-targets From b7cea081c9dab810ca898a80a4a0c2e34066984f Mon Sep 17 00:00:00 2001 From: Be Date: Mon, 1 Feb 2021 18:25:07 -0600 Subject: [PATCH 22/27] CMake: consolidate Apple-specific code --- CMakeLists.txt | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fb24d2ac..95375871 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,12 +76,6 @@ else() target_sources(rubberband PRIVATE src/speex/resample.c) endif() -# Accelerate framework -if(APPLE) - find_library(ACCELERATE_FRAMEWORK NAMES Accelerate REQUIRED) - target_link_libraries(rubberband PUBLIC ${ACCELERATE_FRAMEWORK}) -endif() - # # Handle general flags, include paths, etc. # @@ -117,6 +111,9 @@ if(APPLE) message(FATAL_ERROR "macOS deployment target must be >= 10.11") endif() target_compile_definitions(rubberband PRIVATE HAVE_VDSP) + + find_library(ACCELERATE_FRAMEWORK NAMES Accelerate REQUIRED) + target_link_libraries(rubberband PUBLIC ${ACCELERATE_FRAMEWORK}) endif() if(WIN32) From e4ed0c25f5d74c0e2b7fb4496c0cc6e55184d894 Mon Sep 17 00:00:00 2001 From: Be Date: Mon, 1 Feb 2021 18:25:46 -0600 Subject: [PATCH 23/27] CMake: combine platform-specific code with elseif --- CMakeLists.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 95375871..f58e9dee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,9 +114,7 @@ if(APPLE) find_library(ACCELERATE_FRAMEWORK NAMES Accelerate REQUIRED) target_link_libraries(rubberband PUBLIC ${ACCELERATE_FRAMEWORK}) -endif() - -if(WIN32) +elseif(WIN32) target_compile_definitions(rubberband PRIVATE _WINDOWS) if(CMAKE_SIZEOF_VOID_P EQUAL 4) target_compile_definitions(rubberband PRIVATE WIN32) From 719b80d0f4ec86bf91729fbb4991f26ceeb7334f Mon Sep 17 00:00:00 2001 From: Be Date: Mon, 1 Feb 2021 18:26:34 -0600 Subject: [PATCH 24/27] CMake: "kissFFT" -> "KISS FFT" --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f58e9dee..1b9540e4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ project(rubberband VERSION 2.1.1) option(BUILD_EXECUTABLE "Build the Rubberband executable" OFF) option(BUILD_JNI "Build the Java Native Interface (JNI)" OFF) option(OPTIMIZE "Build Rubberband optimized for the build machine's CPU" OFF) -option(USE_FFTW "Use FFTW instead of kissFFT" OFF) +option(USE_FFTW "Use FFTW instead of KISS FFT" OFF) option(USE_LIBSAMPLERATE "Use libsamplerate instead of Speex" ON) add_library(rubberband From e4ea785a6b38fc2dfe73a378d5a6153f5a099334 Mon Sep 17 00:00:00 2001 From: Be Date: Tue, 2 Feb 2021 23:45:24 -0600 Subject: [PATCH 25/27] CMake: search more names for libsamplerate --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b9540e4..d0b7af2b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,7 +66,7 @@ endif() if(USE_LIBSAMPLERATE) message(STATUS "Using resampling library: libsamplerate") find_path(SAMPLERATE_INCLUDEDIR samplerate.h REQUIRED) - find_library(SAMPLERATE_LIBRARY samplerate REQUIRED) + find_library(SAMPLERATE_LIBRARY samplerate samplerate-0 libsamplerate libsamplerate-0 REQUIRED) target_include_directories(rubberband PRIVATE ${SAMPLERATE_INCLUDEDIR}) target_link_libraries(rubberband PUBLIC ${SAMPLERATE_LIBRARY}) target_compile_definitions(rubberband PRIVATE HAVE_LIBSAMPLERATE) From 51ed896f455d68b218f2c5a2b4ea0575ea60b25a Mon Sep 17 00:00:00 2001 From: Be Date: Wed, 3 Feb 2021 00:01:54 -0600 Subject: [PATCH 26/27] CMake: search more names for fftw --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d0b7af2b..675aae22 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,7 +52,7 @@ target_link_libraries(rubberband PRIVATE Threads::Threads) if(USE_FFTW) message(STATUS "Using FFT library: fftw") find_path(FFTW3_INCLUDEDIR fftw3.h REQUIRED) - find_library(FFTW3_LIBRARY fftw3 REQUIRED) + find_library(FFTW3_LIBRARY fftw fftw3 fftw-3.3 REQUIRED) target_include_directories(rubberband PRIVATE ${FFTW3_INCLUDEDIR}) target_link_libraries(rubberband PUBLIC ${FFTW3_LIBRARY}) target_compile_definitions(rubberband PRIVATE HAVE_FFTW3 FFTW_DOUBLE_ONLY) From 5c8c7fe7381177e658119ec34299085a529183be Mon Sep 17 00:00:00 2001 From: Be Date: Mon, 1 Feb 2021 19:09:47 -0600 Subject: [PATCH 27/27] GitHub Actions: add workflow using CMake on Ubuntu, Windows, macOS --- .github/workflows/build.yml | 79 +++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..46f94bab --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,79 @@ +name: build + +on: + push: + pull_request: + +jobs: + build: + strategy: + fail-fast: false + matrix: + include: + - name: Ubuntu 20.04 + os: ubuntu-20.04 + install_dir: ~/rubberband + cmake_extras: -DCMAKE_BUILD_TYPE=RelWithDebInfo + - name: macOS 10.15 + os: macos-10.15 + install_dir: ~/rubberband + cmake_extras: -DCMAKE_BUILD_TYPE=RelWithDebInfo + - name: Windows 2019 + os: windows-2019 + install_dir: C:\rubberband + cmake_extras: >- + -DCMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts\buildsystems\vcpkg.cmake + -DCMAKE_PREFIX_PATH=C:\vcpkg\installed\x64-windows-static + cmake_config: --config RelWithDebInfo + ctest_config: --build-config RelWithDebInfo + + name: ${{ matrix.name }} + runs-on: ${{ matrix.os }} + steps: + - name: Check out Git repository + uses: actions/checkout@v2 + - name: "[Ubuntu] Install dependencies" + if: startsWith(matrix.os, 'ubuntu') + run: | + sudo apt-get update + sudo apt-get install -y --no-install-recommends fftw3-dev libsamplerate-dev + - name: "[macOS] Install dependencies" + if: startsWith(matrix.os, 'macos') + run: brew install fftw libsamplerate + - name: "[Windows] Set up vcpkg cache" + uses: actions/cache@v2 + if: runner.os == 'Windows' + with: + path: C:\Users\runneradmin\AppData\Local\vcpkg\archives + key: vcpkg-${{ github.head_ref }}-${{ github.run_number }} + restore-keys: | + vcpkg-${{ github.head_ref }} + vcpkg + - name: "[Windows] Install dependencies" + if: startsWith(matrix.os, 'windows') + run: vcpkg install fftw3 libsamplerate + env: + VCPKG_DEFAULT_TRIPLET: x64-windows-static + - name: Configure + run: cmake + -DCMAKE_INSTALL_PREFIX=${{ matrix.install_dir }} + ${{ matrix.cmake_extras }} + -DUSE_FFTW=ON + -DUSE_LIBSAMPLERATE=ON + -S . -B build + - name: Build + run: cmake --build build ${{ matrix.cmake_config }} + env: + CMAKE_BUILD_PARALLEL_LEVEL: 2 + - name: Install + run: cmake --install build ${{ matrix.cmake_config }} + - name: Run Tests + run: ctest ${{ matrix.ctest_config }} --output-on-failure + working-directory: build + env: + CTEST_PARALLEL_LEVEL: 2 + - name: Upload Build Artifact + uses: actions/upload-artifact@v2 + with: + name: ${{ matrix.name }} rubberband build + path: ${{ matrix.install_dir }}