Skip to content

Commit

Permalink
CMake: disable compilation of audio loaders/writers if FFmpeg isn't f…
Browse files Browse the repository at this point in the history
  • Loading branch information
wo80 committed Apr 3, 2024
1 parent 21c8ad6 commit 8c2ddb3
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 27 deletions.
10 changes: 6 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ set(ESSENTIA_USE_TENSORFLOW OFF)
set(ESSENTIA_USE_VAMP OFF)
set(ESSENTIA_USE_GAIA OFF)

if(FFMPEG_FOUND)
set(ESSENTIA_USE_FFMPEG ON)
endif()

if(USE_KISSFFT)
set(ESSENTIA_USE_KISSFFT ON)
else()
Expand All @@ -81,6 +77,12 @@ else()
endif()
endif()

if(FFMPEG_FOUND)
set(ESSENTIA_USE_FFMPEG ON)
else()
message(WARNING "FFmpeg not found - compilation of audio loaders/writers disabled!")
endif()

if(SAMPLERATE_FOUND)
set(ESSENTIA_USE_LIBSAMPLERATE ON)
endif()
Expand Down
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ target_link_libraries(essentia PUBLIC Eigen3::Eigen)
if(ESSENTIA_USE_FFMPEG)
include_directories(${AVCODEC_INCLUDE_DIRS} ${AVFORMAT_INCLUDE_DIRS} ${AVUTIL_INCLUDE_DIRS} ${SWRESAMPLE_INCLUDE_DIRS})
target_link_libraries(essentia PUBLIC ${AVCODEC_LIBRARIES} ${AVFORMAT_LIBRARIES} ${AVUTIL_LIBRARIES} ${SWRESAMPLE_LIBRARIES})
set(ENABLE_AUDIOLOADER ON)
set(ENABLE_AUDIOWRITER ON)
endif()

if(ESSENTIA_USE_FFTW)
Expand Down
36 changes: 24 additions & 12 deletions src/algorithms/essentia_algorithms_reg_2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,21 @@
#include "algorithms/highlevel/intensity.h"
#include "algorithms/highlevel/pca.h"
#include "algorithms/highlevel/sbic.h"
#include "algorithms/io/audioloader.h"
#include "algorithms/io/audioonsetsmarker.h"
#include "algorithms/io/audiowriter.h"
#if ENABLE_AUDIOLOADER
#include "algorithms/io/audioloader.h"
#include "algorithms/io/easyloader.h"
#include "algorithms/io/eqloudloader.h"
#include "algorithms/io/monoloader.h"
#endif
#if ENABLE_AUDIOWRITER
#include "algorithms/io/audiowriter.h"
#include "algorithms/io/monowriter.h"
#endif
#include "algorithms/io/fileoutputproxy.h"
#if ENABLE_TAGLIB
#include "algorithms/io/metadatareader.h"
#endif
#include "algorithms/io/monoloader.h"
#include "algorithms/io/monowriter.h"
#if ENABLE_YAML
#include "algorithms/io/yamlinput.h"
#endif
Expand Down Expand Up @@ -350,16 +354,20 @@ ESSENTIA_API void registerAlgorithm() {
AlgorithmFactory::Registrar<Intensity> regIntensity;
AlgorithmFactory::Registrar<PCA> regPCA;
AlgorithmFactory::Registrar<SBic> regSBic;
AlgorithmFactory::Registrar<AudioLoader> regAudioLoader;
AlgorithmFactory::Registrar<AudioOnsetsMarker> regAudioOnsetsMarker;
AlgorithmFactory::Registrar<AudioWriter> regAudioWriter;
#if ENABLE_AUDIOLOADER
AlgorithmFactory::Registrar<AudioLoader> regAudioLoader;
AlgorithmFactory::Registrar<EasyLoader> regEasyLoader;
AlgorithmFactory::Registrar<EqloudLoader> regEqloudLoader;
AlgorithmFactory::Registrar<MonoLoader> regMonoLoader;
#endif
#if ENABLE_AUDIOWRITER
AlgorithmFactory::Registrar<AudioWriter> regAudioWriter;
AlgorithmFactory::Registrar<MonoWriter> regMonoWriter;
#endif
#if ENABLE_TAGLIB
AlgorithmFactory::Registrar<MetadataReader> regMetadataReader;
#endif
AlgorithmFactory::Registrar<MonoLoader> regMonoLoader;
AlgorithmFactory::Registrar<MonoWriter> regMonoWriter;
#if ENABLE_YAML
AlgorithmFactory::Registrar<YamlInput> regYamlInput;
#endif
Expand Down Expand Up @@ -633,17 +641,21 @@ ESSENTIA_API void registerAlgorithm() {
AlgorithmFactory::Registrar<DynamicComplexity, essentia::standard::DynamicComplexity> regDynamicComplexity;
AlgorithmFactory::Registrar<FadeDetection, essentia::standard::FadeDetection> regFadeDetection;
AlgorithmFactory::Registrar<SBic, essentia::standard::SBic> regSBic;
AlgorithmFactory::Registrar<AudioLoader, essentia::standard::AudioLoader> regAudioLoader;
AlgorithmFactory::Registrar<AudioOnsetsMarker, essentia::standard::AudioOnsetsMarker> regAudioOnsetsMarker;
AlgorithmFactory::Registrar<AudioWriter, essentia::standard::AudioWriter> regAudioWriter;
#if ENABLE_AUDIOLOADER
AlgorithmFactory::Registrar<AudioLoader, essentia::standard::AudioLoader> regAudioLoader;
AlgorithmFactory::Registrar<EasyLoader, essentia::standard::EasyLoader> regEasyLoader;
#endif
#if ENABLE_AUDIOWRITER
AlgorithmFactory::Registrar<EqloudLoader, essentia::standard::EqloudLoader> regEqloudLoader;
AlgorithmFactory::Registrar<MonoLoader, essentia::standard::MonoLoader> regMonoLoader;
AlgorithmFactory::Registrar<AudioWriter, essentia::standard::AudioWriter> regAudioWriter;
AlgorithmFactory::Registrar<MonoWriter, essentia::standard::MonoWriter> regMonoWriter;
#endif
AlgorithmFactory::Registrar<FileOutputProxy> regFileOutputProxy;
#if ENABLE_TAGLIB
AlgorithmFactory::Registrar<MetadataReader, essentia::standard::MetadataReader> regMetadataReader;
#endif
AlgorithmFactory::Registrar<MonoLoader, essentia::standard::MonoLoader> regMonoLoader;
AlgorithmFactory::Registrar<MonoWriter, essentia::standard::MonoWriter> regMonoWriter;
AlgorithmFactory::Registrar<BeatsLoudness, essentia::standard::BeatsLoudness> regBeatsLoudness;
AlgorithmFactory::Registrar<BeatTrackerDegara, essentia::standard::BeatTrackerDegara> regBeatTrackerDegara;
AlgorithmFactory::Registrar<BeatTrackerMultiFeature, essentia::standard::BeatTrackerMultiFeature> regBeatTrackerMultiFeature;
Expand Down
8 changes: 8 additions & 0 deletions src/algorithms/essentia_algorithms_reg_2.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
#ifndef ESSENTIA_ALGORITHMS_REG_H_
#define ESSENTIA_ALGORITHMS_REG_H_

#ifndef ENABLE_AUDIOLOADER
#cmakedefine01 ENABLE_AUDIOLOADER
#endif

#ifndef ENABLE_AUDIOWRITER
#cmakedefine01 ENABLE_AUDIOWRITER
#endif

#ifndef ENABLE_FFTW
#cmakedefine01 ENABLE_FFTW
#endif
Expand Down
22 changes: 11 additions & 11 deletions src/algorithms/io/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
target_sources(essentia
PRIVATE
audioonsetsmarker.cpp
audiowriter.cpp
easyloader.cpp
eqloudloader.cpp
fileoutputproxy.cpp
monoloader.cpp
monowriter.cpp
yamloutput.cpp
audioonsetsmarker.h
audiowriter.h
easyloader.h
eqloudloader.h
fileoutputproxy.h
monoloader.h
monowriter.h
yamloutput.h)

if(ESSENTIA_USE_FFMPEG)
target_sources(essentia
PRIVATE
audioloader.cpp
audioloader.h)
audiowriter.cpp
easyloader.cpp
eqloudloader.cpp
monoloader.cpp
monowriter.cpp
audioloader.h
audiowriter.h
easyloader.h
eqloudloader.h
monoloader.h
monowriter.h)
endif()

if(ESSENTIA_USE_YAML)
Expand Down

0 comments on commit 8c2ddb3

Please sign in to comment.