From c2095b9b7561285a3a86c028971d91b18d84bf84 Mon Sep 17 00:00:00 2001 From: Daniel Walz Date: Fri, 12 Mar 2021 13:59:43 +0100 Subject: [PATCH 01/44] Added method to set all Keyframes with unnormalised vales at once --- Processing/foleys_ParameterAutomation.cpp | 26 +++++++++++++++++++++++ Processing/foleys_ParameterAutomation.h | 15 +++++++++++++ 2 files changed, 41 insertions(+) diff --git a/Processing/foleys_ParameterAutomation.cpp b/Processing/foleys_ParameterAutomation.cpp index 6f2b3628..baf40de4 100644 --- a/Processing/foleys_ParameterAutomation.cpp +++ b/Processing/foleys_ParameterAutomation.cpp @@ -368,6 +368,23 @@ void AudioParameterAutomation::addRealKeyframe (double pts, double value) addKeyframe (pts, value); } +void AudioParameterAutomation::setKeyframesWithRealValues (std::map keys) +{ + if (auto* param = dynamic_cast(¶meter)) + { + auto range = param->getNormalisableRange(); + std::map realKeys; + for (auto& k : keys) + realKeys [k.first] = range.convertTo0to1 (k.second); + + setKeyframes (realKeys); + } + else + { + setKeyframes (keys); + } +} + void AudioParameterAutomation::parameterValueChanged (int, float newValue) { // DBG ("Got Value: " << getName() << " - " << juce::String (newValue) << " " << juce::String (parameterIndex) << "/" << juce::String (parameter.getParameterIndex())); @@ -470,6 +487,15 @@ void VideoParameterAutomation::addRealKeyframe (double pts, double value) addKeyframe (pts, parameter.normaliseValue (value)); } +void VideoParameterAutomation::setKeyframesWithRealValues (std::map keys) +{ + std::map realKeys; + for (auto& k : keys) + realKeys [k.first] = parameter.normaliseValue (k.second); + + setKeyframes (realKeys); +} + void VideoParameterAutomation::valueChanged (ProcessorParameter&, double newValue) { auto pts = controllable.getCurrentPTS(); diff --git a/Processing/foleys_ParameterAutomation.h b/Processing/foleys_ParameterAutomation.h index 2cc24938..b6e76704 100644 --- a/Processing/foleys_ParameterAutomation.h +++ b/Processing/foleys_ParameterAutomation.h @@ -127,6 +127,11 @@ class ParameterAutomation : private juce::ValueTree::Listener */ void setKeyframes (std::map keys); + /** + Replace all keyframes specifying the value in unnormalised values + */ + virtual void setKeyframesWithRealValues (std::map keys) = 0; + virtual juce::String getText (float normalisedValue, int numDigits = 2) const = 0; virtual double getValueForText (const juce::String& text) const = 0; @@ -205,6 +210,11 @@ class AudioParameterAutomation : public ParameterAutomation, void setRealValue (double pts, double value) override; void addRealKeyframe (double pts, double value) override; + /** + Replace all keyframes specifying the value in unnormalised values + */ + void setKeyframesWithRealValues (std::map keys) override; + void parameterValueChanged (int parameterIndex, float newValue) override; void parameterGestureChanged (int parameterIndex, bool gestureIsStarting) override; @@ -251,6 +261,11 @@ class VideoParameterAutomation : public ParameterAutomation, void setRealValue (double pts, double value) override; void addRealKeyframe (double pts, double value) override; + /** + Replace all keyframes specifying the value in unnormalised values + */ + void setKeyframesWithRealValues (std::map keys) override; + void valueChanged (ProcessorParameter& parameter, double newValue) override; void gestureStarted (ProcessorParameter& parameter) override; void gestureFinished (ProcessorParameter& parameter) override; From 3a68c4dafbe76dba653807e8a5489d148f0097c4 Mon Sep 17 00:00:00 2001 From: Daniel Walz Date: Fri, 12 Mar 2021 17:23:22 +0100 Subject: [PATCH 02/44] Pull silence instead of garbage if FIFO is empty --- Basics/foleys_AudioFifo.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Basics/foleys_AudioFifo.cpp b/Basics/foleys_AudioFifo.cpp index 7c40b660..708aeef2 100644 --- a/Basics/foleys_AudioFifo.cpp +++ b/Basics/foleys_AudioFifo.cpp @@ -50,14 +50,22 @@ void AudioFifo::setNumSamples (int samples) void AudioFifo::pullSamples (const juce::AudioSourceChannelInfo& info) { + auto ready = audioFifo.getNumReady() >= info.numSamples; + + if (!ready) + info.clearActiveBufferRegion(); + auto read = audioFifo.read (info.numSamples); - for (int channel=0; channelcopyFrom (channel, info.startSample, audioBuffer.getReadPointer (sourceChannel, read.startIndex1), read.blockSize1); - if (read.blockSize2 > 0) - info.buffer->copyFrom (channel, info.startSample + read.blockSize1, audioBuffer.getReadPointer (sourceChannel, read.startIndex2), read.blockSize2); + for (int channel=0; channelcopyFrom (channel, info.startSample, audioBuffer.getReadPointer (sourceChannel, read.startIndex1), read.blockSize1); + if (read.blockSize2 > 0) + info.buffer->copyFrom (channel, info.startSample + read.blockSize1, audioBuffer.getReadPointer (sourceChannel, read.startIndex2), read.blockSize2); + } } readPosition.fetch_add (read.blockSize1 + read.blockSize2); From f110f1300c078c81db001da38ff570ecfbc7199e Mon Sep 17 00:00:00 2001 From: Daniel Walz Date: Sat, 13 Mar 2021 00:28:53 +0100 Subject: [PATCH 03/44] Fixed warning --- Processing/foleys_ParameterAutomation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Processing/foleys_ParameterAutomation.cpp b/Processing/foleys_ParameterAutomation.cpp index baf40de4..8941298d 100644 --- a/Processing/foleys_ParameterAutomation.cpp +++ b/Processing/foleys_ParameterAutomation.cpp @@ -375,7 +375,7 @@ void AudioParameterAutomation::setKeyframesWithRealValues (std::mapgetNormalisableRange(); std::map realKeys; for (auto& k : keys) - realKeys [k.first] = range.convertTo0to1 (k.second); + realKeys [k.first] = range.convertTo0to1 (float (k.second)); setKeyframes (realKeys); } From 7e9f479702ef0299784602347977d00e07a947d1 Mon Sep 17 00:00:00 2001 From: Daniel Walz Date: Thu, 25 Mar 2021 00:37:25 +0100 Subject: [PATCH 04/44] Optimised CPU spin on read ahead, and when clip is exhausted --- Basics/foleys_Structures.h | 2 +- Basics/foleys_VideoFifo.cpp | 5 +++++ Basics/foleys_VideoFifo.h | 2 ++ Clips/foleys_MovieClip.cpp | 16 ++++++++++++++-- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Basics/foleys_Structures.h b/Basics/foleys_Structures.h index 882a1603..0dad9b92 100644 --- a/Basics/foleys_Structures.h +++ b/Basics/foleys_Structures.h @@ -72,7 +72,7 @@ static inline int64_t convertTimecode (double pts, const VideoStreamSettings& se if (settings.defaultDuration == 0) return 0; - return settings.defaultDuration * int64_t (pts * settings.timebase / settings.defaultDuration); + return int64_t (pts * settings.timebase); } /** Convert a time in seconds into samples, using the sample rate in AudioStreamSettings */ diff --git a/Basics/foleys_VideoFifo.cpp b/Basics/foleys_VideoFifo.cpp index 82c2a74a..397467c2 100644 --- a/Basics/foleys_VideoFifo.cpp +++ b/Basics/foleys_VideoFifo.cpp @@ -159,6 +159,11 @@ void VideoFifo::setVideoSettings (const VideoStreamSettings& s) FOLEYS_LOG ("FIFO VideoSettings: " << settings.frameSize.toString() << " timebase " << settings.timebase << ", duration " << settings.defaultDuration); } +double VideoFifo::getFrameDurationInSeconds() const +{ + return static_cast (settings.defaultDuration) / static_cast (settings.timebase); +} + int VideoFifo::nextIndex (int pos, int offset) const { jassert (offset < int (frames.size())); diff --git a/Basics/foleys_VideoFifo.h b/Basics/foleys_VideoFifo.h index 7b8eaeb8..cf638884 100644 --- a/Basics/foleys_VideoFifo.h +++ b/Basics/foleys_VideoFifo.h @@ -79,6 +79,8 @@ class VideoFifo final */ void dumpTimeCodes() const; + double getFrameDurationInSeconds() const; + private: int findFramePosition (int64_t timecode, int start) const; diff --git a/Clips/foleys_MovieClip.cpp b/Clips/foleys_MovieClip.cpp index 999c1aad..72468b7d 100644 --- a/Clips/foleys_MovieClip.cpp +++ b/Clips/foleys_MovieClip.cpp @@ -319,10 +319,22 @@ int MovieClip::BackgroundReaderJob::useTimeSlice() { juce::ScopedValueSetter guard (inDecodeBlock, true); owner.movieReader->readNewData (owner.videoFifo, owner.audioFifo); - return 3; } - return 30; + if (owner.movieReader.get() != nullptr) + { + if (owner.getNextReadPosition() >= owner.movieReader->getTotalLength()) + return 100; + } + + double secs = 1; + if (owner.hasAudio()) + secs = std::min (secs, owner.audioFifo.getAvailableSamples() / owner.sampleRate); + + if (owner.hasVideo()) + secs = std::min (secs, owner.videoFifo.getNumAvailableFrames() * owner.videoFifo.getFrameDurationInSeconds()); + + return int (50.0 * secs); } void MovieClip::BackgroundReaderJob::setSuspended (bool s) From 7c6231a75fccbe003b90abc92bf66420430ce591 Mon Sep 17 00:00:00 2001 From: Daniel Walz Date: Mon, 26 Apr 2021 14:33:53 +0200 Subject: [PATCH 05/44] Write header even when aborting writing --- Clips/foleys_ComposedClip.cpp | 8 +++++--- Clips/foleys_MovieClip.cpp | 5 ++++- ReadWrite/foleys_ClipRenderer.cpp | 3 +++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Clips/foleys_ComposedClip.cpp b/Clips/foleys_ComposedClip.cpp index 542a2419..39220d4d 100644 --- a/Clips/foleys_ComposedClip.cpp +++ b/Clips/foleys_ComposedClip.cpp @@ -121,12 +121,14 @@ bool ComposedClip::isFrameAvailable (double pts) const { juce::ignoreUnused (pts); auto active = getClips(); - auto pos = pts * getSampleRate(); for (auto& clip : active) - if (clip->clip->hasVideo() && juce::isPositiveAndBelow (pos - clip->getStartInSamples(), clip->getLengthInSamples())) - if (clip->clip->isFrameAvailable (pts - clip->getStart() + clip->getOffset()) == false) + { + auto localPts = clip->getClipTimeInDescriptorTime (pts); + if (clip->clip->hasVideo() && juce::isPositiveAndBelow (localPts * getSampleRate(), clip->getLengthInSamples())) + if (clip->clip->isFrameAvailable (localPts) == false) return false; + } return true; } diff --git a/Clips/foleys_MovieClip.cpp b/Clips/foleys_MovieClip.cpp index 999c1aad..b6aa0cc5 100644 --- a/Clips/foleys_MovieClip.cpp +++ b/Clips/foleys_MovieClip.cpp @@ -131,7 +131,10 @@ void MovieClip::render (OpenGLView& view, double pts, float rotation, float zoom bool MovieClip::isFrameAvailable (double pts) const { - return videoFifo.isFrameAvailable (pts); + if (juce::isPositiveAndBelow (pts * movieReader->sampleRate, movieReader->getTotalLength())) + return videoFifo.isFrameAvailable (pts); + + return true; } juce::Image MovieClip::getStillImage (double seconds, Size size) diff --git a/ReadWrite/foleys_ClipRenderer.cpp b/ReadWrite/foleys_ClipRenderer.cpp index 6afaf407..e4c5a02d 100644 --- a/ReadWrite/foleys_ClipRenderer.cpp +++ b/ReadWrite/foleys_ClipRenderer.cpp @@ -144,6 +144,9 @@ juce::ThreadPoolJob::JobStatus ClipRenderer::RenderJob::runJob() { if (shouldExit()) { + bouncer.writer->finishWriting(); + bouncer.writer.reset(); + if (bouncer.onRenderingFinished) bouncer.onRenderingFinished (false); From 106f5d3433b388dd74bba5682bbe714e8f54ffa6 Mon Sep 17 00:00:00 2001 From: Daniel Walz Date: Mon, 26 Apr 2021 15:31:15 +0200 Subject: [PATCH 06/44] Fixed some warnings --- Processing/foleys_ParameterAutomation.cpp | 34 +++++++++++------------ 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/Processing/foleys_ParameterAutomation.cpp b/Processing/foleys_ParameterAutomation.cpp index 8941298d..9abf0688 100644 --- a/Processing/foleys_ParameterAutomation.cpp +++ b/Processing/foleys_ParameterAutomation.cpp @@ -154,12 +154,12 @@ double ParameterAutomation::getPreviousKeyframeTime (double time) const double ParameterAutomation::getNextKeyframeTime (double time) const { - const auto& next = keyframes.upper_bound (time); + auto next = keyframes.upper_bound (time); if (next == keyframes.end()) return time; if (next->first == time) - std::next (next); + next = std::next (next); if (next == keyframes.end()) return time; @@ -344,28 +344,28 @@ double AudioParameterAutomation::getRealValueForTime (double pts) const return getValueForTime (pts); } -void AudioParameterAutomation::setRealValue (double value) +void AudioParameterAutomation::setRealValue (double newValue) { if (auto* ranged = dynamic_cast(¶meter)) - setValue (ranged->getNormalisableRange().convertTo0to1 (float (value))); + setValue (ranged->getNormalisableRange().convertTo0to1 (float (newValue))); else - setValue (value); + setValue (newValue); } -void AudioParameterAutomation::setRealValue (double pts, double value) +void AudioParameterAutomation::setRealValue (double pts, double newValue) { if (auto* ranged = dynamic_cast(¶meter)) - setValue (pts, ranged->getNormalisableRange().convertTo0to1 (float (value))); + setValue (pts, ranged->getNormalisableRange().convertTo0to1 (float (newValue))); else - setValue (pts, value); + setValue (pts, newValue); } -void AudioParameterAutomation::addRealKeyframe (double pts, double value) +void AudioParameterAutomation::addRealKeyframe (double pts, double newValue) { if (auto* ranged = dynamic_cast(¶meter)) - addKeyframe (pts, ranged->getNormalisableRange().convertTo0to1 (float (value))); + addKeyframe (pts, ranged->getNormalisableRange().convertTo0to1 (float (newValue))); else - addKeyframe (pts, value); + addKeyframe (pts, newValue); } void AudioParameterAutomation::setKeyframesWithRealValues (std::map keys) @@ -472,19 +472,19 @@ double VideoParameterAutomation::getRealValueForTime (double pts) const return parameter.unNormaliseValue (getValueForTime (pts)); } -void VideoParameterAutomation::setRealValue (double value) +void VideoParameterAutomation::setRealValue (double newValue) { - setValue (parameter.normaliseValue (value)); + setValue (parameter.normaliseValue (newValue)); } -void VideoParameterAutomation::setRealValue (double pts, double value) +void VideoParameterAutomation::setRealValue (double pts, double newValue) { - setValue (pts, parameter.normaliseValue (value)); + setValue (pts, parameter.normaliseValue (newValue)); } -void VideoParameterAutomation::addRealKeyframe (double pts, double value) +void VideoParameterAutomation::addRealKeyframe (double pts, double newValue) { - addKeyframe (pts, parameter.normaliseValue (value)); + addKeyframe (pts, parameter.normaliseValue (newValue)); } void VideoParameterAutomation::setKeyframesWithRealValues (std::map keys) From ca53f744e15e680263af57c0c87f840a655d8243 Mon Sep 17 00:00:00 2001 From: Daniel Walz Date: Fri, 30 Apr 2021 14:37:17 +0200 Subject: [PATCH 07/44] Added AVFormat interface to allow different reading backends --- ReadWrite/FFmpeg/FFmpegFormat.cpp | 57 +++++++++++++++++++++++++ ReadWrite/FFmpeg/foleys_FFmpegHelpers.h | 4 +- ReadWrite/foleys_AVFormatManager.cpp | 20 ++++++--- ReadWrite/foleys_AVFormatManager.h | 17 ++++++++ foleys_video_engine.cpp | 1 + 5 files changed, 91 insertions(+), 8 deletions(-) create mode 100644 ReadWrite/FFmpeg/FFmpegFormat.cpp diff --git a/ReadWrite/FFmpeg/FFmpegFormat.cpp b/ReadWrite/FFmpeg/FFmpegFormat.cpp new file mode 100644 index 00000000..8f1eb7c1 --- /dev/null +++ b/ReadWrite/FFmpeg/FFmpegFormat.cpp @@ -0,0 +1,57 @@ +/* + ============================================================================== + + Copyright (c) 2019 - 2021, Foleys Finest Audio - Daniel Walz + All rights reserved. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + OF THE POSSIBILITY OF SUCH DAMAGE. + + ============================================================================== + */ + +#if FOLEYS_USE_FFMPEG + + +namespace foleys +{ + +struct FFmpegFormat : public AVFormat +{ + FFmpegFormat() = default; + + bool canRead(juce::File file) override + { + juce::ignoreUnused(file); + return true; + } + + std::unique_ptr createReaderFor(juce::File file, StreamTypes type = StreamTypes::all()) + { + return std::make_unique(file, type); + } + + bool canWrite(juce::File file) override + { + juce::ignoreUnused(file); + return true; + } + + std::unique_ptr createWriterFor(juce::File file, StreamTypes type = StreamTypes::all()) override + { + return {}; + } +}; + + + +} // foleys +#endif diff --git a/ReadWrite/FFmpeg/foleys_FFmpegHelpers.h b/ReadWrite/FFmpeg/foleys_FFmpegHelpers.h index 07007739..3e1f5e6a 100644 --- a/ReadWrite/FFmpeg/foleys_FFmpegHelpers.h +++ b/ReadWrite/FFmpeg/foleys_FFmpegHelpers.h @@ -42,9 +42,7 @@ extern "C" { #endif -#include -#include -#include +#include #include #include #include diff --git a/ReadWrite/foleys_AVFormatManager.cpp b/ReadWrite/foleys_AVFormatManager.cpp index 64699460..488ef434 100644 --- a/ReadWrite/foleys_AVFormatManager.cpp +++ b/ReadWrite/foleys_AVFormatManager.cpp @@ -78,13 +78,18 @@ std::shared_ptr AVFormatManager::createClipFromFile (VideoEngine& engine std::unique_ptr AVFormatManager::createReaderFor (juce::File file, StreamTypes type) { + // If you hit this jassert you didn't add an AVFormat to read video files. + // use @see registerFormat() to add a reader backend, e.g. + // videoEngine.getFormatManager().registerFormat (std::make_unique()); + jassert(videoFormats.empty() == false); + + for (auto& format : videoFormats) + { + if (format->canRead (file)) + return format->createReaderFor (file, type); + } -#if FOLEYS_USE_FFMPEG - return std::make_unique (file, type); -#else - juce::ignoreUnused (file, type); return {}; -#endif } std::unique_ptr AVFormatManager::createClipWriter (juce::File file) @@ -99,6 +104,11 @@ std::unique_ptr AVFormatManager::createClipWriter (juce::File file) #endif } +void AVFormatManager::registerFormat(std::unique_ptr format) +{ + videoFormats.push_back (std::move (format)); +} + void AVFormatManager::registerFactory (const juce::String& schema, std::function(foleys::VideoEngine& videoEngine, juce::URL url, StreamTypes type)> factory) { factories [schema] = factory; diff --git a/ReadWrite/foleys_AVFormatManager.h b/ReadWrite/foleys_AVFormatManager.h index 82a31de5..9a4a4fdd 100644 --- a/ReadWrite/foleys_AVFormatManager.h +++ b/ReadWrite/foleys_AVFormatManager.h @@ -24,6 +24,19 @@ namespace foleys { + +struct AVFormat { + AVFormat() = default; + virtual ~AVFormat() = default; + + virtual bool canRead(juce::File file) = 0; + virtual std::unique_ptr createReaderFor(juce::File file, StreamTypes type = StreamTypes::all()) = 0; + + virtual bool canWrite(juce::File file) = 0; + virtual std::unique_ptr createWriterFor(juce::File file, StreamTypes type = StreamTypes::all()) = 0; +}; + + /** @class AVFormatManager @@ -47,6 +60,8 @@ class AVFormatManager std::unique_ptr createClipWriter (juce::File file); + void registerFormat (std::unique_ptr format); + void registerFactory (const juce::String& schema, std::function(foleys::VideoEngine& videoEngine, juce::URL url, StreamTypes type)> factory); juce::AudioFormatManager audioFormatManager; @@ -55,6 +70,8 @@ class AVFormatManager std::map(foleys::VideoEngine& videoEngine, juce::URL url, StreamTypes type)>> factories; + std::vector> videoFormats; + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AVFormatManager) }; diff --git a/foleys_video_engine.cpp b/foleys_video_engine.cpp index 9f507c98..8e9ffc21 100644 --- a/foleys_video_engine.cpp +++ b/foleys_video_engine.cpp @@ -48,6 +48,7 @@ #if FOLEYS_USE_FFMPEG #include "ReadWrite/FFmpeg/foleys_FFmpegReader.cpp" #include "ReadWrite/FFmpeg/foleys_FFmpegWriter.cpp" +#include "ReadWrite/FFmpeg/foleys_FFmpegFormat.cpp" #endif #include "Widgets/foleys_SoftwareView.cpp" From d16a08e4d41cc6f0bbf2abdf724182292739ee99 Mon Sep 17 00:00:00 2001 From: Daniel Walz Date: Fri, 30 Apr 2021 14:55:47 +0200 Subject: [PATCH 08/44] Fixed wrong FFmpegFormat include --- ReadWrite/FFmpeg/{FFmpegFormat.cpp => foleys_FFmpegFormat.h} | 2 ++ foleys_video_engine.cpp | 1 - foleys_video_engine.h | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) rename ReadWrite/FFmpeg/{FFmpegFormat.cpp => foleys_FFmpegFormat.h} (99%) diff --git a/ReadWrite/FFmpeg/FFmpegFormat.cpp b/ReadWrite/FFmpeg/foleys_FFmpegFormat.h similarity index 99% rename from ReadWrite/FFmpeg/FFmpegFormat.cpp rename to ReadWrite/FFmpeg/foleys_FFmpegFormat.h index 8f1eb7c1..177fb4e3 100644 --- a/ReadWrite/FFmpeg/FFmpegFormat.cpp +++ b/ReadWrite/FFmpeg/foleys_FFmpegFormat.h @@ -18,6 +18,8 @@ ============================================================================== */ +#pragma once + #if FOLEYS_USE_FFMPEG diff --git a/foleys_video_engine.cpp b/foleys_video_engine.cpp index 8e9ffc21..9f507c98 100644 --- a/foleys_video_engine.cpp +++ b/foleys_video_engine.cpp @@ -48,7 +48,6 @@ #if FOLEYS_USE_FFMPEG #include "ReadWrite/FFmpeg/foleys_FFmpegReader.cpp" #include "ReadWrite/FFmpeg/foleys_FFmpegWriter.cpp" -#include "ReadWrite/FFmpeg/foleys_FFmpegFormat.cpp" #endif #include "Widgets/foleys_SoftwareView.cpp" diff --git a/foleys_video_engine.h b/foleys_video_engine.h index b90bd974..3e306d09 100644 --- a/foleys_video_engine.h +++ b/foleys_video_engine.h @@ -147,6 +147,7 @@ #if FOLEYS_USE_FFMPEG #include "ReadWrite/FFmpeg/foleys_FFmpegReader.h" #include "ReadWrite/FFmpeg/foleys_FFmpegWriter.h" +#include "ReadWrite/FFmpeg/foleys_FFmpegFormat.h" #endif #include "Plugins/foleys_ColourCurveVideoProcessor.h" From 7fb18b1b74a7a04d4a29673f5f1543ebb2048697 Mon Sep 17 00:00:00 2001 From: Daniel Walz Date: Fri, 30 Apr 2021 15:53:31 +0200 Subject: [PATCH 09/44] Fixed FFmpeg setup --- ReadWrite/FFmpeg/foleys_FFmpegFormat.cpp | 55 ++++++++++++++++++++++++ ReadWrite/FFmpeg/foleys_FFmpegFormat.h | 31 ++++--------- ReadWrite/FFmpeg/foleys_FFmpegHelpers.h | 4 +- foleys_video_engine.cpp | 1 + 4 files changed, 67 insertions(+), 24 deletions(-) create mode 100644 ReadWrite/FFmpeg/foleys_FFmpegFormat.cpp diff --git a/ReadWrite/FFmpeg/foleys_FFmpegFormat.cpp b/ReadWrite/FFmpeg/foleys_FFmpegFormat.cpp new file mode 100644 index 00000000..46197888 --- /dev/null +++ b/ReadWrite/FFmpeg/foleys_FFmpegFormat.cpp @@ -0,0 +1,55 @@ +/* + ============================================================================== + + Copyright (c) 2019 - 2021, Foleys Finest Audio - Daniel Walz + All rights reserved. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + OF THE POSSIBILITY OF SUCH DAMAGE. + + ============================================================================== + */ + +#if FOLEYS_USE_FFMPEG + + +namespace foleys +{ + +FFmpegFormat::FFmpegFormat() {} +FFmpegFormat::~FFmpegFormat() {} + +bool FFmpegFormat::canRead(juce::File file) +{ + juce::ignoreUnused(file); + return true; +} + +std::unique_ptr FFmpegFormat::createReaderFor(juce::File file, StreamTypes types) +{ + return std::make_unique(file, types); +} + +bool FFmpegFormat::canWrite(juce::File file) +{ + juce::ignoreUnused(file); + return true; +} + +std::unique_ptr FFmpegFormat::createWriterFor(juce::File file, StreamTypes types) +{ + juce::ignoreUnused (file, types); + return {}; +} + + +} // foleys +#endif diff --git a/ReadWrite/FFmpeg/foleys_FFmpegFormat.h b/ReadWrite/FFmpeg/foleys_FFmpegFormat.h index 177fb4e3..f5430a65 100644 --- a/ReadWrite/FFmpeg/foleys_FFmpegFormat.h +++ b/ReadWrite/FFmpeg/foleys_FFmpegFormat.h @@ -28,29 +28,14 @@ namespace foleys struct FFmpegFormat : public AVFormat { - FFmpegFormat() = default; - - bool canRead(juce::File file) override - { - juce::ignoreUnused(file); - return true; - } - - std::unique_ptr createReaderFor(juce::File file, StreamTypes type = StreamTypes::all()) - { - return std::make_unique(file, type); - } - - bool canWrite(juce::File file) override - { - juce::ignoreUnused(file); - return true; - } - - std::unique_ptr createWriterFor(juce::File file, StreamTypes type = StreamTypes::all()) override - { - return {}; - } + FFmpegFormat(); + ~FFmpegFormat() override; + + bool canRead(juce::File file) override; + std::unique_ptr createReaderFor(juce::File file, StreamTypes types = StreamTypes::all()) override; + + bool canWrite(juce::File file) override; + std::unique_ptr createWriterFor(juce::File file, StreamTypes types = StreamTypes::all()) override; }; diff --git a/ReadWrite/FFmpeg/foleys_FFmpegHelpers.h b/ReadWrite/FFmpeg/foleys_FFmpegHelpers.h index 3e1f5e6a..07007739 100644 --- a/ReadWrite/FFmpeg/foleys_FFmpegHelpers.h +++ b/ReadWrite/FFmpeg/foleys_FFmpegHelpers.h @@ -42,7 +42,9 @@ extern "C" { #endif -#include +#include +#include +#include #include #include #include diff --git a/foleys_video_engine.cpp b/foleys_video_engine.cpp index 9f507c98..8e9ffc21 100644 --- a/foleys_video_engine.cpp +++ b/foleys_video_engine.cpp @@ -48,6 +48,7 @@ #if FOLEYS_USE_FFMPEG #include "ReadWrite/FFmpeg/foleys_FFmpegReader.cpp" #include "ReadWrite/FFmpeg/foleys_FFmpegWriter.cpp" +#include "ReadWrite/FFmpeg/foleys_FFmpegFormat.cpp" #endif #include "Widgets/foleys_SoftwareView.cpp" From 641c1cee0b5c6425ececdfba3afa10b9cf45e2db Mon Sep 17 00:00:00 2001 From: Daniel Walz Date: Tue, 18 May 2021 22:04:37 +0200 Subject: [PATCH 10/44] Sound dev (#12) * Added more granular information of the original video file Co-authored-by: Sound Development --- Basics/foleys_Structures.h | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/Basics/foleys_Structures.h b/Basics/foleys_Structures.h index 0dad9b92..00b46050 100644 --- a/Basics/foleys_Structures.h +++ b/Basics/foleys_Structures.h @@ -31,15 +31,11 @@ struct Size final int width = 0; int height = 0; - double getAspectRatio() - { - return (height > 0) ? width / double (height) : 1.33; - } + double getAspectRatio() const { return (height > 0) ? width / double (height) : 1.33; } - juce::String toString() const - { - return juce::String (width) + "x" + juce::String (height); - } + juce::String toString() const { return juce::String(width) + "x" + juce::String(height); } + + bool isEmpty() const { return ( ( width * height ) == 0 ); } }; enum class Aspect @@ -53,17 +49,27 @@ enum class Aspect /** Defines the size and time settings for a VideoStream */ struct VideoStreamSettings final { - Size frameSize; - int defaultDuration = 1001; - int timebase = 24000; + Size frameSize; + int defaultDuration = 1001; + int timebase = 24000; + + bool isValid() const { return (!frameSize.isEmpty()) && (timebase != 0) && (defaultDuration != 0); } + double getFrameRate() const { return (timebase > 0 ? (timebase / static_cast(defaultDuration)) : 0.0); } + double getFrameDurationSeconds() const { return defaultDuration / static_cast( timebase); } + juce::String toString() const { return frameSize.toString() + " " + juce::String(getFrameRate(), 2) + " FPS"; } }; /** Defines the number of channels and time settings for an AudioStream */ struct AudioStreamSettings final { - int numChannels = 2; + int numChannels = 2; int defaultNumSamples = 1024; - int timebase = 48000; + int timebase = 48000; + int bitsPerSample = 0; + [[nodiscard]] bool isValid() const { return (timebase > 0) && (numChannels > 0) && (bitsPerSample > 0); } + [[nodiscard]] juce::String toString() const { return juce::String(numChannels) + " channels at " + juce::String(timebase) + " Hz @ " + juce::String(bitsPerSample) + " bits"; } + [[nodiscard]] int getFrameSize() const { return numChannels * getSampleSize(); } + [[nodiscard]] int getSampleSize() const { return (bitsPerSample / 8); } }; /** Convert a time in seconds in frame counts, using the time base and duration in VideoStreamSettings */ From 110f186a6b8315ea4349274223a39e44f5e1ef65 Mon Sep 17 00:00:00 2001 From: Ben Vining Date: Wed, 23 Feb 2022 05:16:30 -0600 Subject: [PATCH 11/44] initial commit to cmake branch --- .gitignore | 1 + CMakeLists.txt | 28 + Makefile | 56 ++ ReadWrite/FFmpeg/foleys_FFmpegReader.cpp | 4 +- cmake/AddCPM.cmake | 11 + cmake/CPM.cmake | 1033 +++++++++++++++++++++ cmake/FindFFmpeg.cmake | 30 + cmake/FindJUCE.cmake | 11 + cmake/FoleysDefaultSettings.cmake | 94 ++ cmake/FoleysDefaultTarget.cmake | 76 ++ cmake/ffmpeg/BuildFFmpeg.cmake | 137 +++ cmake/ffmpeg/FindInstalledFFmpeg.cmake | 23 + cmake/ffmpeg/configure_ffmpeg_build.cmake | 64 ++ cmake/ffmpeg/copy_ffmpeg_headers.cmake | 8 + foleys_video_engine.h | 3 +- tests/CMakeLists.txt | 8 + tests/TestAppMain.cpp | 16 + 17 files changed, 1599 insertions(+), 4 deletions(-) create mode 100644 CMakeLists.txt create mode 100644 Makefile create mode 100644 cmake/AddCPM.cmake create mode 100644 cmake/CPM.cmake create mode 100644 cmake/FindFFmpeg.cmake create mode 100644 cmake/FindJUCE.cmake create mode 100644 cmake/FoleysDefaultSettings.cmake create mode 100644 cmake/FoleysDefaultTarget.cmake create mode 100644 cmake/ffmpeg/BuildFFmpeg.cmake create mode 100644 cmake/ffmpeg/FindInstalledFFmpeg.cmake create mode 100644 cmake/ffmpeg/configure_ffmpeg_build.cmake create mode 100644 cmake/ffmpeg/copy_ffmpeg_headers.cmake create mode 100644 tests/CMakeLists.txt create mode 100644 tests/TestAppMain.cpp diff --git a/.gitignore b/.gitignore index b3ba47ba..5bdcdd01 100755 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ **/.DS* **/Builds/ +**/Cache/ **/JuceLibraryCode/ **/!JuceLibraryCode/AppConfig.h libs/ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..87779ade --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,28 @@ +cmake_minimum_required (VERSION 3.15 FATAL_ERROR) + +project (FoleysVideoEngine VERSION 0.2.0 LANGUAGES CXX OBJC C) + + +set (CMAKE_SUPPRESS_REGENERATION TRUE) + + +list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") + +include (FoleysDefaultSettings) +include (FoleysDefaultTarget) +include (FindJUCE) +include (FindFFmpeg) + +juce_add_module ("${CMAKE_CURRENT_LIST_DIR}" ALIAS_NAMESPACE Foleys) + +target_compile_definitions (foleys_video_engine INTERFACE JUCE_USE_CAMERA=1 FOLEYS_CAMERA_SUPPORT=1 + JUCE_MODAL_LOOPS_PERMITTED=1 JUCE_STRICT_REFCOUNTEDPOINTER=1 + JUCE_PLUGINHOST_AU=1 JUCE_PLUGINHOST_VST3=1 JUCE_PLUGINHOST_LADSPA=1) + +target_link_libraries (foleys_video_engine INTERFACE Foleys::foleys_ffmpeg Foleys::FoleysDefaultTarget) + +option (FOLEYS_BUILD_TESTS "" OFF) + +if (FOLEYS_BUILD_TESTS) + add_subdirectory (tests) +endif() diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..b882300e --- /dev/null +++ b/Makefile @@ -0,0 +1,56 @@ +SHELL = /bin/sh +.ONESHELL: +.SHELLFLAGS: -euo +.DEFAULT_GOAL: help +.NOTPARALLEL: +.POSIX: + +# + +CMAKE = cmake +RM = rm -rf + +ifeq ($(OS),Windows_NT) + NUM_CORES = $(NUMBER_OF_PROCESSORS) + CMAKE_GENERATOR = Visual Studio 16 2019 +else ifeq ($(shell uname -s),Darwin) + NUM_CORES = $(shell sysctl hw.ncpu | awk '{print $$2}') + CMAKE_GENERATOR = Xcode +else + NUM_CORES = $(shell grep -c ^processor /proc/cpuinfo) + CMAKE_GENERATOR = Ninja +endif + +BUILDS = Builds +CACHE = Cache + +# + +override FOLEYS_ROOT := $(patsubst %/,%,$(strip $(dir $(realpath $(firstword $(MAKEFILE_LIST)))))) + +override THIS_MAKEFILE := $(FOLEYS_ROOT)/Makefile + +override cmake_config = cd $(FOLEYS_ROOT) && $(CMAKE) -B $(BUILDS) -G "$(CMAKE_GENERATOR)" --log-level=DEBUG + +override cmake_build_configuration = echo "Building $(1) configuration..."; $(CMAKE) --build $(BUILDS) -j $(NUM_CORES) --config $(1) + +# + +help: ## Print this message + @grep -E '^[a-zA-Z_-]+:.*?\#\# .*$$' $(THIS_MAKEFILE) | sort | awk 'BEGIN {FS = ":.*?\#\# "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' + +# + +clean: ## Removes the builds directory + cd $(FOLEYS_ROOT) && $(RM) $(BUILDS) + +wipe: clean ## Removes the builds directory and the dependencies cache + cd $(FOLEYS_ROOT) && $(RM) $(CACHE) + +# + +config_tests: ## Configure the tests + $(call cmake_config) -D FOLEYS_BUILD_TESTS=1 + +tests: config_tests ## Build the tests + @$(call cmake_build_configuration,Debug) diff --git a/ReadWrite/FFmpeg/foleys_FFmpegReader.cpp b/ReadWrite/FFmpeg/foleys_FFmpegReader.cpp index 2733a9d8..a01014ed 100644 --- a/ReadWrite/FFmpeg/foleys_FFmpegReader.cpp +++ b/ReadWrite/FFmpeg/foleys_FFmpegReader.cpp @@ -21,7 +21,7 @@ #if FOLEYS_USE_FFMPEG #include "foleys_FFmpegHelpers.h" - +#include namespace foleys { @@ -353,7 +353,7 @@ class FFmpegReader::Pimpl enum AVMediaType type, bool refCounted) { - AVCodec *decoder = nullptr; + const AVCodec *decoder = nullptr; AVDictionary *opts = nullptr; int id = av_find_best_stream (formatContext, type, -1, -1, nullptr, 0); diff --git a/cmake/AddCPM.cmake b/cmake/AddCPM.cmake new file mode 100644 index 00000000..928b5ae5 --- /dev/null +++ b/cmake/AddCPM.cmake @@ -0,0 +1,11 @@ +cmake_minimum_required (VERSION 3.15 FATAL_ERROR) + +include_guard (GLOBAL) + +if (NOT DEFINED ENV{CPM_SOURCE_CACHE}) + set (ENV{CPM_SOURCE_CACHE} "${PROJECT_SOURCE_DIR}/Cache") +endif() + +if (NOT COMMAND CPMAddPackage) + include ("${CMAKE_CURRENT_LIST_DIR}/CPM.cmake") +endif() diff --git a/cmake/CPM.cmake b/cmake/CPM.cmake new file mode 100644 index 00000000..d1237a15 --- /dev/null +++ b/cmake/CPM.cmake @@ -0,0 +1,1033 @@ +# CPM.cmake - CMake's missing package manager +# =========================================== +# See https://github.com/cpm-cmake/CPM.cmake for usage and update instructions. +# +# MIT License +# ----------- +#[[ + Copyright (c) 2019-2022 Lars Melchior and contributors + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +]] + +cmake_minimum_required(VERSION 3.14 FATAL_ERROR) + +set(CURRENT_CPM_VERSION 1.0.0-development-version) + +if(CPM_DIRECTORY) + if(NOT CPM_DIRECTORY STREQUAL CMAKE_CURRENT_LIST_DIR) + if(CPM_VERSION VERSION_LESS CURRENT_CPM_VERSION) + message( + AUTHOR_WARNING + "${CPM_INDENT} \ +A dependency is using a more recent CPM version (${CURRENT_CPM_VERSION}) than the current project (${CPM_VERSION}). \ +It is recommended to upgrade CPM to the most recent version. \ +See https://github.com/cpm-cmake/CPM.cmake for more information." + ) + endif() + if(${CMAKE_VERSION} VERSION_LESS "3.17.0") + include(FetchContent) + endif() + return() + endif() + + get_property( + CPM_INITIALIZED GLOBAL "" + PROPERTY CPM_INITIALIZED + SET + ) + if(CPM_INITIALIZED) + return() + endif() +endif() + +if(CURRENT_CPM_VERSION MATCHES "development-version") + message(WARNING "Your project is using an unstable development version of CPM.cmake. \ +Please update to a recent release if possible. \ +See https://github.com/cpm-cmake/CPM.cmake for details." + ) +endif() + +set_property(GLOBAL PROPERTY CPM_INITIALIZED true) + +option(CPM_USE_LOCAL_PACKAGES "Always try to use `find_package` to get dependencies" + $ENV{CPM_USE_LOCAL_PACKAGES} +) +option(CPM_LOCAL_PACKAGES_ONLY "Only use `find_package` to get dependencies" + $ENV{CPM_LOCAL_PACKAGES_ONLY} +) +option(CPM_DOWNLOAD_ALL "Always download dependencies from source" $ENV{CPM_DOWNLOAD_ALL}) +option(CPM_DONT_UPDATE_MODULE_PATH "Don't update the module path to allow using find_package" + $ENV{CPM_DONT_UPDATE_MODULE_PATH} +) +option(CPM_DONT_CREATE_PACKAGE_LOCK "Don't create a package lock file in the binary path" + $ENV{CPM_DONT_CREATE_PACKAGE_LOCK} +) +option(CPM_INCLUDE_ALL_IN_PACKAGE_LOCK + "Add all packages added through CPM.cmake to the package lock" + $ENV{CPM_INCLUDE_ALL_IN_PACKAGE_LOCK} +) +option(CPM_USE_NAMED_CACHE_DIRECTORIES + "Use additional directory of package name in cache on the most nested level." + $ENV{CPM_USE_NAMED_CACHE_DIRECTORIES} +) + +set(CPM_VERSION + ${CURRENT_CPM_VERSION} + CACHE INTERNAL "" +) +set(CPM_DIRECTORY + ${CMAKE_CURRENT_LIST_DIR} + CACHE INTERNAL "" +) +set(CPM_FILE + ${CMAKE_CURRENT_LIST_FILE} + CACHE INTERNAL "" +) +set(CPM_PACKAGES + "" + CACHE INTERNAL "" +) +set(CPM_DRY_RUN + OFF + CACHE INTERNAL "Don't download or configure dependencies (for testing)" +) + +if(DEFINED ENV{CPM_SOURCE_CACHE}) + set(CPM_SOURCE_CACHE_DEFAULT $ENV{CPM_SOURCE_CACHE}) +else() + set(CPM_SOURCE_CACHE_DEFAULT OFF) +endif() + +set(CPM_SOURCE_CACHE + ${CPM_SOURCE_CACHE_DEFAULT} + CACHE PATH "Directory to download CPM dependencies" +) + +if(NOT CPM_DONT_UPDATE_MODULE_PATH) + set(CPM_MODULE_PATH + "${CMAKE_BINARY_DIR}/CPM_modules" + CACHE INTERNAL "" + ) + # remove old modules + file(REMOVE_RECURSE ${CPM_MODULE_PATH}) + file(MAKE_DIRECTORY ${CPM_MODULE_PATH}) + # locally added CPM modules should override global packages + set(CMAKE_MODULE_PATH "${CPM_MODULE_PATH};${CMAKE_MODULE_PATH}") +endif() + +if(NOT CPM_DONT_CREATE_PACKAGE_LOCK) + set(CPM_PACKAGE_LOCK_FILE + "${CMAKE_BINARY_DIR}/cpm-package-lock.cmake" + CACHE INTERNAL "" + ) + file(WRITE ${CPM_PACKAGE_LOCK_FILE} + "# CPM Package Lock\n# This file should be committed to version control\n\n" + ) +endif() + +include(FetchContent) + +# Try to infer package name from git repository uri (path or url) +function(cpm_package_name_from_git_uri URI RESULT) + if("${URI}" MATCHES "([^/:]+)/?.git/?$") + set(${RESULT} + ${CMAKE_MATCH_1} + PARENT_SCOPE + ) + else() + unset(${RESULT} PARENT_SCOPE) + endif() +endfunction() + +# Try to infer package name and version from a url +function(cpm_package_name_and_ver_from_url url outName outVer) + if(url MATCHES "[/\\?]([a-zA-Z0-9_\\.-]+)\\.(tar|tar\\.gz|tar\\.bz2|zip|ZIP)(\\?|/|$)") + # We matched an archive + set(filename "${CMAKE_MATCH_1}") + + if(filename MATCHES "([a-zA-Z0-9_\\.-]+)[_-]v?(([0-9]+\\.)*[0-9]+[a-zA-Z0-9]*)") + # We matched - (ie foo-1.2.3) + set(${outName} + "${CMAKE_MATCH_1}" + PARENT_SCOPE + ) + set(${outVer} + "${CMAKE_MATCH_2}" + PARENT_SCOPE + ) + elseif(filename MATCHES "(([0-9]+\\.)+[0-9]+[a-zA-Z0-9]*)") + # We couldn't find a name, but we found a version + # + # In many cases (which we don't handle here) the url would look something like + # `irrelevant/ACTUAL_PACKAGE_NAME/irrelevant/1.2.3.zip`. In such a case we can't possibly + # distinguish the package name from the irrelevant bits. Moreover if we try to match the + # package name from the filename, we'd get bogus at best. + unset(${outName} PARENT_SCOPE) + set(${outVer} + "${CMAKE_MATCH_1}" + PARENT_SCOPE + ) + else() + # Boldly assume that the file name is the package name. + # + # Yes, something like `irrelevant/ACTUAL_NAME/irrelevant/download.zip` will ruin our day, but + # such cases should be quite rare. No popular service does this... we think. + set(${outName} + "${filename}" + PARENT_SCOPE + ) + unset(${outVer} PARENT_SCOPE) + endif() + else() + # No ideas yet what to do with non-archives + unset(${outName} PARENT_SCOPE) + unset(${outVer} PARENT_SCOPE) + endif() +endfunction() + +# Initialize logging prefix +if(NOT CPM_INDENT) + set(CPM_INDENT + "CPM:" + CACHE INTERNAL "" + ) +endif() + +function(cpm_find_package NAME VERSION) + string(REPLACE " " ";" EXTRA_ARGS "${ARGN}") + find_package(${NAME} ${VERSION} ${EXTRA_ARGS} QUIET) + if(${CPM_ARGS_NAME}_FOUND) + message(STATUS "${CPM_INDENT} using local package ${CPM_ARGS_NAME}@${VERSION}") + CPMRegisterPackage(${CPM_ARGS_NAME} "${VERSION}") + set(CPM_PACKAGE_FOUND + YES + PARENT_SCOPE + ) + else() + set(CPM_PACKAGE_FOUND + NO + PARENT_SCOPE + ) + endif() +endfunction() + +# Create a custom FindXXX.cmake module for a CPM package This prevents `find_package(NAME)` from +# finding the system library +function(cpm_create_module_file Name) + if(NOT CPM_DONT_UPDATE_MODULE_PATH) + # erase any previous modules + file(WRITE ${CPM_MODULE_PATH}/Find${Name}.cmake + "include(\"${CPM_FILE}\")\n${ARGN}\nset(${Name}_FOUND TRUE)" + ) + endif() +endfunction() + +# Find a package locally or fallback to CPMAddPackage +function(CPMFindPackage) + set(oneValueArgs NAME VERSION GIT_TAG FIND_PACKAGE_ARGUMENTS) + + cmake_parse_arguments(CPM_ARGS "" "${oneValueArgs}" "" ${ARGN}) + + if(NOT DEFINED CPM_ARGS_VERSION) + if(DEFINED CPM_ARGS_GIT_TAG) + cpm_get_version_from_git_tag("${CPM_ARGS_GIT_TAG}" CPM_ARGS_VERSION) + endif() + endif() + + set(downloadPackage ${CPM_DOWNLOAD_ALL}) + if(DEFINED CPM_DOWNLOAD_${CPM_ARGS_NAME}) + set(downloadPackage ${CPM_DOWNLOAD_${CPM_ARGS_NAME}}) + elseif(DEFINED ENV{CPM_DOWNLOAD_${CPM_ARGS_NAME}}) + set(downloadPackage $ENV{CPM_DOWNLOAD_${CPM_ARGS_NAME}}) + endif() + if(downloadPackage) + CPMAddPackage(${ARGN}) + cpm_export_variables(${CPM_ARGS_NAME}) + return() + endif() + + cpm_check_if_package_already_added(${CPM_ARGS_NAME} "${CPM_ARGS_VERSION}") + if(CPM_PACKAGE_ALREADY_ADDED) + cpm_export_variables(${CPM_ARGS_NAME}) + return() + endif() + + cpm_find_package(${CPM_ARGS_NAME} "${CPM_ARGS_VERSION}" ${CPM_ARGS_FIND_PACKAGE_ARGUMENTS}) + + if(NOT CPM_PACKAGE_FOUND) + CPMAddPackage(${ARGN}) + cpm_export_variables(${CPM_ARGS_NAME}) + endif() + +endfunction() + +# checks if a package has been added before +function(cpm_check_if_package_already_added CPM_ARGS_NAME CPM_ARGS_VERSION) + if("${CPM_ARGS_NAME}" IN_LIST CPM_PACKAGES) + CPMGetPackageVersion(${CPM_ARGS_NAME} CPM_PACKAGE_VERSION) + if("${CPM_PACKAGE_VERSION}" VERSION_LESS "${CPM_ARGS_VERSION}") + message( + WARNING + "${CPM_INDENT} requires a newer version of ${CPM_ARGS_NAME} (${CPM_ARGS_VERSION}) than currently included (${CPM_PACKAGE_VERSION})." + ) + endif() + cpm_get_fetch_properties(${CPM_ARGS_NAME}) + set(${CPM_ARGS_NAME}_ADDED NO) + set(CPM_PACKAGE_ALREADY_ADDED + YES + PARENT_SCOPE + ) + cpm_export_variables(${CPM_ARGS_NAME}) + else() + set(CPM_PACKAGE_ALREADY_ADDED + NO + PARENT_SCOPE + ) + endif() +endfunction() + +# Parse the argument of CPMAddPackage in case a single one was provided and convert it to a list of +# arguments which can then be parsed idiomatically. For example gh:foo/bar@1.2.3 will be converted +# to: GITHUB_REPOSITORY;foo/bar;VERSION;1.2.3 +function(cpm_parse_add_package_single_arg arg outArgs) + # Look for a scheme + if("${arg}" MATCHES "^([a-zA-Z]+):(.+)$") + string(TOLOWER "${CMAKE_MATCH_1}" scheme) + set(uri "${CMAKE_MATCH_2}") + + # Check for CPM-specific schemes + if(scheme STREQUAL "gh") + set(out "GITHUB_REPOSITORY;${uri}") + set(packageType "git") + elseif(scheme STREQUAL "gl") + set(out "GITLAB_REPOSITORY;${uri}") + set(packageType "git") + elseif(scheme STREQUAL "bb") + set(out "BITBUCKET_REPOSITORY;${uri}") + set(packageType "git") + # A CPM-specific scheme was not found. Looks like this is a generic URL so try to determine + # type + elseif(arg MATCHES ".git/?(@|#|$)") + set(out "GIT_REPOSITORY;${arg}") + set(packageType "git") + else() + # Fall back to a URL + set(out "URL;${arg}") + set(packageType "archive") + + # We could also check for SVN since FetchContent supports it, but SVN is so rare these days. + # We just won't bother with the additional complexity it will induce in this function. SVN is + # done by multi-arg + endif() + else() + if(arg MATCHES ".git/?(@|#|$)") + set(out "GIT_REPOSITORY;${arg}") + set(packageType "git") + else() + # Give up + message(FATAL_ERROR "CPM: Can't determine package type of '${arg}'") + endif() + endif() + + # For all packages we interpret @... as version. Only replace the last occurrence. Thus URIs + # containing '@' can be used + string(REGEX REPLACE "@([^@]+)$" ";VERSION;\\1" out "${out}") + + # Parse the rest according to package type + if(packageType STREQUAL "git") + # For git repos we interpret #... as a tag or branch or commit hash + string(REGEX REPLACE "#([^#]+)$" ";GIT_TAG;\\1" out "${out}") + elseif(packageType STREQUAL "archive") + # For archives we interpret #... as a URL hash. + string(REGEX REPLACE "#([^#]+)$" ";URL_HASH;\\1" out "${out}") + # We don't try to parse the version if it's not provided explicitly. cpm_get_version_from_url + # should do this at a later point + else() + # We should never get here. This is an assertion and hitting it means there's a bug in the code + # above. A packageType was set, but not handled by this if-else. + message(FATAL_ERROR "CPM: Unsupported package type '${packageType}' of '${arg}'") + endif() + + set(${outArgs} + ${out} + PARENT_SCOPE + ) +endfunction() + +# Check that the working directory for a git repo is clean +function(cpm_check_git_working_dir_is_clean repoPath gitTag isClean) + + find_package(Git REQUIRED) + + if(NOT GIT_EXECUTABLE) + # No git executable, assume directory is clean + set(${isClean} + TRUE + PARENT_SCOPE + ) + return() + endif() + + # check for uncommitted changes + execute_process( + COMMAND ${GIT_EXECUTABLE} status --porcelain + RESULT_VARIABLE resultGitStatus + OUTPUT_VARIABLE repoStatus + OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET + WORKING_DIRECTORY ${repoPath} + ) + if(resultGitStatus) + # not supposed to happen, assume clean anyway + message(WARNING "Calling git status on folder ${repoPath} failed") + set(${isClean} + TRUE + PARENT_SCOPE + ) + return() + endif() + + if(NOT "${repoStatus}" STREQUAL "") + set(${isClean} + FALSE + PARENT_SCOPE + ) + return() + endif() + + # check for committed changes + execute_process( + COMMAND ${GIT_EXECUTABLE} diff -s --exit-code ${gitTag} + RESULT_VARIABLE resultGitDiff + OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_QUIET + WORKING_DIRECTORY ${repoPath} + ) + + if(${resultGitDiff} EQUAL 0) + set(${isClean} + TRUE + PARENT_SCOPE + ) + else() + set(${isClean} + FALSE + PARENT_SCOPE + ) + endif() + +endfunction() + +# Download and add a package from source +function(CPMAddPackage) + list(LENGTH ARGN argnLength) + if(argnLength EQUAL 1) + cpm_parse_add_package_single_arg("${ARGN}" ARGN) + + # The shorthand syntax implies EXCLUDE_FROM_ALL + set(ARGN "${ARGN};EXCLUDE_FROM_ALL;YES") + endif() + + set(oneValueArgs + NAME + FORCE + VERSION + GIT_TAG + DOWNLOAD_ONLY + GITHUB_REPOSITORY + GITLAB_REPOSITORY + BITBUCKET_REPOSITORY + GIT_REPOSITORY + SOURCE_DIR + DOWNLOAD_COMMAND + FIND_PACKAGE_ARGUMENTS + NO_CACHE + GIT_SHALLOW + EXCLUDE_FROM_ALL + SOURCE_SUBDIR + ) + + set(multiValueArgs URL OPTIONS) + + cmake_parse_arguments(CPM_ARGS "" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}") + + # Set default values for arguments + + if(NOT DEFINED CPM_ARGS_VERSION) + if(DEFINED CPM_ARGS_GIT_TAG) + cpm_get_version_from_git_tag("${CPM_ARGS_GIT_TAG}" CPM_ARGS_VERSION) + endif() + endif() + + if(CPM_ARGS_DOWNLOAD_ONLY) + set(DOWNLOAD_ONLY ${CPM_ARGS_DOWNLOAD_ONLY}) + else() + set(DOWNLOAD_ONLY NO) + endif() + + if(DEFINED CPM_ARGS_GITHUB_REPOSITORY) + set(CPM_ARGS_GIT_REPOSITORY "https://github.com/${CPM_ARGS_GITHUB_REPOSITORY}.git") + elseif(DEFINED CPM_ARGS_GITLAB_REPOSITORY) + set(CPM_ARGS_GIT_REPOSITORY "https://gitlab.com/${CPM_ARGS_GITLAB_REPOSITORY}.git") + elseif(DEFINED CPM_ARGS_BITBUCKET_REPOSITORY) + set(CPM_ARGS_GIT_REPOSITORY "https://bitbucket.org/${CPM_ARGS_BITBUCKET_REPOSITORY}.git") + endif() + + if(DEFINED CPM_ARGS_GIT_REPOSITORY) + list(APPEND CPM_ARGS_UNPARSED_ARGUMENTS GIT_REPOSITORY ${CPM_ARGS_GIT_REPOSITORY}) + if(NOT DEFINED CPM_ARGS_GIT_TAG) + set(CPM_ARGS_GIT_TAG v${CPM_ARGS_VERSION}) + endif() + + # If a name wasn't provided, try to infer it from the git repo + if(NOT DEFINED CPM_ARGS_NAME) + cpm_package_name_from_git_uri(${CPM_ARGS_GIT_REPOSITORY} CPM_ARGS_NAME) + endif() + endif() + + set(CPM_SKIP_FETCH FALSE) + + if(DEFINED CPM_ARGS_GIT_TAG) + list(APPEND CPM_ARGS_UNPARSED_ARGUMENTS GIT_TAG ${CPM_ARGS_GIT_TAG}) + # If GIT_SHALLOW is explicitly specified, honor the value. + if(DEFINED CPM_ARGS_GIT_SHALLOW) + list(APPEND CPM_ARGS_UNPARSED_ARGUMENTS GIT_SHALLOW ${CPM_ARGS_GIT_SHALLOW}) + endif() + endif() + + if(DEFINED CPM_ARGS_URL) + # If a name or version aren't provided, try to infer them from the URL + list(GET CPM_ARGS_URL 0 firstUrl) + cpm_package_name_and_ver_from_url(${firstUrl} nameFromUrl verFromUrl) + # If we fail to obtain name and version from the first URL, we could try other URLs if any. + # However multiple URLs are expected to be quite rare, so for now we won't bother. + + # If the caller provided their own name and version, they trump the inferred ones. + if(NOT DEFINED CPM_ARGS_NAME) + set(CPM_ARGS_NAME ${nameFromUrl}) + endif() + if(NOT DEFINED CPM_ARGS_VERSION) + set(CPM_ARGS_VERSION ${verFromUrl}) + endif() + + list(APPEND CPM_ARGS_UNPARSED_ARGUMENTS URL "${CPM_ARGS_URL}") + endif() + + # Check for required arguments + + if(NOT DEFINED CPM_ARGS_NAME) + message( + FATAL_ERROR + "CPM: 'NAME' was not provided and couldn't be automatically inferred for package added with arguments: '${ARGN}'" + ) + endif() + + # Check if package has been added before + cpm_check_if_package_already_added(${CPM_ARGS_NAME} "${CPM_ARGS_VERSION}") + if(CPM_PACKAGE_ALREADY_ADDED) + cpm_export_variables(${CPM_ARGS_NAME}) + return() + endif() + + # Check for manual overrides + if(NOT CPM_ARGS_FORCE AND NOT "${CPM_${CPM_ARGS_NAME}_SOURCE}" STREQUAL "") + set(PACKAGE_SOURCE ${CPM_${CPM_ARGS_NAME}_SOURCE}) + set(CPM_${CPM_ARGS_NAME}_SOURCE "") + CPMAddPackage( + NAME "${CPM_ARGS_NAME}" + SOURCE_DIR "${PACKAGE_SOURCE}" + EXCLUDE_FROM_ALL "${CPM_ARGS_EXCLUDE_FROM_ALL}" + OPTIONS "${CPM_ARGS_OPTIONS}" + SOURCE_SUBDIR "${CPM_ARGS_SOURCE_SUBDIR}" + DOWNLOAD_ONLY "${DOWNLOAD_ONLY}" + FORCE True + ) + cpm_export_variables(${CPM_ARGS_NAME}) + return() + endif() + + # Check for available declaration + if(NOT CPM_ARGS_FORCE AND NOT "${CPM_DECLARATION_${CPM_ARGS_NAME}}" STREQUAL "") + set(declaration ${CPM_DECLARATION_${CPM_ARGS_NAME}}) + set(CPM_DECLARATION_${CPM_ARGS_NAME} "") + CPMAddPackage(${declaration}) + cpm_export_variables(${CPM_ARGS_NAME}) + # checking again to ensure version and option compatibility + cpm_check_if_package_already_added(${CPM_ARGS_NAME} "${CPM_ARGS_VERSION}") + return() + endif() + + if(CPM_USE_LOCAL_PACKAGES OR CPM_LOCAL_PACKAGES_ONLY) + cpm_find_package(${CPM_ARGS_NAME} "${CPM_ARGS_VERSION}" ${CPM_ARGS_FIND_PACKAGE_ARGUMENTS}) + + if(CPM_PACKAGE_FOUND) + cpm_export_variables(${CPM_ARGS_NAME}) + return() + endif() + + if(CPM_LOCAL_PACKAGES_ONLY) + message( + SEND_ERROR + "CPM: ${CPM_ARGS_NAME} not found via find_package(${CPM_ARGS_NAME} ${CPM_ARGS_VERSION})" + ) + endif() + endif() + + CPMRegisterPackage("${CPM_ARGS_NAME}" "${CPM_ARGS_VERSION}") + + if(DEFINED CPM_ARGS_GIT_TAG) + set(PACKAGE_INFO "${CPM_ARGS_GIT_TAG}") + elseif(DEFINED CPM_ARGS_SOURCE_DIR) + set(PACKAGE_INFO "${CPM_ARGS_SOURCE_DIR}") + else() + set(PACKAGE_INFO "${CPM_ARGS_VERSION}") + endif() + + if(DEFINED FETCHCONTENT_BASE_DIR) + # respect user's FETCHCONTENT_BASE_DIR if set + set(CPM_FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR}) + else() + set(CPM_FETCHCONTENT_BASE_DIR ${CMAKE_BINARY_DIR}/_deps) + endif() + + if(DEFINED CPM_ARGS_DOWNLOAD_COMMAND) + list(APPEND CPM_ARGS_UNPARSED_ARGUMENTS DOWNLOAD_COMMAND ${CPM_ARGS_DOWNLOAD_COMMAND}) + elseif(DEFINED CPM_ARGS_SOURCE_DIR) + list(APPEND CPM_ARGS_UNPARSED_ARGUMENTS SOURCE_DIR ${CPM_ARGS_SOURCE_DIR}) + elseif(CPM_SOURCE_CACHE AND NOT CPM_ARGS_NO_CACHE) + string(TOLOWER ${CPM_ARGS_NAME} lower_case_name) + set(origin_parameters ${CPM_ARGS_UNPARSED_ARGUMENTS}) + list(SORT origin_parameters) + if(CPM_USE_NAMED_CACHE_DIRECTORIES) + string(SHA1 origin_hash "${origin_parameters};NEW_CACHE_STRUCTURE_TAG") + set(download_directory ${CPM_SOURCE_CACHE}/${lower_case_name}/${origin_hash}/${CPM_ARGS_NAME}) + else() + string(SHA1 origin_hash "${origin_parameters}") + set(download_directory ${CPM_SOURCE_CACHE}/${lower_case_name}/${origin_hash}) + endif() + # Expand `download_directory` relative path. This is important because EXISTS doesn't work for + # relative paths. + get_filename_component(download_directory ${download_directory} ABSOLUTE) + list(APPEND CPM_ARGS_UNPARSED_ARGUMENTS SOURCE_DIR ${download_directory}) + if(EXISTS ${download_directory}) + cpm_store_fetch_properties( + ${CPM_ARGS_NAME} "${download_directory}" + "${CPM_FETCHCONTENT_BASE_DIR}/${lower_case_name}-build" + ) + cpm_get_fetch_properties("${CPM_ARGS_NAME}") + + if(DEFINED CPM_ARGS_GIT_TAG) + # warn if cache has been changed since checkout + cpm_check_git_working_dir_is_clean(${download_directory} ${CPM_ARGS_GIT_TAG} IS_CLEAN) + if(NOT ${IS_CLEAN}) + message(WARNING "Cache for ${CPM_ARGS_NAME} (${download_directory}) is dirty") + endif() + endif() + + cpm_add_subdirectory( + "${CPM_ARGS_NAME}" "${DOWNLOAD_ONLY}" + "${${CPM_ARGS_NAME}_SOURCE_DIR}/${CPM_ARGS_SOURCE_SUBDIR}" "${${CPM_ARGS_NAME}_BINARY_DIR}" + "${CPM_ARGS_EXCLUDE_FROM_ALL}" "${CPM_ARGS_OPTIONS}" + ) + set(CPM_SKIP_FETCH TRUE) + set(PACKAGE_INFO "${PACKAGE_INFO} at ${download_directory}") + else() + # Enable shallow clone when GIT_TAG is not a commit hash. Our guess may not be accurate, but + # it should guarantee no commit hash get mis-detected. + if(NOT DEFINED CPM_ARGS_GIT_SHALLOW) + cpm_is_git_tag_commit_hash("${CPM_ARGS_GIT_TAG}" IS_HASH) + if(NOT ${IS_HASH}) + list(APPEND CPM_ARGS_UNPARSED_ARGUMENTS GIT_SHALLOW TRUE) + endif() + endif() + + # remove timestamps so CMake will re-download the dependency + file(REMOVE_RECURSE ${CPM_FETCHCONTENT_BASE_DIR}/${lower_case_name}-subbuild) + set(PACKAGE_INFO "${PACKAGE_INFO} to ${download_directory}") + endif() + endif() + + cpm_create_module_file(${CPM_ARGS_NAME} "CPMAddPackage(\"${ARGN}\")") + + if(CPM_PACKAGE_LOCK_ENABLED) + if((CPM_ARGS_VERSION AND NOT CPM_ARGS_SOURCE_DIR) OR CPM_INCLUDE_ALL_IN_PACKAGE_LOCK) + cpm_add_to_package_lock(${CPM_ARGS_NAME} "${ARGN}") + elseif(CPM_ARGS_SOURCE_DIR) + cpm_add_comment_to_package_lock(${CPM_ARGS_NAME} "local directory") + else() + cpm_add_comment_to_package_lock(${CPM_ARGS_NAME} "${ARGN}") + endif() + endif() + + message( + STATUS "${CPM_INDENT} adding package ${CPM_ARGS_NAME}@${CPM_ARGS_VERSION} (${PACKAGE_INFO})" + ) + + if(NOT CPM_SKIP_FETCH) + cpm_declare_fetch( + "${CPM_ARGS_NAME}" "${CPM_ARGS_VERSION}" "${PACKAGE_INFO}" "${CPM_ARGS_UNPARSED_ARGUMENTS}" + ) + cpm_fetch_package("${CPM_ARGS_NAME}" populated) + if(${populated}) + cpm_add_subdirectory( + "${CPM_ARGS_NAME}" "${DOWNLOAD_ONLY}" + "${${CPM_ARGS_NAME}_SOURCE_DIR}/${CPM_ARGS_SOURCE_SUBDIR}" "${${CPM_ARGS_NAME}_BINARY_DIR}" + "${CPM_ARGS_EXCLUDE_FROM_ALL}" "${CPM_ARGS_OPTIONS}" + ) + endif() + cpm_get_fetch_properties("${CPM_ARGS_NAME}") + endif() + + set(${CPM_ARGS_NAME}_ADDED YES) + cpm_export_variables("${CPM_ARGS_NAME}") +endfunction() + +# Fetch a previously declared package +macro(CPMGetPackage Name) + if(DEFINED "CPM_DECLARATION_${Name}") + CPMAddPackage(NAME ${Name}) + else() + message(SEND_ERROR "Cannot retrieve package ${Name}: no declaration available") + endif() +endmacro() + +# export variables available to the caller to the parent scope expects ${CPM_ARGS_NAME} to be set +macro(cpm_export_variables name) + set(${name}_SOURCE_DIR + "${${name}_SOURCE_DIR}" + PARENT_SCOPE + ) + set(${name}_BINARY_DIR + "${${name}_BINARY_DIR}" + PARENT_SCOPE + ) + set(${name}_ADDED + "${${name}_ADDED}" + PARENT_SCOPE + ) +endmacro() + +# declares a package, so that any call to CPMAddPackage for the package name will use these +# arguments instead. Previous declarations will not be overridden. +macro(CPMDeclarePackage Name) + if(NOT DEFINED "CPM_DECLARATION_${Name}") + set("CPM_DECLARATION_${Name}" "${ARGN}") + endif() +endmacro() + +function(cpm_add_to_package_lock Name) + if(NOT CPM_DONT_CREATE_PACKAGE_LOCK) + cpm_prettify_package_arguments(PRETTY_ARGN false ${ARGN}) + file(APPEND ${CPM_PACKAGE_LOCK_FILE} "# ${Name}\nCPMDeclarePackage(${Name}\n${PRETTY_ARGN})\n") + endif() +endfunction() + +function(cpm_add_comment_to_package_lock Name) + if(NOT CPM_DONT_CREATE_PACKAGE_LOCK) + cpm_prettify_package_arguments(PRETTY_ARGN true ${ARGN}) + file(APPEND ${CPM_PACKAGE_LOCK_FILE} + "# ${Name} (unversioned)\n# CPMDeclarePackage(${Name}\n${PRETTY_ARGN}#)\n" + ) + endif() +endfunction() + +# includes the package lock file if it exists and creates a target `cpm-update-package-lock` to +# update it +macro(CPMUsePackageLock file) + if(NOT CPM_DONT_CREATE_PACKAGE_LOCK) + get_filename_component(CPM_ABSOLUTE_PACKAGE_LOCK_PATH ${file} ABSOLUTE) + if(EXISTS ${CPM_ABSOLUTE_PACKAGE_LOCK_PATH}) + include(${CPM_ABSOLUTE_PACKAGE_LOCK_PATH}) + endif() + if(NOT TARGET cpm-update-package-lock) + add_custom_target( + cpm-update-package-lock COMMAND ${CMAKE_COMMAND} -E copy ${CPM_PACKAGE_LOCK_FILE} + ${CPM_ABSOLUTE_PACKAGE_LOCK_PATH} + ) + endif() + set(CPM_PACKAGE_LOCK_ENABLED true) + endif() +endmacro() + +# registers a package that has been added to CPM +function(CPMRegisterPackage PACKAGE VERSION) + list(APPEND CPM_PACKAGES ${PACKAGE}) + set(CPM_PACKAGES + ${CPM_PACKAGES} + CACHE INTERNAL "" + ) + set("CPM_PACKAGE_${PACKAGE}_VERSION" + ${VERSION} + CACHE INTERNAL "" + ) +endfunction() + +# retrieve the current version of the package to ${OUTPUT} +function(CPMGetPackageVersion PACKAGE OUTPUT) + set(${OUTPUT} + "${CPM_PACKAGE_${PACKAGE}_VERSION}" + PARENT_SCOPE + ) +endfunction() + +# declares a package in FetchContent_Declare +function(cpm_declare_fetch PACKAGE VERSION INFO) + if(${CPM_DRY_RUN}) + message(STATUS "${CPM_INDENT} package not declared (dry run)") + return() + endif() + + FetchContent_Declare(${PACKAGE} ${ARGN}) +endfunction() + +# returns properties for a package previously defined by cpm_declare_fetch +function(cpm_get_fetch_properties PACKAGE) + if(${CPM_DRY_RUN}) + return() + endif() + + set(${PACKAGE}_SOURCE_DIR + "${CPM_PACKAGE_${PACKAGE}_SOURCE_DIR}" + PARENT_SCOPE + ) + set(${PACKAGE}_BINARY_DIR + "${CPM_PACKAGE_${PACKAGE}_BINARY_DIR}" + PARENT_SCOPE + ) +endfunction() + +function(cpm_store_fetch_properties PACKAGE source_dir binary_dir) + if(${CPM_DRY_RUN}) + return() + endif() + + set(CPM_PACKAGE_${PACKAGE}_SOURCE_DIR + "${source_dir}" + CACHE INTERNAL "" + ) + set(CPM_PACKAGE_${PACKAGE}_BINARY_DIR + "${binary_dir}" + CACHE INTERNAL "" + ) +endfunction() + +# adds a package as a subdirectory if viable, according to provided options +function( + cpm_add_subdirectory + PACKAGE + DOWNLOAD_ONLY + SOURCE_DIR + BINARY_DIR + EXCLUDE + OPTIONS +) + if(NOT DOWNLOAD_ONLY AND EXISTS ${SOURCE_DIR}/CMakeLists.txt) + if(EXCLUDE) + set(addSubdirectoryExtraArgs EXCLUDE_FROM_ALL) + else() + set(addSubdirectoryExtraArgs "") + endif() + if(OPTIONS) + # the policy allows us to change options without caching + cmake_policy(SET CMP0077 NEW) + set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) + + # the policy allows us to change set(CACHE) without caching + if(POLICY CMP0126) + cmake_policy(SET CMP0126 NEW) + set(CMAKE_POLICY_DEFAULT_CMP0126 NEW) + endif() + + foreach(OPTION ${OPTIONS}) + cpm_parse_option("${OPTION}") + set(${OPTION_KEY} "${OPTION_VALUE}") + endforeach() + endif() + set(CPM_OLD_INDENT "${CPM_INDENT}") + set(CPM_INDENT "${CPM_INDENT} ${PACKAGE}:") + add_subdirectory(${SOURCE_DIR} ${BINARY_DIR} ${addSubdirectoryExtraArgs}) + set(CPM_INDENT "${CPM_OLD_INDENT}") + endif() +endfunction() + +# downloads a previously declared package via FetchContent and exports the variables +# `${PACKAGE}_SOURCE_DIR` and `${PACKAGE}_BINARY_DIR` to the parent scope +function(cpm_fetch_package PACKAGE populated) + set(${populated} + FALSE + PARENT_SCOPE + ) + if(${CPM_DRY_RUN}) + message(STATUS "${CPM_INDENT} package ${PACKAGE} not fetched (dry run)") + return() + endif() + + FetchContent_GetProperties(${PACKAGE}) + + string(TOLOWER "${PACKAGE}" lower_case_name) + + if(NOT ${lower_case_name}_POPULATED) + FetchContent_Populate(${PACKAGE}) + set(${populated} + TRUE + PARENT_SCOPE + ) + endif() + + cpm_store_fetch_properties( + ${CPM_ARGS_NAME} ${${lower_case_name}_SOURCE_DIR} ${${lower_case_name}_BINARY_DIR} + ) + + set(${PACKAGE}_SOURCE_DIR + ${${lower_case_name}_SOURCE_DIR} + PARENT_SCOPE + ) + set(${PACKAGE}_BINARY_DIR + ${${lower_case_name}_BINARY_DIR} + PARENT_SCOPE + ) +endfunction() + +# splits a package option +function(cpm_parse_option OPTION) + string(REGEX MATCH "^[^ ]+" OPTION_KEY "${OPTION}") + string(LENGTH "${OPTION}" OPTION_LENGTH) + string(LENGTH "${OPTION_KEY}" OPTION_KEY_LENGTH) + if(OPTION_KEY_LENGTH STREQUAL OPTION_LENGTH) + # no value for key provided, assume user wants to set option to "ON" + set(OPTION_VALUE "ON") + else() + math(EXPR OPTION_KEY_LENGTH "${OPTION_KEY_LENGTH}+1") + string(SUBSTRING "${OPTION}" "${OPTION_KEY_LENGTH}" "-1" OPTION_VALUE) + endif() + set(OPTION_KEY + "${OPTION_KEY}" + PARENT_SCOPE + ) + set(OPTION_VALUE + "${OPTION_VALUE}" + PARENT_SCOPE + ) +endfunction() + +# guesses the package version from a git tag +function(cpm_get_version_from_git_tag GIT_TAG RESULT) + string(LENGTH ${GIT_TAG} length) + if(length EQUAL 40) + # GIT_TAG is probably a git hash + set(${RESULT} + 0 + PARENT_SCOPE + ) + else() + string(REGEX MATCH "v?([0123456789.]*).*" _ ${GIT_TAG}) + set(${RESULT} + ${CMAKE_MATCH_1} + PARENT_SCOPE + ) + endif() +endfunction() + +# guesses if the git tag is a commit hash or an actual tag or a branch name. +function(cpm_is_git_tag_commit_hash GIT_TAG RESULT) + string(LENGTH "${GIT_TAG}" length) + # full hash has 40 characters, and short hash has at least 7 characters. + if(length LESS 7 OR length GREATER 40) + set(${RESULT} + 0 + PARENT_SCOPE + ) + else() + if(${GIT_TAG} MATCHES "^[a-fA-F0-9]+$") + set(${RESULT} + 1 + PARENT_SCOPE + ) + else() + set(${RESULT} + 0 + PARENT_SCOPE + ) + endif() + endif() +endfunction() + +function(cpm_prettify_package_arguments OUT_VAR IS_IN_COMMENT) + set(oneValueArgs + NAME + FORCE + VERSION + GIT_TAG + DOWNLOAD_ONLY + GITHUB_REPOSITORY + GITLAB_REPOSITORY + GIT_REPOSITORY + SOURCE_DIR + DOWNLOAD_COMMAND + FIND_PACKAGE_ARGUMENTS + NO_CACHE + GIT_SHALLOW + ) + set(multiValueArgs OPTIONS) + cmake_parse_arguments(CPM_ARGS "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + foreach(oneArgName ${oneValueArgs}) + if(DEFINED CPM_ARGS_${oneArgName}) + if(${IS_IN_COMMENT}) + string(APPEND PRETTY_OUT_VAR "#") + endif() + if(${oneArgName} STREQUAL "SOURCE_DIR") + string(REPLACE ${CMAKE_SOURCE_DIR} "\${CMAKE_SOURCE_DIR}" CPM_ARGS_${oneArgName} + ${CPM_ARGS_${oneArgName}} + ) + endif() + string(APPEND PRETTY_OUT_VAR " ${oneArgName} ${CPM_ARGS_${oneArgName}}\n") + endif() + endforeach() + foreach(multiArgName ${multiValueArgs}) + if(DEFINED CPM_ARGS_${multiArgName}) + if(${IS_IN_COMMENT}) + string(APPEND PRETTY_OUT_VAR "#") + endif() + string(APPEND PRETTY_OUT_VAR " ${multiArgName}\n") + foreach(singleOption ${CPM_ARGS_${multiArgName}}) + if(${IS_IN_COMMENT}) + string(APPEND PRETTY_OUT_VAR "#") + endif() + string(APPEND PRETTY_OUT_VAR " \"${singleOption}\"\n") + endforeach() + endif() + endforeach() + + if(NOT "${CPM_ARGS_UNPARSED_ARGUMENTS}" STREQUAL "") + if(${IS_IN_COMMENT}) + string(APPEND PRETTY_OUT_VAR "#") + endif() + string(APPEND PRETTY_OUT_VAR " ") + foreach(CPM_ARGS_UNPARSED_ARGUMENT ${CPM_ARGS_UNPARSED_ARGUMENTS}) + string(APPEND PRETTY_OUT_VAR " ${CPM_ARGS_UNPARSED_ARGUMENT}") + endforeach() + string(APPEND PRETTY_OUT_VAR "\n") + endif() + + set(${OUT_VAR} + ${PRETTY_OUT_VAR} + PARENT_SCOPE + ) + +endfunction() \ No newline at end of file diff --git a/cmake/FindFFmpeg.cmake b/cmake/FindFFmpeg.cmake new file mode 100644 index 00000000..da6a65db --- /dev/null +++ b/cmake/FindFFmpeg.cmake @@ -0,0 +1,30 @@ +cmake_minimum_required (VERSION 3.15 FATAL_ERROR) + +include_guard (GLOBAL) + +set (foleys_ffmpeg_libs avutil swresample avcodec avformat swscale CACHE INTERNAL "") + +option (FOLEYS_USE_SYSTEM_FFMPEG "Use preinstalled ffmpeg found on system, if any" OFF) + +if (FOLEYS_USE_SYSTEM_FFMPEG) + include ("${CMAKE_CURRENT_LIST_DIR}/ffmpeg/FindInstalledFFmpeg.cmake") +endif() + +if (NOT TARGET foleys_ffmpeg) + include ("${CMAKE_CURRENT_LIST_DIR}/ffmpeg/BuildFFmpeg.cmake") +endif() + +if (NOT TARGET foleys_ffmpeg) + message (FATAL_ERROR "Error creating foleys_ffmpeg target!") +endif() + +# customXcodeResourceFolders + +# extra def FFMPEG_ROOT=... + +# linux: compile flag -I${FFMPEG_ROOT}/include +# linux: linker flag -L${FFMPEG_ROOT}/lib + +target_compile_definitions (foleys_ffmpeg INTERFACE FOLEYS_USE_FFMPEG=1) + +add_library (Foleys::foleys_ffmpeg ALIAS foleys_ffmpeg) diff --git a/cmake/FindJUCE.cmake b/cmake/FindJUCE.cmake new file mode 100644 index 00000000..0990edf9 --- /dev/null +++ b/cmake/FindJUCE.cmake @@ -0,0 +1,11 @@ +cmake_minimum_required (VERSION 3.15 FATAL_ERROR) + +include_guard (GLOBAL) + +include ("${CMAKE_CURRENT_LIST_DIR}/AddCPM.cmake") + +CPMAddPackage (NAME JUCE + GITHUB_REPOSITORY juce-framework/JUCE + GIT_TAG origin/develop + OPTIONS "JUCE_BUILD_EXAMPLES OFF" "JUCE_BUILD_EXTRAS OFF" "JUCE_ENABLE_MODULE_SOURCE_GROUPS ON") + diff --git a/cmake/FoleysDefaultSettings.cmake b/cmake/FoleysDefaultSettings.cmake new file mode 100644 index 00000000..e583945c --- /dev/null +++ b/cmake/FoleysDefaultSettings.cmake @@ -0,0 +1,94 @@ +cmake_minimum_required (VERSION 3.15 FATAL_ERROR) + +include_guard (GLOBAL) + +set_property (GLOBAL PROPERTY USE_FOLDERS YES) + +set (ENV{CMAKE_EXPORT_COMPILE_COMMANDS} TRUE) +set (CMAKE_EXPORT_COMPILE_COMMANDS TRUE CACHE INTERNAL "") + +if (NOT DEFINED ENV{CMAKE_INSTALL_MODE}) + set (ENV{CMAKE_INSTALL_MODE} ABS_SYMLINK_OR_COPY) +endif() + +include (CheckIPOSupported) + +check_ipo_supported (RESULT result OUTPUT output) + +if(result) + set (ENV{CMAKE_INTERPROCEDURAL_OPTIMIZATION} ON) + set (CMAKE_INTERPROCEDURAL_OPTIMIZATION ON CACHE INTERNAL "") + message (VERBOSE "Enabling IPO") +endif() + + +# platform settings + +if(APPLE) + if(IOS) + set (ENV{MACOSX_DEPLOYMENT_TARGET} 9.3) + set (CMAKE_OSX_DEPLOYMENT_TARGET "9.3" CACHE INTERNAL "") + + set (CMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH NO CACHE INTERNAL "") + + option (FOLEYS_IOS_SIMULATOR "Build for an iOS simulator, rather than a real device" ON) + + if(FOLEYS_IOS_SIMULATOR) + set (CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "\"iPhone Developer\"" CACHE INTERNAL "") + + set (IOS_PLATFORM_LOCATION "iPhoneSimulator.platform" CACHE INTERNAL "") + set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphonesimulator" CACHE INTERNAL "") + + set (ENV{CMAKE_OSX_ARCHITECTURES} "i386;x86_64") + set (CMAKE_OSX_ARCHITECTURES "i386;x86_64" CACHE INTERNAL "") + + else() # Options for building for a real device + + set (CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM "" CACHE STRING "") + + set (IOS_PLATFORM_LOCATION "iPhoneOS.platform" CACHE INTERNAL "") + set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos" CACHE INTERNAL "") + + set (ENV{CMAKE_OSX_ARCHITECTURES} "armv7;armv7s;arm64;i386;x86_64") + set (CMAKE_OSX_ARCHITECTURES "armv7;armv7s;arm64;i386;x86_64" CACHE INTERNAL "") + + endif() + else() + set (ENV{MACOSX_DEPLOYMENT_TARGET} 10.11) + set (CMAKE_OSX_DEPLOYMENT_TARGET "10.11" CACHE INTERNAL "") + + set (FOLEYS_MAC_SDK_VERSION "10.13" CACHE STRING "") + mark_as_advanced (FOLEYS_MAC_SDK_VERSION FORCE) + + set ( + MAC_SDK_DIR + "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${FOLEYS_MAC_SDK_VERSION}.sdk" + ) + + if(IS_DIRECTORY ${MAC_SDK_DIR}) + set (CMAKE_OSX_SYSROOT ${MAC_SDK_DIR} CACHE INTERNAL "") + else() + message (DEBUG "Mac SDK dir ${MAC_SDK_DIR} doesn't exist!") + endif() + + option (FOLEYS_MAC_UNIVERSAL_BINARY "Builds for x86_64 and arm64" ON) + + if(FOLEYS_MAC_UNIVERSAL_BINARY) + set (ENV{CMAKE_OSX_ARCHITECTURES} "x86_64;arm64") + set (CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE INTERNAL "") + endif() + endif() +else() + set (CMAKE_INSTALL_RPATH $ORIGIN CACHE INTERNAL "") + + if(WIN32) + set (CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" CACHE INTERNAL "") + else() + # fixes a bug with LTO on Ubuntu with Clang + set (CMAKE_AR ${CMAKE_CXX_COMPILER_AR} CACHE PATH "AR" FORCE) + set (CMAKE_RANLIB ${CMAKE_CXX_COMPILER_RANLIB} CACHE PATH "RANLIB" FORCE) + + mark_as_advanced (CMAKE_AR CMAKE_RANLIB FORCE) + endif() +endif() + diff --git a/cmake/FoleysDefaultTarget.cmake b/cmake/FoleysDefaultTarget.cmake new file mode 100644 index 00000000..df1a2125 --- /dev/null +++ b/cmake/FoleysDefaultTarget.cmake @@ -0,0 +1,76 @@ +cmake_minimum_required (VERSION 3.15 FATAL_ERROR) + +include_guard (GLOBAL) + +include (FoleysDefaultSettings) + +add_library (FoleysDefaultTarget INTERFACE) + +set_target_properties (FoleysDefaultTarget PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON) + +target_compile_features (FoleysDefaultTarget INTERFACE cxx_std_17) + +if((CMAKE_CXX_COMPILER_ID MATCHES "MSVC") OR (CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES "MSVC")) + + # config flags + target_compile_options ( + FoleysDefaultTarget INTERFACE $,/Od /Zi,/Ox> + $<$:/MP> /EHsc) + + # LTO + target_compile_options ( + FoleysDefaultTarget + INTERFACE $<$:$,-GL,-flto>> + ) + + target_link_libraries ( + FoleysDefaultTarget + INTERFACE $<$:$<$:-LTCG>>) + +elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang|GNU") + + # config flags + target_compile_options (FoleysDefaultTarget INTERFACE $<$:-g -O0> + $<$:-O3>) + + # LTO + if(NOT MINGW) + target_compile_options (FoleysDefaultTarget INTERFACE $<$:-flto>) + target_link_libraries (FoleysDefaultTarget INTERFACE $<$:-flto>) + endif() + +endif() + + +# MacOS options + +option (FOLEYS_MAC_UNIVERSAL_BINARY "Builds for x86_64 and arm64" ON) + +if(APPLE) + + set_target_properties (FoleysDefaultTarget PROPERTIES XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME YES) + target_compile_definitions (FoleysDefaultTarget INTERFACE JUCE_USE_VDSP_FRAMEWORK=1) + + if(IOS) + set_target_properties (FoleysDefaultTarget PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY "./" + XCODE_ATTRIBUTE_INSTALL_PATH "$(LOCAL_APPS_DIR)" + XCODE_ATTRIBUTE_SKIP_INSTALL "NO" + XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH "NO" + XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET "9.3") + + target_compile_options (FoleysDefaultTarget INTERFACE "-mmacosx-version-min=9.3") + target_link_options (FoleysDefaultTarget INTERFACE "-mmacosx-version-min=9.3") + else() + set_target_properties (FoleysDefaultTarget PROPERTIES XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET "10.11") + + target_compile_options (FoleysDefaultTarget INTERFACE "-mmacosx-version-min=10.11") + target_link_options (FoleysDefaultTarget INTERFACE "-mmacosx-version-min=10.11") + + if (FOLEYS_MAC_UNIVERSAL_BINARY) + set_target_properties (FoleysDefaultTarget PROPERTIES OSX_ARCHITECTURES "x86_64;arm64") + endif() + endif() +endif() + +add_library (Foleys::FoleysDefaultTarget ALIAS FoleysDefaultTarget) diff --git a/cmake/ffmpeg/BuildFFmpeg.cmake b/cmake/ffmpeg/BuildFFmpeg.cmake new file mode 100644 index 00000000..fac18287 --- /dev/null +++ b/cmake/ffmpeg/BuildFFmpeg.cmake @@ -0,0 +1,137 @@ +cmake_minimum_required (VERSION 3.15 FATAL_ERROR) + +include_guard (GLOBAL) + +set (FFMPEG_CONFIGURE_EXTRAS "") +set (FFMPEG_EXTRA_C_FLAGS "") +set (FFMPEG_EXTRA_LD_FLAGS "") + +# + +set (FFMPEG_VERSION 4.4.1) +set (FFMPEG_NAME "ffmpeg-${FFMPEG_VERSION}") +set (FFMPEG_URL "https://ffmpeg.org/releases/${FFMPEG_NAME}.tar.bz2") + +if (DEFINED ENV{CPM_SOURCE_CACHE}) + set (FOLEYS_SOURCE_CACHE "$ENV{CPM_SOURCE_CACHE}") +else() + set (FOLEYS_SOURCE_CACHE "${PROJECT_SOURCE_DIR}/Cache") +endif() + +set (FFMPEG_SOURCE_DIR "${FOLEYS_SOURCE_CACHE}/${FFMPEG_NAME}") + +set (FFMPEG_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/ffmpeg") + +# + +if (NOT EXISTS "${FFMPEG_SOURCE_DIR}") + + message (STATUS "Downloading FFmpeg sources from ${FFMPEG_URL} to ${FFMPEG_SOURCE_DIR}...") + + get_filename_component (FFMPEG_ARCHIVE_NAME "${FFMPEG_URL}" NAME) + + set (ffmpeg_tarball "${FOLEYS_SOURCE_CACHE}/${FFMPEG_ARCHIVE_NAME}") + + file (DOWNLOAD "${FFMPEG_URL}" "${ffmpeg_tarball}") + + execute_process (COMMAND ${CMAKE_COMMAND} -E tar xzf "${ffmpeg_tarball}" + WORKING_DIRECTORY "${FOLEYS_SOURCE_CACHE}") + + file (REMOVE "${ffmpeg_tarball}") + +endif() + +# + +set (FFMPEG_CC "${CMAKE_C_COMPILER}") + +#set (FFMPEG_C_FLAGS "${CMAKE_C_FLAGS} --target=${ANDROID_LLVM_TRIPLE} --gcc-toolchain=${ANDROID_TOOLCHAIN_ROOT} ${FFMPEG_EXTRA_C_FLAGS}") + +string (REPLACE " -Wl,--fatal-warnings" "" FFMPEG_LD_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") +set (FFMPEG_LD_FLAGS "${FFMPEG_C_FLAGS} ${FFMPEG_LD_FLAGS} ${FFMPEG_EXTRA_LD_FLAGS}") + +#set (FFMPEG_AR "${ANDROID_AR}") +#set (FFMPEG_AS "${ANDROID_ASM_COMPILER}") +#set (FFMPEG_RANLIB "${ANDROID_TOOLCHAIN_PREFIX}ranlib${ANDROID_TOOLCHAIN_SUFFIX}") +#set (FFMPEG_STRIP "${ANDROID_TOOLCHAIN_ROOT}/bin/llvm-strip${ANDROID_TOOLCHAIN_SUFFIX}") +#set (FFMPEG_NM "${ANDROID_TOOLCHAIN_PREFIX}nm${ANDROID_TOOLCHAIN_SUFFIX}") + +#set (HOST_BIN "${ANDROID_NDK}/prebuilt/${ANDROID_HOST_TAG}/bin") + +if ("${CMAKE_ANDROID_ARCH_ABI}" STREQUAL x86) + list (APPEND FFMPEG_CONFIGURE_EXTRAS --disable-asm) +endif() + +string (REPLACE ";" "|" FFMPEG_CONFIGURE_EXTRAS_ENCODED "${FFMPEG_CONFIGURE_EXTRAS}") + +# + +# +# CMAKE_SYSTEM_PROCESSOR + +## FFMPEG_ASM_FLAGS ? + +include (ExternalProject) + +configure_file ("${CMAKE_CURRENT_LIST_DIR}/configure_ffmpeg_build.cmake" configure_ffmpeg_build.cmake @ONLY) + +ExternalProject_Add (ffmpeg_build + PREFIX ffmpeg_pref + URL "${FFMPEG_SOURCE_DIR}" + DOWNLOAD_NO_EXTRACT 1 + CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env PATH=${ANDROID_TOOLCHAIN_ROOT}/bin:$ENV{PATH} + ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/configure_ffmpeg_build.cmake" + BUILD_COMMAND ${CMAKE_COMMAND} -E env PATH=${ANDROID_TOOLCHAIN_ROOT}/bin:$ENV{PATH} + make -j4 + #${HOST_BIN}/make -j4 + BUILD_IN_SOURCE 1 + INSTALL_COMMAND ${CMAKE_COMMAND} -E env PATH=${ANDROID_TOOLCHAIN_ROOT}/bin:$ENV{PATH} + make install + #${HOST_BIN}/make install + STEP_TARGETS ffmpeg_copy_headers + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 +) + +ExternalProject_Get_Property (ffmpeg_build SOURCE_DIR) + +configure_file ("${CMAKE_CURRENT_LIST_DIR}/copy_ffmpeg_headers.cmake" copy_ffmpeg_headers.cmake @ONLY) + +ExternalProject_Add_Step ( + ffmpeg_build + ffmpeg_copy_headers + COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/copy_ffmpeg_headers.cmake" + DEPENDEES build + DEPENDERS install +) + +# + +add_library (foleys_ffmpeg INTERFACE) + +ExternalProject_Get_Property (ffmpeg_build INSTALL_DIR) + +foreach (ffmpeg_lib IN LISTS foleys_ffmpeg_libs) + + add_library (Foleys::${ffmpeg_lib} SHARED IMPORTED) + + add_dependencies (Foleys::${ffmpeg_lib} ffmpeg_build) + + set_target_properties (Foleys::${ffmpeg_lib} PROPERTIES IMPORTED_LOCATION "${INSTALL_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}${ffmpeg_lib}.${CMAKE_SHARED_LIBRARY_SUFFIX}") + + target_link_libraries (foleys_ffmpeg INTERFACE Foleys::${ffmpeg_lib}) + +endforeach() + +# + +#target_sources (foleys_ffmpeg PRIVATE ${ffmpeg_src}) + +add_dependencies (foleys_ffmpeg ffmpeg_build) + +#target_link_libraries (foleys_ffmpeg PRIVATE ${foleys_ffmpeg_libs}) + +target_link_directories (foleys_ffmpeg INTERFACE "${FFMPEG_OUTPUT_DIR}" "${INSTALL_DIR}") + +target_include_directories (foleys_ffmpeg INTERFACE "${FFMPEG_OUTPUT_DIR}/include") diff --git a/cmake/ffmpeg/FindInstalledFFmpeg.cmake b/cmake/ffmpeg/FindInstalledFFmpeg.cmake new file mode 100644 index 00000000..9dedc4da --- /dev/null +++ b/cmake/ffmpeg/FindInstalledFFmpeg.cmake @@ -0,0 +1,23 @@ +cmake_minimum_required (VERSION 3.15 FATAL_ERROR) + +include_guard (GLOBAL) + +find_package (PkgConfig) + +if (NOT PkgConfig_FOUND) + return() +endif() + +list (TRANSFORM foleys_ffmpeg_libs + PREPEND lib + OUTPUT_VARIABLE libav_libs) + +pkg_check_modules (LIBAV IMPORTED_TARGET ${libav_libs}) + +if (NOT LIBAV_FOUND) + return() +endif() + +add_library (foleys_ffmpeg INTERFACE) + +target_link_libraries (foleys_ffmpeg INTERFACE PkgConfig::LIBAV) diff --git a/cmake/ffmpeg/configure_ffmpeg_build.cmake b/cmake/ffmpeg/configure_ffmpeg_build.cmake new file mode 100644 index 00000000..fe40f1ed --- /dev/null +++ b/cmake/ffmpeg/configure_ffmpeg_build.cmake @@ -0,0 +1,64 @@ +cmake_minimum_required (VERSION 3.15 FATAL_ERROR) + +string (REPLACE "|" ";" CONFIGURE_EXTRAS_ENCODED "@FFMPEG_CONFIGURE_EXTRAS_ENCODED@") +list (REMOVE_ITEM CONFIGURE_EXTRAS_ENCODED "") + +set (CONFIGURE_COMMAND + ./configure + #--cc=@FFMPEG_CC@ + #--ar=@FFMPEG_AR@ + #--strip=@FFMPEG_STRIP@ + #--ranlib=@FFMPEG_RANLIB@ + #--as=@FFMPEG_AS@ + #--nm=@FFMPEG_NM@ + #--arch=@CMAKE_SYSTEM_PROCESSOR@ + --disable-static + --enable-shared + --enable-protocol=file + --shlibdir=@FFMPEG_OUTPUT_DIR@ + --prefix=@FFMPEG_OUTPUT_DIR@ + ${CONFIGURE_EXTRAS_ENCODED} +) + +if ("@CMAKE_SYSROOT@") + set (CONFIGURE_COMMAND "${CONFIGURE_COMMAND} --sysroot=@CMAKE_SYSROOT@") +endif() + +if ("@FFMPEG_C_FLAGS@") + set (CONFIGURE_COMMAND "${CONFIGURE_COMMAND} --extra-cflags=@FFMPEG_C_FLAGS@") +endif() + +if ("@FFMPEG_LD_FLAGS@") + set (CONFIGURE_COMMAND "${CONFIGURE_COMMAND} --extra-ldflags=@FFMPEG_LD_FLAGS@") +endif() + +if ("@IOS@" OR "@ANDROID@") + + set (CONFIGURE_COMMAND + ${CONFIGURE_COMMAND} + --enable-cross-compile + --disable-programs + --disable-doc + --enable-pic + ) +endif() + +if ("@IOS@") + + set (CONFIGURE_COMMAND + ${CONFIGURE_COMMAND} + --target-os=darwin) + +elseif ("@ANDROID@") + + set (CONFIGURE_COMMAND + ${CONFIGURE_COMMAND} + --target-os=android) + +endif() + + +execute_process (COMMAND ${CONFIGURE_COMMAND} + WORKING_DIRECTORY @FFMPEG_SOURCE_DIR@ + COMMAND_ECHO STDOUT + COMMAND_ERROR_IS_FATAL ANY) diff --git a/cmake/ffmpeg/copy_ffmpeg_headers.cmake b/cmake/ffmpeg/copy_ffmpeg_headers.cmake new file mode 100644 index 00000000..a5d696a8 --- /dev/null +++ b/cmake/ffmpeg/copy_ffmpeg_headers.cmake @@ -0,0 +1,8 @@ +cmake_minimum_required (VERSION 3.15 FATAL_ERROR) + +file (GLOB libs "@FFMPEG_SOURCE_DIR@/lib*") + +file (COPY ${libs} @SOURCE_DIR@/config.h @FFMPEG_SOURCE_DIR@/compat + DESTINATION @FFMPEG_OUTPUT_DIR@/include + FILES_MATCHING PATTERN *.h +) diff --git a/foleys_video_engine.h b/foleys_video_engine.h index 3e306d09..2cf1b49d 100644 --- a/foleys_video_engine.h +++ b/foleys_video_engine.h @@ -25,8 +25,7 @@ name: Video engine to read, process, display and write video in JUCE description: Provides classes to read audio streams from video files or to mux audio into an existing video - dependencies: juce_audio_basics juce_audio_formats juce_gui_basics - juce_graphics juce_core juce_audio_utils + dependencies: juce_audio_basics juce_audio_devices juce_audio_formats juce_gui_basics juce_graphics juce_core juce_audio_utils juce_audio_processors minimumCppStandard: 17 website: https://foleysfinest.com/ diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 00000000..a69c23d4 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,8 @@ +set (CMAKE_SUPPRESS_REGENERATION TRUE) + +# juce_add_plugin (PluginTest) +# target_link_libraries (PluginTest PRIVATE Foleys::foleys_video_engine) + +juce_add_gui_app (AppTest) +target_link_libraries (AppTest PRIVATE Foleys::foleys_video_engine) +target_sources (AppTest PRIVATE TestAppMain.cpp) diff --git a/tests/TestAppMain.cpp b/tests/TestAppMain.cpp new file mode 100644 index 00000000..ed30a9fc --- /dev/null +++ b/tests/TestAppMain.cpp @@ -0,0 +1,16 @@ +#include + +using juce::String; + +struct FoleysVideoTest final : public juce::JUCEApplication +{ + const String getApplicationName() final { return "Foleys video engine test"; } + + const String getApplicationVersion() final { return "0.0.1"; } + + void initialise (const String&) final { } + + void shutdown() const final { } +}; + +START_JUCE_APPLICATION (FoleysVideoTest) From aeb09387e59bafce970479aeda796256969765b2 Mon Sep 17 00:00:00 2001 From: Ben Vining Date: Tue, 1 Mar 2022 00:19:03 -0600 Subject: [PATCH 12/44] fixing issue with directory structure; refactoring cmake --- CMakeLists.txt | 5 +- Makefile | 8 ++- cmake/FindFFmpeg.cmake | 9 ++-- cmake/FoleysDefaultTarget.cmake | 22 ++++++--- cmake/ffmpeg/BuildFFmpeg.cmake | 49 +++++++++++-------- cmake/ffmpeg/configure_ffmpeg_build.cmake | 1 + .../Basics}/foleys_AudioFifo.cpp | 0 .../Basics}/foleys_AudioFifo.h | 0 .../Basics}/foleys_Structures.h | 0 .../Basics}/foleys_TimeCodeAware.cpp | 0 .../Basics}/foleys_TimeCodeAware.h | 0 .../Basics}/foleys_Usage.cpp | 0 .../Basics}/foleys_Usage.h | 0 .../Basics}/foleys_VideoEngine.cpp | 0 .../Basics}/foleys_VideoEngine.h | 0 .../Basics}/foleys_VideoFifo.cpp | 0 .../Basics}/foleys_VideoFifo.h | 0 .../Basics}/foleys_VideoFrame.h | 0 .../Clips}/foleys_AVClip.cpp | 0 .../Clips}/foleys_AVClip.h | 0 .../Clips}/foleys_AudioClip.cpp | 0 .../Clips}/foleys_AudioClip.h | 0 .../Clips}/foleys_ClipDescriptor.cpp | 0 .../Clips}/foleys_ClipDescriptor.h | 0 .../Clips}/foleys_ComposedClip.cpp | 0 .../Clips}/foleys_ComposedClip.h | 0 .../Clips}/foleys_ImageClip.cpp | 0 .../Clips}/foleys_ImageClip.h | 0 .../Clips}/foleys_MovieClip.cpp | 0 .../Clips}/foleys_MovieClip.h | 0 .../Plugins}/foleys_AudioPluginManager.cpp | 0 .../Plugins}/foleys_AudioPluginManager.h | 0 .../foleys_ColourCurveVideoProcessor.h | 0 .../Plugins}/foleys_VideoPluginManager.cpp | 0 .../Plugins}/foleys_VideoPluginManager.h | 0 .../Plugins}/foleys_VideoProcessor.h | 0 .../Processing}/foleys_AudioMixer.h | 0 .../Processing}/foleys_ColourLookuptables.h | 0 .../Processing}/foleys_ControllableBase.cpp | 0 .../Processing}/foleys_ControllableBase.h | 0 .../Processing}/foleys_DefaultAudioMixer.cpp | 0 .../Processing}/foleys_DefaultAudioMixer.h | 0 .../foleys_ParameterAutomation.cpp | 0 .../Processing}/foleys_ParameterAutomation.h | 0 .../foleys_ProcessorController.cpp | 0 .../Processing}/foleys_ProcessorController.h | 0 .../Processing}/foleys_ProcessorParameter.cpp | 0 .../Processing}/foleys_ProcessorParameter.h | 0 .../Processing}/foleys_SoftwareVideoMixer.cpp | 0 .../Processing}/foleys_SoftwareVideoMixer.h | 0 .../Processing}/foleys_VideoMixer.h | 0 .../ReadWrite}/FFmpeg/foleys_FFmpegFormat.cpp | 0 .../ReadWrite}/FFmpeg/foleys_FFmpegFormat.h | 0 .../ReadWrite}/FFmpeg/foleys_FFmpegHelpers.h | 0 .../ReadWrite}/FFmpeg/foleys_FFmpegReader.cpp | 0 .../ReadWrite}/FFmpeg/foleys_FFmpegReader.h | 0 .../ReadWrite}/FFmpeg/foleys_FFmpegWriter.cpp | 0 .../ReadWrite}/FFmpeg/foleys_FFmpegWriter.h | 0 .../ReadWrite}/foleys_AVFormatManager.cpp | 0 .../ReadWrite}/foleys_AVFormatManager.h | 0 .../ReadWrite}/foleys_AVReader.h | 0 .../ReadWrite}/foleys_AVWriter.h | 0 .../ReadWrite}/foleys_ClipRenderer.cpp | 0 .../ReadWrite}/foleys_ClipRenderer.h | 0 .../Widgets}/foleys_AudioStrip.cpp | 0 .../Widgets}/foleys_AudioStrip.h | 0 .../Widgets}/foleys_FilmStrip.cpp | 0 .../Widgets}/foleys_FilmStrip.h | 0 .../Widgets}/foleys_OpenGLDraw.h | 44 ++++++++--------- .../Widgets}/foleys_OpenGLView.cpp | 6 +-- .../Widgets}/foleys_OpenGLView.h | 0 .../Widgets}/foleys_SoftwareView.cpp | 0 .../Widgets}/foleys_SoftwareView.h | 0 .../Widgets}/foleys_VideoView.h | 0 .../foleys_video_engine.cpp | 0 .../foleys_video_engine.h | 0 tests/CMakeLists.txt | 2 +- 77 files changed, 83 insertions(+), 63 deletions(-) rename {Basics => foleys_video_engine/Basics}/foleys_AudioFifo.cpp (100%) rename {Basics => foleys_video_engine/Basics}/foleys_AudioFifo.h (100%) rename {Basics => foleys_video_engine/Basics}/foleys_Structures.h (100%) rename {Basics => foleys_video_engine/Basics}/foleys_TimeCodeAware.cpp (100%) rename {Basics => foleys_video_engine/Basics}/foleys_TimeCodeAware.h (100%) rename {Basics => foleys_video_engine/Basics}/foleys_Usage.cpp (100%) rename {Basics => foleys_video_engine/Basics}/foleys_Usage.h (100%) rename {Basics => foleys_video_engine/Basics}/foleys_VideoEngine.cpp (100%) rename {Basics => foleys_video_engine/Basics}/foleys_VideoEngine.h (100%) rename {Basics => foleys_video_engine/Basics}/foleys_VideoFifo.cpp (100%) rename {Basics => foleys_video_engine/Basics}/foleys_VideoFifo.h (100%) rename {Basics => foleys_video_engine/Basics}/foleys_VideoFrame.h (100%) rename {Clips => foleys_video_engine/Clips}/foleys_AVClip.cpp (100%) rename {Clips => foleys_video_engine/Clips}/foleys_AVClip.h (100%) rename {Clips => foleys_video_engine/Clips}/foleys_AudioClip.cpp (100%) rename {Clips => foleys_video_engine/Clips}/foleys_AudioClip.h (100%) rename {Clips => foleys_video_engine/Clips}/foleys_ClipDescriptor.cpp (100%) rename {Clips => foleys_video_engine/Clips}/foleys_ClipDescriptor.h (100%) rename {Clips => foleys_video_engine/Clips}/foleys_ComposedClip.cpp (100%) rename {Clips => foleys_video_engine/Clips}/foleys_ComposedClip.h (100%) rename {Clips => foleys_video_engine/Clips}/foleys_ImageClip.cpp (100%) rename {Clips => foleys_video_engine/Clips}/foleys_ImageClip.h (100%) rename {Clips => foleys_video_engine/Clips}/foleys_MovieClip.cpp (100%) rename {Clips => foleys_video_engine/Clips}/foleys_MovieClip.h (100%) rename {Plugins => foleys_video_engine/Plugins}/foleys_AudioPluginManager.cpp (100%) rename {Plugins => foleys_video_engine/Plugins}/foleys_AudioPluginManager.h (100%) rename {Plugins => foleys_video_engine/Plugins}/foleys_ColourCurveVideoProcessor.h (100%) rename {Plugins => foleys_video_engine/Plugins}/foleys_VideoPluginManager.cpp (100%) rename {Plugins => foleys_video_engine/Plugins}/foleys_VideoPluginManager.h (100%) rename {Plugins => foleys_video_engine/Plugins}/foleys_VideoProcessor.h (100%) rename {Processing => foleys_video_engine/Processing}/foleys_AudioMixer.h (100%) rename {Processing => foleys_video_engine/Processing}/foleys_ColourLookuptables.h (100%) rename {Processing => foleys_video_engine/Processing}/foleys_ControllableBase.cpp (100%) rename {Processing => foleys_video_engine/Processing}/foleys_ControllableBase.h (100%) rename {Processing => foleys_video_engine/Processing}/foleys_DefaultAudioMixer.cpp (100%) rename {Processing => foleys_video_engine/Processing}/foleys_DefaultAudioMixer.h (100%) rename {Processing => foleys_video_engine/Processing}/foleys_ParameterAutomation.cpp (100%) rename {Processing => foleys_video_engine/Processing}/foleys_ParameterAutomation.h (100%) rename {Processing => foleys_video_engine/Processing}/foleys_ProcessorController.cpp (100%) rename {Processing => foleys_video_engine/Processing}/foleys_ProcessorController.h (100%) rename {Processing => foleys_video_engine/Processing}/foleys_ProcessorParameter.cpp (100%) rename {Processing => foleys_video_engine/Processing}/foleys_ProcessorParameter.h (100%) rename {Processing => foleys_video_engine/Processing}/foleys_SoftwareVideoMixer.cpp (100%) rename {Processing => foleys_video_engine/Processing}/foleys_SoftwareVideoMixer.h (100%) rename {Processing => foleys_video_engine/Processing}/foleys_VideoMixer.h (100%) rename {ReadWrite => foleys_video_engine/ReadWrite}/FFmpeg/foleys_FFmpegFormat.cpp (100%) rename {ReadWrite => foleys_video_engine/ReadWrite}/FFmpeg/foleys_FFmpegFormat.h (100%) rename {ReadWrite => foleys_video_engine/ReadWrite}/FFmpeg/foleys_FFmpegHelpers.h (100%) rename {ReadWrite => foleys_video_engine/ReadWrite}/FFmpeg/foleys_FFmpegReader.cpp (100%) rename {ReadWrite => foleys_video_engine/ReadWrite}/FFmpeg/foleys_FFmpegReader.h (100%) rename {ReadWrite => foleys_video_engine/ReadWrite}/FFmpeg/foleys_FFmpegWriter.cpp (100%) rename {ReadWrite => foleys_video_engine/ReadWrite}/FFmpeg/foleys_FFmpegWriter.h (100%) rename {ReadWrite => foleys_video_engine/ReadWrite}/foleys_AVFormatManager.cpp (100%) rename {ReadWrite => foleys_video_engine/ReadWrite}/foleys_AVFormatManager.h (100%) rename {ReadWrite => foleys_video_engine/ReadWrite}/foleys_AVReader.h (100%) rename {ReadWrite => foleys_video_engine/ReadWrite}/foleys_AVWriter.h (100%) rename {ReadWrite => foleys_video_engine/ReadWrite}/foleys_ClipRenderer.cpp (100%) rename {ReadWrite => foleys_video_engine/ReadWrite}/foleys_ClipRenderer.h (100%) rename {Widgets => foleys_video_engine/Widgets}/foleys_AudioStrip.cpp (100%) rename {Widgets => foleys_video_engine/Widgets}/foleys_AudioStrip.h (100%) rename {Widgets => foleys_video_engine/Widgets}/foleys_FilmStrip.cpp (100%) rename {Widgets => foleys_video_engine/Widgets}/foleys_FilmStrip.h (100%) rename {Widgets => foleys_video_engine/Widgets}/foleys_OpenGLDraw.h (83%) rename {Widgets => foleys_video_engine/Widgets}/foleys_OpenGLView.cpp (91%) rename {Widgets => foleys_video_engine/Widgets}/foleys_OpenGLView.h (100%) rename {Widgets => foleys_video_engine/Widgets}/foleys_SoftwareView.cpp (100%) rename {Widgets => foleys_video_engine/Widgets}/foleys_SoftwareView.h (100%) rename {Widgets => foleys_video_engine/Widgets}/foleys_VideoView.h (100%) rename foleys_video_engine.cpp => foleys_video_engine/foleys_video_engine.cpp (100%) rename foleys_video_engine.h => foleys_video_engine/foleys_video_engine.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 87779ade..a9a95f03 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,10 +13,9 @@ include (FoleysDefaultTarget) include (FindJUCE) include (FindFFmpeg) -juce_add_module ("${CMAKE_CURRENT_LIST_DIR}" ALIAS_NAMESPACE Foleys) +juce_add_module ("${CMAKE_CURRENT_LIST_DIR}/foleys_video_engine" ALIAS_NAMESPACE Foleys) -target_compile_definitions (foleys_video_engine INTERFACE JUCE_USE_CAMERA=1 FOLEYS_CAMERA_SUPPORT=1 - JUCE_MODAL_LOOPS_PERMITTED=1 JUCE_STRICT_REFCOUNTEDPOINTER=1 +target_compile_definitions (foleys_video_engine INTERFACE JUCE_MODAL_LOOPS_PERMITTED=1 JUCE_STRICT_REFCOUNTEDPOINTER=1 JUCE_PLUGINHOST_AU=1 JUCE_PLUGINHOST_VST3=1 JUCE_PLUGINHOST_LADSPA=1) target_link_libraries (foleys_video_engine INTERFACE Foleys::foleys_ffmpeg Foleys::FoleysDefaultTarget) diff --git a/Makefile b/Makefile index b882300e..51a7e363 100644 --- a/Makefile +++ b/Makefile @@ -49,8 +49,12 @@ wipe: clean ## Removes the builds directory and the dependencies cache # -config_tests: ## Configure the tests +config: ## Configure the tests $(call cmake_config) -D FOLEYS_BUILD_TESTS=1 -tests: config_tests ## Build the tests +tests: config ## Build the tests @$(call cmake_build_configuration,Debug) + +# + +.PHONY: $(shell grep -E '^[a-zA-Z_-]+:.*?\#\# .*$$' $(THIS_MAKEFILE) | sed 's/:.*/\ /' | tr '\n' ' ') diff --git a/cmake/FindFFmpeg.cmake b/cmake/FindFFmpeg.cmake index da6a65db..86b329ac 100644 --- a/cmake/FindFFmpeg.cmake +++ b/cmake/FindFFmpeg.cmake @@ -11,6 +11,10 @@ if (FOLEYS_USE_SYSTEM_FFMPEG) endif() if (NOT TARGET foleys_ffmpeg) + if (FOLEYS_USE_SYSTEM_FFMPEG) + message (WARNING "System installation of FFmpeg was requested, but targets couldn't be imported. Configuring to build from source...") + endif() + include ("${CMAKE_CURRENT_LIST_DIR}/ffmpeg/BuildFFmpeg.cmake") endif() @@ -20,11 +24,6 @@ endif() # customXcodeResourceFolders -# extra def FFMPEG_ROOT=... - -# linux: compile flag -I${FFMPEG_ROOT}/include -# linux: linker flag -L${FFMPEG_ROOT}/lib - target_compile_definitions (foleys_ffmpeg INTERFACE FOLEYS_USE_FFMPEG=1) add_library (Foleys::foleys_ffmpeg ALIAS foleys_ffmpeg) diff --git a/cmake/FoleysDefaultTarget.cmake b/cmake/FoleysDefaultTarget.cmake index df1a2125..82dd3c1b 100644 --- a/cmake/FoleysDefaultTarget.cmake +++ b/cmake/FoleysDefaultTarget.cmake @@ -44,14 +44,13 @@ endif() # MacOS options -option (FOLEYS_MAC_UNIVERSAL_BINARY "Builds for x86_64 and arm64" ON) - if(APPLE) set_target_properties (FoleysDefaultTarget PROPERTIES XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME YES) target_compile_definitions (FoleysDefaultTarget INTERFACE JUCE_USE_VDSP_FRAMEWORK=1) if(IOS) + set_target_properties (FoleysDefaultTarget PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "./" XCODE_ATTRIBUTE_INSTALL_PATH "$(LOCAL_APPS_DIR)" @@ -61,15 +60,26 @@ if(APPLE) target_compile_options (FoleysDefaultTarget INTERFACE "-mmacosx-version-min=9.3") target_link_options (FoleysDefaultTarget INTERFACE "-mmacosx-version-min=9.3") + else() + + option (FOLEYS_MAC_UNIVERSAL_BINARY "Builds for x86_64 and arm64" ON) + + if (FOLEYS_MAC_UNIVERSAL_BINARY AND XCODE) + + execute_process (COMMAND uname -m RESULT_VARIABLE result OUTPUT_VARIABLE osx_native_arch + OUTPUT_STRIP_TRAILING_WHITESPACE) + + if ("${osx_native_arch}" STREQUAL "arm64") + set_target_properties (FoleysDefaultTarget PROPERTIES OSX_ARCHITECTURES "x86_64;arm64") + message (STATUS "Enabling Mac universal binary") + endif() + endif() + set_target_properties (FoleysDefaultTarget PROPERTIES XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET "10.11") target_compile_options (FoleysDefaultTarget INTERFACE "-mmacosx-version-min=10.11") target_link_options (FoleysDefaultTarget INTERFACE "-mmacosx-version-min=10.11") - - if (FOLEYS_MAC_UNIVERSAL_BINARY) - set_target_properties (FoleysDefaultTarget PROPERTIES OSX_ARCHITECTURES "x86_64;arm64") - endif() endif() endif() diff --git a/cmake/ffmpeg/BuildFFmpeg.cmake b/cmake/ffmpeg/BuildFFmpeg.cmake index fac18287..b92cbe80 100644 --- a/cmake/ffmpeg/BuildFFmpeg.cmake +++ b/cmake/ffmpeg/BuildFFmpeg.cmake @@ -19,7 +19,6 @@ else() endif() set (FFMPEG_SOURCE_DIR "${FOLEYS_SOURCE_CACHE}/${FFMPEG_NAME}") - set (FFMPEG_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/ffmpeg") # @@ -66,9 +65,6 @@ string (REPLACE ";" "|" FFMPEG_CONFIGURE_EXTRAS_ENCODED "${FFMPEG_CONFIGURE_EXTR # -# -# CMAKE_SYSTEM_PROCESSOR - ## FFMPEG_ASM_FLAGS ? include (ExternalProject) @@ -76,18 +72,13 @@ include (ExternalProject) configure_file ("${CMAKE_CURRENT_LIST_DIR}/configure_ffmpeg_build.cmake" configure_ffmpeg_build.cmake @ONLY) ExternalProject_Add (ffmpeg_build - PREFIX ffmpeg_pref + PREFIX ffmpeg URL "${FFMPEG_SOURCE_DIR}" DOWNLOAD_NO_EXTRACT 1 - CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env PATH=${ANDROID_TOOLCHAIN_ROOT}/bin:$ENV{PATH} - ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/configure_ffmpeg_build.cmake" - BUILD_COMMAND ${CMAKE_COMMAND} -E env PATH=${ANDROID_TOOLCHAIN_ROOT}/bin:$ENV{PATH} - make -j4 - #${HOST_BIN}/make -j4 + CONFIGURE_COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/configure_ffmpeg_build.cmake" + BUILD_COMMAND make -j4 BUILD_IN_SOURCE 1 - INSTALL_COMMAND ${CMAKE_COMMAND} -E env PATH=${ANDROID_TOOLCHAIN_ROOT}/bin:$ENV{PATH} - make install - #${HOST_BIN}/make install + INSTALL_COMMAND make install STEP_TARGETS ffmpeg_copy_headers LOG_CONFIGURE 1 LOG_BUILD 1 @@ -108,9 +99,27 @@ ExternalProject_Add_Step ( # -add_library (foleys_ffmpeg INTERFACE) +function (foleys_make_lib_filename libname filename_out) + + set (output "") + + if (CMAKE_SHARED_LIBRARY_PREFIX) + set (output "${CMAKE_SHARED_LIBRARY_PREFIX}") + endif() + + set (output "${output}${libname}") + + if (CMAKE_SHARED_LIBRARY_SUFFIX) + set (output "${output}${CMAKE_SHARED_LIBRARY_SUFFIX}") + endif() -ExternalProject_Get_Property (ffmpeg_build INSTALL_DIR) + set (${filename_out} "${output}" PARENT_SCOPE) + +endfunction() + +# + +add_library (foleys_ffmpeg INTERFACE) foreach (ffmpeg_lib IN LISTS foleys_ffmpeg_libs) @@ -118,7 +127,9 @@ foreach (ffmpeg_lib IN LISTS foleys_ffmpeg_libs) add_dependencies (Foleys::${ffmpeg_lib} ffmpeg_build) - set_target_properties (Foleys::${ffmpeg_lib} PROPERTIES IMPORTED_LOCATION "${INSTALL_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}${ffmpeg_lib}.${CMAKE_SHARED_LIBRARY_SUFFIX}") + foleys_make_lib_filename (${ffmpeg_lib} lib_filename) + + set_target_properties (Foleys::${ffmpeg_lib} PROPERTIES IMPORTED_LOCATION "${FFMPEG_OUTPUT_DIR}/${lib_filename}") target_link_libraries (foleys_ffmpeg INTERFACE Foleys::${ffmpeg_lib}) @@ -126,12 +137,8 @@ endforeach() # -#target_sources (foleys_ffmpeg PRIVATE ${ffmpeg_src}) - add_dependencies (foleys_ffmpeg ffmpeg_build) -#target_link_libraries (foleys_ffmpeg PRIVATE ${foleys_ffmpeg_libs}) - -target_link_directories (foleys_ffmpeg INTERFACE "${FFMPEG_OUTPUT_DIR}" "${INSTALL_DIR}") +target_link_directories (foleys_ffmpeg INTERFACE "${FFMPEG_OUTPUT_DIR}") target_include_directories (foleys_ffmpeg INTERFACE "${FFMPEG_OUTPUT_DIR}/include") diff --git a/cmake/ffmpeg/configure_ffmpeg_build.cmake b/cmake/ffmpeg/configure_ffmpeg_build.cmake index fe40f1ed..140735b2 100644 --- a/cmake/ffmpeg/configure_ffmpeg_build.cmake +++ b/cmake/ffmpeg/configure_ffmpeg_build.cmake @@ -2,6 +2,7 @@ cmake_minimum_required (VERSION 3.15 FATAL_ERROR) string (REPLACE "|" ";" CONFIGURE_EXTRAS_ENCODED "@FFMPEG_CONFIGURE_EXTRAS_ENCODED@") list (REMOVE_ITEM CONFIGURE_EXTRAS_ENCODED "") +list (REMOVE_DUPLICATES CONFIGURE_EXTRAS_ENCODED) set (CONFIGURE_COMMAND ./configure diff --git a/Basics/foleys_AudioFifo.cpp b/foleys_video_engine/Basics/foleys_AudioFifo.cpp similarity index 100% rename from Basics/foleys_AudioFifo.cpp rename to foleys_video_engine/Basics/foleys_AudioFifo.cpp diff --git a/Basics/foleys_AudioFifo.h b/foleys_video_engine/Basics/foleys_AudioFifo.h similarity index 100% rename from Basics/foleys_AudioFifo.h rename to foleys_video_engine/Basics/foleys_AudioFifo.h diff --git a/Basics/foleys_Structures.h b/foleys_video_engine/Basics/foleys_Structures.h similarity index 100% rename from Basics/foleys_Structures.h rename to foleys_video_engine/Basics/foleys_Structures.h diff --git a/Basics/foleys_TimeCodeAware.cpp b/foleys_video_engine/Basics/foleys_TimeCodeAware.cpp similarity index 100% rename from Basics/foleys_TimeCodeAware.cpp rename to foleys_video_engine/Basics/foleys_TimeCodeAware.cpp diff --git a/Basics/foleys_TimeCodeAware.h b/foleys_video_engine/Basics/foleys_TimeCodeAware.h similarity index 100% rename from Basics/foleys_TimeCodeAware.h rename to foleys_video_engine/Basics/foleys_TimeCodeAware.h diff --git a/Basics/foleys_Usage.cpp b/foleys_video_engine/Basics/foleys_Usage.cpp similarity index 100% rename from Basics/foleys_Usage.cpp rename to foleys_video_engine/Basics/foleys_Usage.cpp diff --git a/Basics/foleys_Usage.h b/foleys_video_engine/Basics/foleys_Usage.h similarity index 100% rename from Basics/foleys_Usage.h rename to foleys_video_engine/Basics/foleys_Usage.h diff --git a/Basics/foleys_VideoEngine.cpp b/foleys_video_engine/Basics/foleys_VideoEngine.cpp similarity index 100% rename from Basics/foleys_VideoEngine.cpp rename to foleys_video_engine/Basics/foleys_VideoEngine.cpp diff --git a/Basics/foleys_VideoEngine.h b/foleys_video_engine/Basics/foleys_VideoEngine.h similarity index 100% rename from Basics/foleys_VideoEngine.h rename to foleys_video_engine/Basics/foleys_VideoEngine.h diff --git a/Basics/foleys_VideoFifo.cpp b/foleys_video_engine/Basics/foleys_VideoFifo.cpp similarity index 100% rename from Basics/foleys_VideoFifo.cpp rename to foleys_video_engine/Basics/foleys_VideoFifo.cpp diff --git a/Basics/foleys_VideoFifo.h b/foleys_video_engine/Basics/foleys_VideoFifo.h similarity index 100% rename from Basics/foleys_VideoFifo.h rename to foleys_video_engine/Basics/foleys_VideoFifo.h diff --git a/Basics/foleys_VideoFrame.h b/foleys_video_engine/Basics/foleys_VideoFrame.h similarity index 100% rename from Basics/foleys_VideoFrame.h rename to foleys_video_engine/Basics/foleys_VideoFrame.h diff --git a/Clips/foleys_AVClip.cpp b/foleys_video_engine/Clips/foleys_AVClip.cpp similarity index 100% rename from Clips/foleys_AVClip.cpp rename to foleys_video_engine/Clips/foleys_AVClip.cpp diff --git a/Clips/foleys_AVClip.h b/foleys_video_engine/Clips/foleys_AVClip.h similarity index 100% rename from Clips/foleys_AVClip.h rename to foleys_video_engine/Clips/foleys_AVClip.h diff --git a/Clips/foleys_AudioClip.cpp b/foleys_video_engine/Clips/foleys_AudioClip.cpp similarity index 100% rename from Clips/foleys_AudioClip.cpp rename to foleys_video_engine/Clips/foleys_AudioClip.cpp diff --git a/Clips/foleys_AudioClip.h b/foleys_video_engine/Clips/foleys_AudioClip.h similarity index 100% rename from Clips/foleys_AudioClip.h rename to foleys_video_engine/Clips/foleys_AudioClip.h diff --git a/Clips/foleys_ClipDescriptor.cpp b/foleys_video_engine/Clips/foleys_ClipDescriptor.cpp similarity index 100% rename from Clips/foleys_ClipDescriptor.cpp rename to foleys_video_engine/Clips/foleys_ClipDescriptor.cpp diff --git a/Clips/foleys_ClipDescriptor.h b/foleys_video_engine/Clips/foleys_ClipDescriptor.h similarity index 100% rename from Clips/foleys_ClipDescriptor.h rename to foleys_video_engine/Clips/foleys_ClipDescriptor.h diff --git a/Clips/foleys_ComposedClip.cpp b/foleys_video_engine/Clips/foleys_ComposedClip.cpp similarity index 100% rename from Clips/foleys_ComposedClip.cpp rename to foleys_video_engine/Clips/foleys_ComposedClip.cpp diff --git a/Clips/foleys_ComposedClip.h b/foleys_video_engine/Clips/foleys_ComposedClip.h similarity index 100% rename from Clips/foleys_ComposedClip.h rename to foleys_video_engine/Clips/foleys_ComposedClip.h diff --git a/Clips/foleys_ImageClip.cpp b/foleys_video_engine/Clips/foleys_ImageClip.cpp similarity index 100% rename from Clips/foleys_ImageClip.cpp rename to foleys_video_engine/Clips/foleys_ImageClip.cpp diff --git a/Clips/foleys_ImageClip.h b/foleys_video_engine/Clips/foleys_ImageClip.h similarity index 100% rename from Clips/foleys_ImageClip.h rename to foleys_video_engine/Clips/foleys_ImageClip.h diff --git a/Clips/foleys_MovieClip.cpp b/foleys_video_engine/Clips/foleys_MovieClip.cpp similarity index 100% rename from Clips/foleys_MovieClip.cpp rename to foleys_video_engine/Clips/foleys_MovieClip.cpp diff --git a/Clips/foleys_MovieClip.h b/foleys_video_engine/Clips/foleys_MovieClip.h similarity index 100% rename from Clips/foleys_MovieClip.h rename to foleys_video_engine/Clips/foleys_MovieClip.h diff --git a/Plugins/foleys_AudioPluginManager.cpp b/foleys_video_engine/Plugins/foleys_AudioPluginManager.cpp similarity index 100% rename from Plugins/foleys_AudioPluginManager.cpp rename to foleys_video_engine/Plugins/foleys_AudioPluginManager.cpp diff --git a/Plugins/foleys_AudioPluginManager.h b/foleys_video_engine/Plugins/foleys_AudioPluginManager.h similarity index 100% rename from Plugins/foleys_AudioPluginManager.h rename to foleys_video_engine/Plugins/foleys_AudioPluginManager.h diff --git a/Plugins/foleys_ColourCurveVideoProcessor.h b/foleys_video_engine/Plugins/foleys_ColourCurveVideoProcessor.h similarity index 100% rename from Plugins/foleys_ColourCurveVideoProcessor.h rename to foleys_video_engine/Plugins/foleys_ColourCurveVideoProcessor.h diff --git a/Plugins/foleys_VideoPluginManager.cpp b/foleys_video_engine/Plugins/foleys_VideoPluginManager.cpp similarity index 100% rename from Plugins/foleys_VideoPluginManager.cpp rename to foleys_video_engine/Plugins/foleys_VideoPluginManager.cpp diff --git a/Plugins/foleys_VideoPluginManager.h b/foleys_video_engine/Plugins/foleys_VideoPluginManager.h similarity index 100% rename from Plugins/foleys_VideoPluginManager.h rename to foleys_video_engine/Plugins/foleys_VideoPluginManager.h diff --git a/Plugins/foleys_VideoProcessor.h b/foleys_video_engine/Plugins/foleys_VideoProcessor.h similarity index 100% rename from Plugins/foleys_VideoProcessor.h rename to foleys_video_engine/Plugins/foleys_VideoProcessor.h diff --git a/Processing/foleys_AudioMixer.h b/foleys_video_engine/Processing/foleys_AudioMixer.h similarity index 100% rename from Processing/foleys_AudioMixer.h rename to foleys_video_engine/Processing/foleys_AudioMixer.h diff --git a/Processing/foleys_ColourLookuptables.h b/foleys_video_engine/Processing/foleys_ColourLookuptables.h similarity index 100% rename from Processing/foleys_ColourLookuptables.h rename to foleys_video_engine/Processing/foleys_ColourLookuptables.h diff --git a/Processing/foleys_ControllableBase.cpp b/foleys_video_engine/Processing/foleys_ControllableBase.cpp similarity index 100% rename from Processing/foleys_ControllableBase.cpp rename to foleys_video_engine/Processing/foleys_ControllableBase.cpp diff --git a/Processing/foleys_ControllableBase.h b/foleys_video_engine/Processing/foleys_ControllableBase.h similarity index 100% rename from Processing/foleys_ControllableBase.h rename to foleys_video_engine/Processing/foleys_ControllableBase.h diff --git a/Processing/foleys_DefaultAudioMixer.cpp b/foleys_video_engine/Processing/foleys_DefaultAudioMixer.cpp similarity index 100% rename from Processing/foleys_DefaultAudioMixer.cpp rename to foleys_video_engine/Processing/foleys_DefaultAudioMixer.cpp diff --git a/Processing/foleys_DefaultAudioMixer.h b/foleys_video_engine/Processing/foleys_DefaultAudioMixer.h similarity index 100% rename from Processing/foleys_DefaultAudioMixer.h rename to foleys_video_engine/Processing/foleys_DefaultAudioMixer.h diff --git a/Processing/foleys_ParameterAutomation.cpp b/foleys_video_engine/Processing/foleys_ParameterAutomation.cpp similarity index 100% rename from Processing/foleys_ParameterAutomation.cpp rename to foleys_video_engine/Processing/foleys_ParameterAutomation.cpp diff --git a/Processing/foleys_ParameterAutomation.h b/foleys_video_engine/Processing/foleys_ParameterAutomation.h similarity index 100% rename from Processing/foleys_ParameterAutomation.h rename to foleys_video_engine/Processing/foleys_ParameterAutomation.h diff --git a/Processing/foleys_ProcessorController.cpp b/foleys_video_engine/Processing/foleys_ProcessorController.cpp similarity index 100% rename from Processing/foleys_ProcessorController.cpp rename to foleys_video_engine/Processing/foleys_ProcessorController.cpp diff --git a/Processing/foleys_ProcessorController.h b/foleys_video_engine/Processing/foleys_ProcessorController.h similarity index 100% rename from Processing/foleys_ProcessorController.h rename to foleys_video_engine/Processing/foleys_ProcessorController.h diff --git a/Processing/foleys_ProcessorParameter.cpp b/foleys_video_engine/Processing/foleys_ProcessorParameter.cpp similarity index 100% rename from Processing/foleys_ProcessorParameter.cpp rename to foleys_video_engine/Processing/foleys_ProcessorParameter.cpp diff --git a/Processing/foleys_ProcessorParameter.h b/foleys_video_engine/Processing/foleys_ProcessorParameter.h similarity index 100% rename from Processing/foleys_ProcessorParameter.h rename to foleys_video_engine/Processing/foleys_ProcessorParameter.h diff --git a/Processing/foleys_SoftwareVideoMixer.cpp b/foleys_video_engine/Processing/foleys_SoftwareVideoMixer.cpp similarity index 100% rename from Processing/foleys_SoftwareVideoMixer.cpp rename to foleys_video_engine/Processing/foleys_SoftwareVideoMixer.cpp diff --git a/Processing/foleys_SoftwareVideoMixer.h b/foleys_video_engine/Processing/foleys_SoftwareVideoMixer.h similarity index 100% rename from Processing/foleys_SoftwareVideoMixer.h rename to foleys_video_engine/Processing/foleys_SoftwareVideoMixer.h diff --git a/Processing/foleys_VideoMixer.h b/foleys_video_engine/Processing/foleys_VideoMixer.h similarity index 100% rename from Processing/foleys_VideoMixer.h rename to foleys_video_engine/Processing/foleys_VideoMixer.h diff --git a/ReadWrite/FFmpeg/foleys_FFmpegFormat.cpp b/foleys_video_engine/ReadWrite/FFmpeg/foleys_FFmpegFormat.cpp similarity index 100% rename from ReadWrite/FFmpeg/foleys_FFmpegFormat.cpp rename to foleys_video_engine/ReadWrite/FFmpeg/foleys_FFmpegFormat.cpp diff --git a/ReadWrite/FFmpeg/foleys_FFmpegFormat.h b/foleys_video_engine/ReadWrite/FFmpeg/foleys_FFmpegFormat.h similarity index 100% rename from ReadWrite/FFmpeg/foleys_FFmpegFormat.h rename to foleys_video_engine/ReadWrite/FFmpeg/foleys_FFmpegFormat.h diff --git a/ReadWrite/FFmpeg/foleys_FFmpegHelpers.h b/foleys_video_engine/ReadWrite/FFmpeg/foleys_FFmpegHelpers.h similarity index 100% rename from ReadWrite/FFmpeg/foleys_FFmpegHelpers.h rename to foleys_video_engine/ReadWrite/FFmpeg/foleys_FFmpegHelpers.h diff --git a/ReadWrite/FFmpeg/foleys_FFmpegReader.cpp b/foleys_video_engine/ReadWrite/FFmpeg/foleys_FFmpegReader.cpp similarity index 100% rename from ReadWrite/FFmpeg/foleys_FFmpegReader.cpp rename to foleys_video_engine/ReadWrite/FFmpeg/foleys_FFmpegReader.cpp diff --git a/ReadWrite/FFmpeg/foleys_FFmpegReader.h b/foleys_video_engine/ReadWrite/FFmpeg/foleys_FFmpegReader.h similarity index 100% rename from ReadWrite/FFmpeg/foleys_FFmpegReader.h rename to foleys_video_engine/ReadWrite/FFmpeg/foleys_FFmpegReader.h diff --git a/ReadWrite/FFmpeg/foleys_FFmpegWriter.cpp b/foleys_video_engine/ReadWrite/FFmpeg/foleys_FFmpegWriter.cpp similarity index 100% rename from ReadWrite/FFmpeg/foleys_FFmpegWriter.cpp rename to foleys_video_engine/ReadWrite/FFmpeg/foleys_FFmpegWriter.cpp diff --git a/ReadWrite/FFmpeg/foleys_FFmpegWriter.h b/foleys_video_engine/ReadWrite/FFmpeg/foleys_FFmpegWriter.h similarity index 100% rename from ReadWrite/FFmpeg/foleys_FFmpegWriter.h rename to foleys_video_engine/ReadWrite/FFmpeg/foleys_FFmpegWriter.h diff --git a/ReadWrite/foleys_AVFormatManager.cpp b/foleys_video_engine/ReadWrite/foleys_AVFormatManager.cpp similarity index 100% rename from ReadWrite/foleys_AVFormatManager.cpp rename to foleys_video_engine/ReadWrite/foleys_AVFormatManager.cpp diff --git a/ReadWrite/foleys_AVFormatManager.h b/foleys_video_engine/ReadWrite/foleys_AVFormatManager.h similarity index 100% rename from ReadWrite/foleys_AVFormatManager.h rename to foleys_video_engine/ReadWrite/foleys_AVFormatManager.h diff --git a/ReadWrite/foleys_AVReader.h b/foleys_video_engine/ReadWrite/foleys_AVReader.h similarity index 100% rename from ReadWrite/foleys_AVReader.h rename to foleys_video_engine/ReadWrite/foleys_AVReader.h diff --git a/ReadWrite/foleys_AVWriter.h b/foleys_video_engine/ReadWrite/foleys_AVWriter.h similarity index 100% rename from ReadWrite/foleys_AVWriter.h rename to foleys_video_engine/ReadWrite/foleys_AVWriter.h diff --git a/ReadWrite/foleys_ClipRenderer.cpp b/foleys_video_engine/ReadWrite/foleys_ClipRenderer.cpp similarity index 100% rename from ReadWrite/foleys_ClipRenderer.cpp rename to foleys_video_engine/ReadWrite/foleys_ClipRenderer.cpp diff --git a/ReadWrite/foleys_ClipRenderer.h b/foleys_video_engine/ReadWrite/foleys_ClipRenderer.h similarity index 100% rename from ReadWrite/foleys_ClipRenderer.h rename to foleys_video_engine/ReadWrite/foleys_ClipRenderer.h diff --git a/Widgets/foleys_AudioStrip.cpp b/foleys_video_engine/Widgets/foleys_AudioStrip.cpp similarity index 100% rename from Widgets/foleys_AudioStrip.cpp rename to foleys_video_engine/Widgets/foleys_AudioStrip.cpp diff --git a/Widgets/foleys_AudioStrip.h b/foleys_video_engine/Widgets/foleys_AudioStrip.h similarity index 100% rename from Widgets/foleys_AudioStrip.h rename to foleys_video_engine/Widgets/foleys_AudioStrip.h diff --git a/Widgets/foleys_FilmStrip.cpp b/foleys_video_engine/Widgets/foleys_FilmStrip.cpp similarity index 100% rename from Widgets/foleys_FilmStrip.cpp rename to foleys_video_engine/Widgets/foleys_FilmStrip.cpp diff --git a/Widgets/foleys_FilmStrip.h b/foleys_video_engine/Widgets/foleys_FilmStrip.h similarity index 100% rename from Widgets/foleys_FilmStrip.h rename to foleys_video_engine/Widgets/foleys_FilmStrip.h diff --git a/Widgets/foleys_OpenGLDraw.h b/foleys_video_engine/Widgets/foleys_OpenGLDraw.h similarity index 83% rename from Widgets/foleys_OpenGLDraw.h rename to foleys_video_engine/Widgets/foleys_OpenGLDraw.h index d57e1fee..9de42fb0 100644 --- a/Widgets/foleys_OpenGLDraw.h +++ b/foleys_video_engine/Widgets/foleys_OpenGLDraw.h @@ -33,18 +33,18 @@ static const char* getGLErrorMessage (const GLenum e) noexcept { switch (e) { - case GL_INVALID_ENUM: return "GL_INVALID_ENUM"; - case GL_INVALID_VALUE: return "GL_INVALID_VALUE"; - case GL_INVALID_OPERATION: return "GL_INVALID_OPERATION"; - case GL_OUT_OF_MEMORY: return "GL_OUT_OF_MEMORY"; + case juce::gl::GL_INVALID_ENUM: return "GL_INVALID_ENUM"; + case juce::gl::GL_INVALID_VALUE: return "GL_INVALID_VALUE"; + case juce::gl::GL_INVALID_OPERATION: return "GL_INVALID_OPERATION"; + case juce::gl::GL_OUT_OF_MEMORY: return "GL_OUT_OF_MEMORY"; #ifdef GL_STACK_OVERFLOW - case GL_STACK_OVERFLOW: return "GL_STACK_OVERFLOW"; + case juce::gl::GL_STACK_OVERFLOW: return "GL_STACK_OVERFLOW"; #endif #ifdef GL_STACK_UNDERFLOW - case GL_STACK_UNDERFLOW: return "GL_STACK_UNDERFLOW"; + case juce::gl::GL_STACK_UNDERFLOW: return "GL_STACK_UNDERFLOW"; #endif #ifdef GL_INVALID_FRAMEBUFFER_OPERATION - case GL_INVALID_FRAMEBUFFER_OPERATION: return "GL_INVALID_FRAMEBUFFER_OPERATION"; + case juce::gl::GL_INVALID_FRAMEBUFFER_OPERATION: return "GL_INVALID_FRAMEBUFFER_OPERATION"; #endif default: break; } @@ -56,9 +56,9 @@ static void checkGLError (const char* file, const int line) { for (;;) { - const GLenum e = glGetError(); + const GLenum e = juce::gl::glGetError(); - if (e == GL_NO_ERROR) + if (e == juce::gl::GL_NO_ERROR) break; DBG ("***** " << getGLErrorMessage (e) << " at " << file << " : " << line); @@ -73,7 +73,7 @@ static void checkGLError (const char* file, const int line) static void clearGLError() noexcept { - while (glGetError() != GL_NO_ERROR) {} + while (juce::gl::glGetError() != juce::gl::GL_NO_ERROR) {} } @@ -81,19 +81,19 @@ struct DepthTestDisabler { DepthTestDisabler() noexcept { - glGetBooleanv (GL_DEPTH_TEST, &wasEnabled); + juce::gl::glGetBooleanv (juce::gl::GL_DEPTH_TEST, &wasEnabled); if (wasEnabled) - glDisable (GL_DEPTH_TEST); + juce::gl::glDisable (juce::gl::GL_DEPTH_TEST); } ~DepthTestDisabler() noexcept { if (wasEnabled) - glEnable (GL_DEPTH_TEST); + juce::gl::glEnable (juce::gl::GL_DEPTH_TEST); } - GLboolean wasEnabled; + GLboolean wasEnabled; }; static inline void drawTexture (juce::OpenGLContext& context, @@ -110,8 +110,8 @@ static inline void drawTexture (juce::OpenGLContext& context, juce::ignoreUnused (transform); JUCE_CHECK_OPENGL_ERROR - glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - glEnable (GL_BLEND); + juce::gl::glBlendFunc (juce::gl::GL_ONE, juce::gl::GL_ONE_MINUS_SRC_ALPHA); + juce::gl::glEnable (juce::gl::GL_BLEND); DepthTestDisabler depthDisabler; @@ -218,20 +218,20 @@ static inline void drawTexture (juce::OpenGLContext& context, GLuint vertexBuffer = 0; context.extensions.glGenBuffers (1, &vertexBuffer); - context.extensions.glBindBuffer (GL_ARRAY_BUFFER, vertexBuffer); - context.extensions.glBufferData (GL_ARRAY_BUFFER, sizeof (vertices), vertices, GL_STATIC_DRAW); + context.extensions.glBindBuffer (juce::gl::GL_ARRAY_BUFFER, vertexBuffer); + context.extensions.glBufferData (juce::gl::GL_ARRAY_BUFFER, sizeof (vertices), vertices, juce::gl::GL_STATIC_DRAW); JUCE_CHECK_OPENGL_ERROR auto index = (GLuint) program.params.positionAttribute.attributeID; - context.extensions.glVertexAttribPointer (index, 2, GL_SHORT, GL_FALSE, 4, nullptr); + context.extensions.glVertexAttribPointer (index, 2, juce::gl::GL_SHORT, juce::gl::GL_FALSE, 4, nullptr); context.extensions.glEnableVertexAttribArray (index); JUCE_CHECK_OPENGL_ERROR - if (context.extensions.glCheckFramebufferStatus (GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE) + if (context.extensions.glCheckFramebufferStatus (juce::gl::GL_FRAMEBUFFER) == juce::gl::GL_FRAMEBUFFER_COMPLETE) { - glDrawArrays (GL_TRIANGLE_STRIP, 0, 4); + juce::gl::glDrawArrays (juce::gl::GL_TRIANGLE_STRIP, 0, 4); - context.extensions.glBindBuffer (GL_ARRAY_BUFFER, 0); + context.extensions.glBindBuffer (juce::gl::GL_ARRAY_BUFFER, 0); context.extensions.glUseProgram (0); context.extensions.glDisableVertexAttribArray (index); context.extensions.glDeleteBuffers (1, &vertexBuffer); diff --git a/Widgets/foleys_OpenGLView.cpp b/foleys_video_engine/Widgets/foleys_OpenGLView.cpp similarity index 91% rename from Widgets/foleys_OpenGLView.cpp rename to foleys_video_engine/Widgets/foleys_OpenGLView.cpp index 85e8e8d2..52822c2f 100644 --- a/Widgets/foleys_OpenGLView.cpp +++ b/foleys_video_engine/Widgets/foleys_OpenGLView.cpp @@ -54,10 +54,10 @@ void OpenGLView::render() auto desktopScale = (float) openGLContext.getRenderingScale(); juce::OpenGLHelpers::clear (juce::Colours::black); - glEnable (GL_BLEND); - glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + juce::gl::glEnable (juce::gl::GL_BLEND); + juce::gl::glBlendFunc (juce::gl::GL_SRC_ALPHA, juce::gl::GL_ONE_MINUS_SRC_ALPHA); - glViewport (0, 0, juce::roundToInt (desktopScale * (float) getWidth()), juce::roundToInt (desktopScale * (float) getHeight())); + juce::gl::glViewport (0, 0, juce::roundToInt (desktopScale * (float) getWidth()), juce::roundToInt (desktopScale * (float) getHeight())); clip->render (*this, clip->getCurrentTimeInSeconds()); } diff --git a/Widgets/foleys_OpenGLView.h b/foleys_video_engine/Widgets/foleys_OpenGLView.h similarity index 100% rename from Widgets/foleys_OpenGLView.h rename to foleys_video_engine/Widgets/foleys_OpenGLView.h diff --git a/Widgets/foleys_SoftwareView.cpp b/foleys_video_engine/Widgets/foleys_SoftwareView.cpp similarity index 100% rename from Widgets/foleys_SoftwareView.cpp rename to foleys_video_engine/Widgets/foleys_SoftwareView.cpp diff --git a/Widgets/foleys_SoftwareView.h b/foleys_video_engine/Widgets/foleys_SoftwareView.h similarity index 100% rename from Widgets/foleys_SoftwareView.h rename to foleys_video_engine/Widgets/foleys_SoftwareView.h diff --git a/Widgets/foleys_VideoView.h b/foleys_video_engine/Widgets/foleys_VideoView.h similarity index 100% rename from Widgets/foleys_VideoView.h rename to foleys_video_engine/Widgets/foleys_VideoView.h diff --git a/foleys_video_engine.cpp b/foleys_video_engine/foleys_video_engine.cpp similarity index 100% rename from foleys_video_engine.cpp rename to foleys_video_engine/foleys_video_engine.cpp diff --git a/foleys_video_engine.h b/foleys_video_engine/foleys_video_engine.h similarity index 100% rename from foleys_video_engine.h rename to foleys_video_engine/foleys_video_engine.h diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a69c23d4..151a77b1 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -4,5 +4,5 @@ set (CMAKE_SUPPRESS_REGENERATION TRUE) # target_link_libraries (PluginTest PRIVATE Foleys::foleys_video_engine) juce_add_gui_app (AppTest) -target_link_libraries (AppTest PRIVATE Foleys::foleys_video_engine) +target_link_libraries (AppTest PRIVATE Foleys::foleys_video_engine Foleys::FoleysDefaultTarget) target_sources (AppTest PRIVATE TestAppMain.cpp) From 5b0fe54650d45324a5ca1d4a3b6423c44c8a097c Mon Sep 17 00:00:00 2001 From: Ben Vining Date: Tue, 1 Mar 2022 02:02:32 -0600 Subject: [PATCH 13/44] refactoring cmake --- cmake/FindFFmpeg.cmake | 2 - cmake/ffmpeg/BuildFFmpeg.cmake | 51 +++++++++++++---------- cmake/ffmpeg/configure_ffmpeg_build.cmake | 7 +--- 3 files changed, 31 insertions(+), 29 deletions(-) diff --git a/cmake/FindFFmpeg.cmake b/cmake/FindFFmpeg.cmake index 86b329ac..500c58df 100644 --- a/cmake/FindFFmpeg.cmake +++ b/cmake/FindFFmpeg.cmake @@ -22,8 +22,6 @@ if (NOT TARGET foleys_ffmpeg) message (FATAL_ERROR "Error creating foleys_ffmpeg target!") endif() -# customXcodeResourceFolders - target_compile_definitions (foleys_ffmpeg INTERFACE FOLEYS_USE_FFMPEG=1) add_library (Foleys::foleys_ffmpeg ALIAS foleys_ffmpeg) diff --git a/cmake/ffmpeg/BuildFFmpeg.cmake b/cmake/ffmpeg/BuildFFmpeg.cmake index b92cbe80..84679194 100644 --- a/cmake/ffmpeg/BuildFFmpeg.cmake +++ b/cmake/ffmpeg/BuildFFmpeg.cmake @@ -2,13 +2,18 @@ cmake_minimum_required (VERSION 3.15 FATAL_ERROR) include_guard (GLOBAL) +find_program (MAKE_EXECUTABLE NAMES make gmake + DOC "Path to the make executable used for building FFmpeg") + +if (NOT MAKE_EXECUTABLE) + message (FATAL_ERROR "Make could not be found, and is required to build FFmpeg!") +endif() + set (FFMPEG_CONFIGURE_EXTRAS "") set (FFMPEG_EXTRA_C_FLAGS "") set (FFMPEG_EXTRA_LD_FLAGS "") +set (FFMPEG_VERSION 4.4.1 CACHE STRING "FFmpeg version") -# - -set (FFMPEG_VERSION 4.4.1) set (FFMPEG_NAME "ffmpeg-${FFMPEG_VERSION}") set (FFMPEG_URL "https://ffmpeg.org/releases/${FFMPEG_NAME}.tar.bz2") @@ -33,7 +38,7 @@ if (NOT EXISTS "${FFMPEG_SOURCE_DIR}") file (DOWNLOAD "${FFMPEG_URL}" "${ffmpeg_tarball}") - execute_process (COMMAND ${CMAKE_COMMAND} -E tar xzf "${ffmpeg_tarball}" + execute_process (COMMAND "${CMAKE_COMMAND}" -E tar xzf "${ffmpeg_tarball}" WORKING_DIRECTORY "${FOLEYS_SOURCE_CACHE}") file (REMOVE "${ffmpeg_tarball}") @@ -57,9 +62,9 @@ set (FFMPEG_LD_FLAGS "${FFMPEG_C_FLAGS} ${FFMPEG_LD_FLAGS} ${FFMPEG_EXTRA_LD_FLA #set (HOST_BIN "${ANDROID_NDK}/prebuilt/${ANDROID_HOST_TAG}/bin") -if ("${CMAKE_ANDROID_ARCH_ABI}" STREQUAL x86) - list (APPEND FFMPEG_CONFIGURE_EXTRAS --disable-asm) -endif() +# if ("${CMAKE_ANDROID_ARCH_ABI}" STREQUAL x86) +# list (APPEND FFMPEG_CONFIGURE_EXTRAS --disable-asm) +# endif() string (REPLACE ";" "|" FFMPEG_CONFIGURE_EXTRAS_ENCODED "${FFMPEG_CONFIGURE_EXTRAS}") @@ -75,10 +80,10 @@ ExternalProject_Add (ffmpeg_build PREFIX ffmpeg URL "${FFMPEG_SOURCE_DIR}" DOWNLOAD_NO_EXTRACT 1 - CONFIGURE_COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/configure_ffmpeg_build.cmake" - BUILD_COMMAND make -j4 + CONFIGURE_COMMAND "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/configure_ffmpeg_build.cmake" + BUILD_COMMAND "${MAKE_EXECUTABLE}" -j4 BUILD_IN_SOURCE 1 - INSTALL_COMMAND make install + INSTALL_COMMAND "${MAKE_EXECUTABLE}" install STEP_TARGETS ffmpeg_copy_headers LOG_CONFIGURE 1 LOG_BUILD 1 @@ -92,28 +97,32 @@ configure_file ("${CMAKE_CURRENT_LIST_DIR}/copy_ffmpeg_headers.cmake" copy_ffmpe ExternalProject_Add_Step ( ffmpeg_build ffmpeg_copy_headers - COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/copy_ffmpeg_headers.cmake" + COMMAND "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/copy_ffmpeg_headers.cmake" DEPENDEES build DEPENDERS install ) # -function (foleys_make_lib_filename libname filename_out) +function (foleys_make_lib_filename libname filename_out libname_out) - set (output "") + set (filename "") + set (implibname "") if (CMAKE_SHARED_LIBRARY_PREFIX) - set (output "${CMAKE_SHARED_LIBRARY_PREFIX}") + set (filename "${CMAKE_SHARED_LIBRARY_PREFIX}") + set (implibname "${CMAKE_SHARED_LIBRARY_PREFIX}") endif() - set (output "${output}${libname}") + set (filename "${filename}${libname}") + set (implibname "${implibname}${libname}") if (CMAKE_SHARED_LIBRARY_SUFFIX) - set (output "${output}${CMAKE_SHARED_LIBRARY_SUFFIX}") + set (filename "${filename}${CMAKE_SHARED_LIBRARY_SUFFIX}") endif() - set (${filename_out} "${output}" PARENT_SCOPE) + set (${filename_out} "${filename}" PARENT_SCOPE) + set (${libname_out} "${implibname}.lib" PARENT_SCOPE) endfunction() @@ -125,11 +134,11 @@ foreach (ffmpeg_lib IN LISTS foleys_ffmpeg_libs) add_library (Foleys::${ffmpeg_lib} SHARED IMPORTED) - add_dependencies (Foleys::${ffmpeg_lib} ffmpeg_build) - - foleys_make_lib_filename (${ffmpeg_lib} lib_filename) + foleys_make_lib_filename (${ffmpeg_lib} lib_filename lib_libname) - set_target_properties (Foleys::${ffmpeg_lib} PROPERTIES IMPORTED_LOCATION "${FFMPEG_OUTPUT_DIR}/${lib_filename}") + set_target_properties (Foleys::${ffmpeg_lib} PROPERTIES + IMPORTED_LOCATION "${FFMPEG_OUTPUT_DIR}/${lib_filename}" + IMPORTED_IMPLIB "${FFMPEG_OUTPUT_DIR}/${lib_libname}") target_link_libraries (foleys_ffmpeg INTERFACE Foleys::${ffmpeg_lib}) diff --git a/cmake/ffmpeg/configure_ffmpeg_build.cmake b/cmake/ffmpeg/configure_ffmpeg_build.cmake index 140735b2..dc3b6756 100644 --- a/cmake/ffmpeg/configure_ffmpeg_build.cmake +++ b/cmake/ffmpeg/configure_ffmpeg_build.cmake @@ -12,7 +12,6 @@ set (CONFIGURE_COMMAND #--ranlib=@FFMPEG_RANLIB@ #--as=@FFMPEG_AS@ #--nm=@FFMPEG_NM@ - #--arch=@CMAKE_SYSTEM_PROCESSOR@ --disable-static --enable-shared --enable-protocol=file @@ -34,7 +33,6 @@ if ("@FFMPEG_LD_FLAGS@") endif() if ("@IOS@" OR "@ANDROID@") - set (CONFIGURE_COMMAND ${CONFIGURE_COMMAND} --enable-cross-compile @@ -45,21 +43,18 @@ if ("@IOS@" OR "@ANDROID@") endif() if ("@IOS@") - set (CONFIGURE_COMMAND ${CONFIGURE_COMMAND} --target-os=darwin) elseif ("@ANDROID@") - set (CONFIGURE_COMMAND ${CONFIGURE_COMMAND} --target-os=android) - endif() execute_process (COMMAND ${CONFIGURE_COMMAND} - WORKING_DIRECTORY @FFMPEG_SOURCE_DIR@ + WORKING_DIRECTORY "@FFMPEG_SOURCE_DIR@" COMMAND_ECHO STDOUT COMMAND_ERROR_IS_FATAL ANY) From 1c6078065a31a090d8629a13f0feb074699ca65c Mon Sep 17 00:00:00 2001 From: Ben Vining Date: Thu, 3 Mar 2022 03:45:17 -0600 Subject: [PATCH 14/44] cmake refactor: universal binary build of ffmpeg --- cmake/ffmpeg/BuildFFmpeg.cmake | 101 +---------- cmake/ffmpeg/ConfigureFFmpegBuild.cmake | 196 ++++++++++++++++++++++ cmake/ffmpeg/FFmpegMacBuild.cmake | 90 ++++++++++ cmake/ffmpeg/configure_ffmpeg_build.cmake | 60 ------- cmake/ffmpeg/copy_ffmpeg_headers.cmake | 8 - cmake/ffmpeg/mac_install_homebrew.sh | 7 + 6 files changed, 296 insertions(+), 166 deletions(-) create mode 100644 cmake/ffmpeg/ConfigureFFmpegBuild.cmake create mode 100644 cmake/ffmpeg/FFmpegMacBuild.cmake delete mode 100644 cmake/ffmpeg/configure_ffmpeg_build.cmake delete mode 100644 cmake/ffmpeg/copy_ffmpeg_headers.cmake create mode 100644 cmake/ffmpeg/mac_install_homebrew.sh diff --git a/cmake/ffmpeg/BuildFFmpeg.cmake b/cmake/ffmpeg/BuildFFmpeg.cmake index 84679194..94aee42b 100644 --- a/cmake/ffmpeg/BuildFFmpeg.cmake +++ b/cmake/ffmpeg/BuildFFmpeg.cmake @@ -14,7 +14,7 @@ set (FFMPEG_EXTRA_C_FLAGS "") set (FFMPEG_EXTRA_LD_FLAGS "") set (FFMPEG_VERSION 4.4.1 CACHE STRING "FFmpeg version") -set (FFMPEG_NAME "ffmpeg-${FFMPEG_VERSION}") +set (FFMPEG_NAME "ffmpeg-${FFMPEG_VERSION}" CACHE INTERNAL "") set (FFMPEG_URL "https://ffmpeg.org/releases/${FFMPEG_NAME}.tar.bz2") if (DEFINED ENV{CPM_SOURCE_CACHE}) @@ -24,7 +24,6 @@ else() endif() set (FFMPEG_SOURCE_DIR "${FOLEYS_SOURCE_CACHE}/${FFMPEG_NAME}") -set (FFMPEG_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/ffmpeg") # @@ -47,107 +46,13 @@ endif() # -set (FFMPEG_CC "${CMAKE_C_COMPILER}") - -#set (FFMPEG_C_FLAGS "${CMAKE_C_FLAGS} --target=${ANDROID_LLVM_TRIPLE} --gcc-toolchain=${ANDROID_TOOLCHAIN_ROOT} ${FFMPEG_EXTRA_C_FLAGS}") - string (REPLACE " -Wl,--fatal-warnings" "" FFMPEG_LD_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") set (FFMPEG_LD_FLAGS "${FFMPEG_C_FLAGS} ${FFMPEG_LD_FLAGS} ${FFMPEG_EXTRA_LD_FLAGS}") -#set (FFMPEG_AR "${ANDROID_AR}") -#set (FFMPEG_AS "${ANDROID_ASM_COMPILER}") -#set (FFMPEG_RANLIB "${ANDROID_TOOLCHAIN_PREFIX}ranlib${ANDROID_TOOLCHAIN_SUFFIX}") -#set (FFMPEG_STRIP "${ANDROID_TOOLCHAIN_ROOT}/bin/llvm-strip${ANDROID_TOOLCHAIN_SUFFIX}") -#set (FFMPEG_NM "${ANDROID_TOOLCHAIN_PREFIX}nm${ANDROID_TOOLCHAIN_SUFFIX}") - -#set (HOST_BIN "${ANDROID_NDK}/prebuilt/${ANDROID_HOST_TAG}/bin") - -# if ("${CMAKE_ANDROID_ARCH_ABI}" STREQUAL x86) -# list (APPEND FFMPEG_CONFIGURE_EXTRAS --disable-asm) -# endif() - -string (REPLACE ";" "|" FFMPEG_CONFIGURE_EXTRAS_ENCODED "${FFMPEG_CONFIGURE_EXTRAS}") - -# - -## FFMPEG_ASM_FLAGS ? - -include (ExternalProject) - -configure_file ("${CMAKE_CURRENT_LIST_DIR}/configure_ffmpeg_build.cmake" configure_ffmpeg_build.cmake @ONLY) - -ExternalProject_Add (ffmpeg_build - PREFIX ffmpeg - URL "${FFMPEG_SOURCE_DIR}" - DOWNLOAD_NO_EXTRACT 1 - CONFIGURE_COMMAND "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/configure_ffmpeg_build.cmake" - BUILD_COMMAND "${MAKE_EXECUTABLE}" -j4 - BUILD_IN_SOURCE 1 - INSTALL_COMMAND "${MAKE_EXECUTABLE}" install - STEP_TARGETS ffmpeg_copy_headers - LOG_CONFIGURE 1 - LOG_BUILD 1 - LOG_INSTALL 1 -) - -ExternalProject_Get_Property (ffmpeg_build SOURCE_DIR) - -configure_file ("${CMAKE_CURRENT_LIST_DIR}/copy_ffmpeg_headers.cmake" copy_ffmpeg_headers.cmake @ONLY) - -ExternalProject_Add_Step ( - ffmpeg_build - ffmpeg_copy_headers - COMMAND "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/copy_ffmpeg_headers.cmake" - DEPENDEES build - DEPENDERS install -) - -# - -function (foleys_make_lib_filename libname filename_out libname_out) - - set (filename "") - set (implibname "") - - if (CMAKE_SHARED_LIBRARY_PREFIX) - set (filename "${CMAKE_SHARED_LIBRARY_PREFIX}") - set (implibname "${CMAKE_SHARED_LIBRARY_PREFIX}") - endif() - - set (filename "${filename}${libname}") - set (implibname "${implibname}${libname}") - - if (CMAKE_SHARED_LIBRARY_SUFFIX) - set (filename "${filename}${CMAKE_SHARED_LIBRARY_SUFFIX}") - endif() - - set (${filename_out} "${filename}" PARENT_SCOPE) - set (${libname_out} "${implibname}.lib" PARENT_SCOPE) - -endfunction() - # -add_library (foleys_ffmpeg INTERFACE) - -foreach (ffmpeg_lib IN LISTS foleys_ffmpeg_libs) - - add_library (Foleys::${ffmpeg_lib} SHARED IMPORTED) - - foleys_make_lib_filename (${ffmpeg_lib} lib_filename lib_libname) - - set_target_properties (Foleys::${ffmpeg_lib} PROPERTIES - IMPORTED_LOCATION "${FFMPEG_OUTPUT_DIR}/${lib_filename}" - IMPORTED_IMPLIB "${FFMPEG_OUTPUT_DIR}/${lib_libname}") - - target_link_libraries (foleys_ffmpeg INTERFACE Foleys::${ffmpeg_lib}) - -endforeach() - -# +include ("${CMAKE_CURRENT_LIST_DIR}/ConfigureFFmpegBuild.cmake") -add_dependencies (foleys_ffmpeg ffmpeg_build) +foleys_configure_ffmpeg_build (SOURCE_DIR "${FFMPEG_SOURCE_DIR}") -target_link_directories (foleys_ffmpeg INTERFACE "${FFMPEG_OUTPUT_DIR}") -target_include_directories (foleys_ffmpeg INTERFACE "${FFMPEG_OUTPUT_DIR}/include") diff --git a/cmake/ffmpeg/ConfigureFFmpegBuild.cmake b/cmake/ffmpeg/ConfigureFFmpegBuild.cmake new file mode 100644 index 00000000..3b828c0e --- /dev/null +++ b/cmake/ffmpeg/ConfigureFFmpegBuild.cmake @@ -0,0 +1,196 @@ +cmake_minimum_required (VERSION 3.15 FATAL_ERROR) + +include_guard (GLOBAL) + +if (APPLE AND NOT IOS) + include ("${CMAKE_CURRENT_LIST_DIR}/FFmpegMacBuild.cmake") +endif() + + +# + +# Runs FFmpeg's configure script (at CMake configure time) +function (foleys_preconfigure_ffmpeg_build) + + set (options "") + set (oneValueArgs OUTPUT_DIR SOURCE_DIR EXTRA_ARGS C_FLAGS LD_FLAGS) + set (multiValueArgs "") + + cmake_parse_arguments (FOLEYS_ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if (NOT FOLEYS_ARG_OUTPUT_DIR) + message (FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} called without required argument OUTPUT_DIR!") + endif() + + if (NOT FOLEYS_ARG_SOURCE_DIR) + message (FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} called without required argument SOURCE_DIR!") + endif() + + set (CONFIGURE_COMMAND + "./configure + --disable-static + --disable-doc + --enable-shared + --enable-protocol=file + --shlibdir=${FOLEYS_ARG_OUTPUT_DIR} + --libdir=${FOLEYS_ARG_OUTPUT_DIR} + --incdir=${FOLEYS_ARG_OUTPUT_DIR}/include + --prefix=${FOLEYS_ARG_OUTPUT_DIR}") + + if (FOLEYS_ARG_EXTRA_ARGS) + set (CONFIGURE_COMMAND "${CONFIGURE_COMMAND} ${FOLEYS_ARG_EXTRA_ARGS}") + endif() + + if (FOLEYS_ARG_C_FLAGS) + set (CONFIGURE_COMMAND "${CONFIGURE_COMMAND} --extra-cflags=${FOLEYS_ARG_C_FLAGS}") + endif() + + if (FOLEYS_ARG_LD_FLAGS) + set (CONFIGURE_COMMAND "${CONFIGURE_COMMAND} --extra-ldflags=${FOLEYS_ARG_LD_FLAGS}") + endif() + + if (CMAKE_SYSROOT) + set (CONFIGURE_COMMAND "${CONFIGURE_COMMAND} --sysroot=${CMAKE_SYSROOT}") + endif() + + if (IOS OR ANDROID) + set (CONFIGURE_COMMAND + "${CONFIGURE_COMMAND} + --enable-cross-compile + --disable-programs + --enable-pic" + ) + + if (IOS) + set (CONFIGURE_COMMAND "${CONFIGURE_COMMAND} --target-os=darwin") + elseif (ANDROID) + set (CONFIGURE_COMMAND "${CONFIGURE_COMMAND} --target-os=android") + endif() + endif() + + separate_arguments (ffmpeg_config_command UNIX_COMMAND "${CONFIGURE_COMMAND}") + + execute_process (COMMAND ${ffmpeg_config_command} + WORKING_DIRECTORY "${FOLEYS_ARG_SOURCE_DIR}" + COMMAND_ECHO STDOUT + COMMAND_ERROR_IS_FATAL ANY) + +endfunction() + +# + +# Creates targets that execute the FFmpeg build and can be linked to from elsewhere in CMake +# BUILD_TARGET - name used for the actual underlying custom command target that executes the FFmpeg build +function (foleys_create_ffmpeg_build_target) + + set (options "") + set (oneValueArgs BUILD_TARGET SOURCE_DIR OUTPUT_DIR) + set (multiValueArgs "") + + cmake_parse_arguments (FOLEYS_ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if (NOT FOLEYS_ARG_BUILD_TARGET) + message (FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} called without required argument BUILD_TARGET!") + endif() + + if (NOT FOLEYS_ARG_SOURCE_DIR) + message (FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} called without required argument SOURCE_DIR!") + endif() + + if (NOT FOLEYS_ARG_OUTPUT_DIR) + message (FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} called without required argument OUTPUT_DIR!") + endif() + + # + + function (foleys_make_lib_filename libname filename_out) + + set (filename "") + + if (CMAKE_SHARED_LIBRARY_PREFIX) + set (filename "${CMAKE_SHARED_LIBRARY_PREFIX}") + endif() + + set (filename "${filename}${libname}") + + if (CMAKE_SHARED_LIBRARY_SUFFIX) + set (filename "${filename}${CMAKE_SHARED_LIBRARY_SUFFIX}") + endif() + + set (${filename_out} "${filename}" PARENT_SCOPE) + + endfunction() + + # + + # the target should only already exist if this is a Mac universal binary build... + if (NOT TARGET foleys_ffmpeg) + add_library (foleys_ffmpeg INTERFACE) + endif() + + #set (ffmpeg_libs_input_files "") + set (ffmpeg_libs_output_files "") + + foreach (libname ${foleys_ffmpeg_libs}) + foleys_make_lib_filename ("${libname}" libfilename) + + #list (APPEND ffmpeg_libs_input_files "${FOLEYS_ARG_OUTPUT_DIR}/${libfilename}") + list (APPEND ffmpeg_libs_output_files "${FOLEYS_ARG_OUTPUT_DIR}/${libfilename}") + + target_link_libraries (foleys_ffmpeg INTERFACE "${FOLEYS_ARG_OUTPUT_DIR}/${libfilename}") + + endforeach() + + # + + add_custom_target ("${FOLEYS_ARG_BUILD_TARGET}" + COMMAND "${MAKE_EXECUTABLE}" -j4 + WORKING_DIRECTORY "${FOLEYS_ARG_SOURCE_DIR}" + COMMENT "Building FFmpeg..." + VERBATIM USES_TERMINAL) + #BYPRODUCTS "${ffmpeg_libs_input_files}") + + add_custom_command (TARGET "${FOLEYS_ARG_BUILD_TARGET}" + POST_BUILD + COMMAND "${MAKE_EXECUTABLE}" install + BYPRODUCTS "${ffmpeg_libs_output_files}" + WORKING_DIRECTORY "${FOLEYS_ARG_SOURCE_DIR}" + VERBATIM USES_TERMINAL) + + add_dependencies (foleys_ffmpeg "${FOLEYS_ARG_BUILD_TARGET}") + +endfunction() + +# + +function (foleys_configure_ffmpeg_build) + + set (options "") + set (oneValueArgs SOURCE_DIR) + set (multiValueArgs "") + + cmake_parse_arguments (FOLEYS_ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if (NOT FOLEYS_ARG_SOURCE_DIR) + message (FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} called without required argument SOURCE_DIR!") + endif() + + set (outputDir "${CMAKE_CURRENT_BINARY_DIR}/ffmpeg") + + if (APPLE AND NOT IOS) + foleys_configure_ffmpeg_macos_universal_binary_build (SOURCE_DIR "${FOLEYS_ARG_SOURCE_DIR}" + OUTPUT_DIR "${outputDir}") + else() + message (STATUS "Configuring FFmpeg build...") + + foleys_preconfigure_ffmpeg_build (SOURCE_DIR "${FOLEYS_ARG_SOURCE_DIR}" + OUTPUT_DIR "${outputDir}") + + foleys_create_ffmpeg_build_target (SOURCE_DIR "${FOLEYS_ARG_SOURCE_DIR}" + OUTPUT_DIR "${outputDir}" + BUILD_TARGET ffmpeg_build) + endif() + + target_include_directories (foleys_ffmpeg INTERFACE "${outputDir}/include") + +endfunction() diff --git a/cmake/ffmpeg/FFmpegMacBuild.cmake b/cmake/ffmpeg/FFmpegMacBuild.cmake new file mode 100644 index 00000000..e96f62d2 --- /dev/null +++ b/cmake/ffmpeg/FFmpegMacBuild.cmake @@ -0,0 +1,90 @@ +cmake_minimum_required (VERSION 3.15 FATAL_ERROR) + +include_guard (GLOBAL) + +# + +find_program (YASM yasm) + +if (NOT YASM) # install yasm via Homebrew + + find_program (HOMEBREW brew) + + if (NOT HOMEBREW) + unset (CACHE{HOMEBREW}) + + find_program (BASH bash) + + if (NOT BASH) + message (FATAL_ERROR "bash is required for installing Homebrew, and cannot be found!") + endif() + + message (STATUS "Installing Homebrew...") + + execute_process (COMMAND "${BASH}" "${CMAKE_CURRENT_LIST_DIR}/mac_install_homebrew.sh" + COMMAND_ECHO STDOUT + COMMAND_ERROR_IS_FATAL ANY) + + find_program (HOMEBREW brew) + + if (NOT HOMEBREW) + message (FATAL_ERROR "Error installing Homebrew!") + endif() + endif() + + execute_process (COMMAND "${HOMEBREW}" install yasm + COMMAND_ECHO STDOUT + COMMAND_ERROR_IS_FATAL ANY) +endif() + +# + +function (foleys_configure_ffmpeg_macos_universal_binary_build) + + set (options "") + set (oneValueArgs SOURCE_DIR OUTPUT_DIR) + set (multiValueArgs "") + + cmake_parse_arguments (FOLEYS_ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if (NOT FOLEYS_ARG_SOURCE_DIR) + message (FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} called without required argument SOURCE_DIR!") + endif() + + if (NOT FOLEYS_ARG_OUTPUT_DIR) + message (FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} called without required argument OUTPUT_DIR!") + endif() + + set (FFMPEG_ARCHITECTURES "x86_64;arm64") + + foreach (arch ${FFMPEG_ARCHITECTURES}) + + message (STATUS "Configuring FFmpeg build for arch ${arch}...") + + set (sourceDir "${CMAKE_CURRENT_BINARY_DIR}/ffmpeg_arch_sources/${arch}/${FFMPEG_NAME}") + + # each arch needs its own copy of the source tree ¯\_(ツ)_/¯ + file (COPY "${FOLEYS_ARG_SOURCE_DIR}" + DESTINATION "${sourceDir}/.." # silly cmake adds an extra nested directory when copying + USE_SOURCE_PERMISSIONS + FOLLOW_SYMLINK_CHAIN) + + set (outputDir "${FOLEYS_ARG_OUTPUT_DIR}/${arch}") + + foleys_preconfigure_ffmpeg_build (SOURCE_DIR "${sourceDir}" + OUTPUT_DIR "${outputDir}" + EXTRA_ARGS "--arch=${arch} --target-os=darwin") + + foleys_create_ffmpeg_build_target (SOURCE_DIR "${sourceDir}" + OUTPUT_DIR "${outputDir}" + BUILD_TARGET "ffmpeg_build_${arch}") + endforeach() + + # Need to manually copy headers... + file (GLOB libs ${FOLEYS_ARG_SOURCE_DIR}/lib*) + + file (COPY ${libs} "${FOLEYS_ARG_SOURCE_DIR}/config.h" "${FOLEYS_ARG_SOURCE_DIR}/compat" + DESTINATION "${FOLEYS_ARG_OUTPUT_DIR}/include" + FILES_MATCHING PATTERN *.h) + +endfunction() diff --git a/cmake/ffmpeg/configure_ffmpeg_build.cmake b/cmake/ffmpeg/configure_ffmpeg_build.cmake deleted file mode 100644 index dc3b6756..00000000 --- a/cmake/ffmpeg/configure_ffmpeg_build.cmake +++ /dev/null @@ -1,60 +0,0 @@ -cmake_minimum_required (VERSION 3.15 FATAL_ERROR) - -string (REPLACE "|" ";" CONFIGURE_EXTRAS_ENCODED "@FFMPEG_CONFIGURE_EXTRAS_ENCODED@") -list (REMOVE_ITEM CONFIGURE_EXTRAS_ENCODED "") -list (REMOVE_DUPLICATES CONFIGURE_EXTRAS_ENCODED) - -set (CONFIGURE_COMMAND - ./configure - #--cc=@FFMPEG_CC@ - #--ar=@FFMPEG_AR@ - #--strip=@FFMPEG_STRIP@ - #--ranlib=@FFMPEG_RANLIB@ - #--as=@FFMPEG_AS@ - #--nm=@FFMPEG_NM@ - --disable-static - --enable-shared - --enable-protocol=file - --shlibdir=@FFMPEG_OUTPUT_DIR@ - --prefix=@FFMPEG_OUTPUT_DIR@ - ${CONFIGURE_EXTRAS_ENCODED} -) - -if ("@CMAKE_SYSROOT@") - set (CONFIGURE_COMMAND "${CONFIGURE_COMMAND} --sysroot=@CMAKE_SYSROOT@") -endif() - -if ("@FFMPEG_C_FLAGS@") - set (CONFIGURE_COMMAND "${CONFIGURE_COMMAND} --extra-cflags=@FFMPEG_C_FLAGS@") -endif() - -if ("@FFMPEG_LD_FLAGS@") - set (CONFIGURE_COMMAND "${CONFIGURE_COMMAND} --extra-ldflags=@FFMPEG_LD_FLAGS@") -endif() - -if ("@IOS@" OR "@ANDROID@") - set (CONFIGURE_COMMAND - ${CONFIGURE_COMMAND} - --enable-cross-compile - --disable-programs - --disable-doc - --enable-pic - ) -endif() - -if ("@IOS@") - set (CONFIGURE_COMMAND - ${CONFIGURE_COMMAND} - --target-os=darwin) - -elseif ("@ANDROID@") - set (CONFIGURE_COMMAND - ${CONFIGURE_COMMAND} - --target-os=android) -endif() - - -execute_process (COMMAND ${CONFIGURE_COMMAND} - WORKING_DIRECTORY "@FFMPEG_SOURCE_DIR@" - COMMAND_ECHO STDOUT - COMMAND_ERROR_IS_FATAL ANY) diff --git a/cmake/ffmpeg/copy_ffmpeg_headers.cmake b/cmake/ffmpeg/copy_ffmpeg_headers.cmake deleted file mode 100644 index a5d696a8..00000000 --- a/cmake/ffmpeg/copy_ffmpeg_headers.cmake +++ /dev/null @@ -1,8 +0,0 @@ -cmake_minimum_required (VERSION 3.15 FATAL_ERROR) - -file (GLOB libs "@FFMPEG_SOURCE_DIR@/lib*") - -file (COPY ${libs} @SOURCE_DIR@/config.h @FFMPEG_SOURCE_DIR@/compat - DESTINATION @FFMPEG_OUTPUT_DIR@/include - FILES_MATCHING PATTERN *.h -) diff --git a/cmake/ffmpeg/mac_install_homebrew.sh b/cmake/ffmpeg/mac_install_homebrew.sh new file mode 100644 index 00000000..6760b92a --- /dev/null +++ b/cmake/ffmpeg/mac_install_homebrew.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -euo pipefail + +/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + +exit 0 From 8f179b56f3efa16a97e904be28483a0c3f8f82d8 Mon Sep 17 00:00:00 2001 From: Ben Vining Date: Thu, 3 Mar 2022 04:02:44 -0600 Subject: [PATCH 15/44] disabled assembly to fix ffmpeg compile error --- cmake/ffmpeg/ConfigureFFmpegBuild.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/ffmpeg/ConfigureFFmpegBuild.cmake b/cmake/ffmpeg/ConfigureFFmpegBuild.cmake index 3b828c0e..272f8dda 100644 --- a/cmake/ffmpeg/ConfigureFFmpegBuild.cmake +++ b/cmake/ffmpeg/ConfigureFFmpegBuild.cmake @@ -30,6 +30,7 @@ function (foleys_preconfigure_ffmpeg_build) "./configure --disable-static --disable-doc + --disable-asm --enable-shared --enable-protocol=file --shlibdir=${FOLEYS_ARG_OUTPUT_DIR} From 465b99a070a01ec639862ff38233dcd4761ca8d4 Mon Sep 17 00:00:00 2001 From: Ben Vining Date: Tue, 15 Mar 2022 14:21:49 -0500 Subject: [PATCH 16/44] refactor: various cmake refactors --- CMakeLists.txt | 13 +++---- cmake/FindFFmpeg.cmake | 38 ++++++++++++++------ cmake/FindJUCE.cmake | 6 ++++ cmake/FoleysDefaultSettings.cmake | 34 ++++-------------- cmake/ffmpeg/BuildFFmpeg.cmake | 23 ++++++++----- cmake/ffmpeg/ConfigureFFmpegBuild.cmake | 38 ++++++++++---------- cmake/ffmpeg/FFmpegMacBuild.cmake | 46 +++++++++++++++++++++---- cmake/ffmpeg/FindInstalledFFmpeg.cmake | 6 ++-- tests/CMakeLists.txt | 8 ----- tests/TestAppMain.cpp | 16 --------- 10 files changed, 121 insertions(+), 107 deletions(-) delete mode 100644 tests/CMakeLists.txt delete mode 100644 tests/TestAppMain.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index a9a95f03..42760fb7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,18 +10,13 @@ list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") include (FoleysDefaultSettings) include (FoleysDefaultTarget) -include (FindJUCE) -include (FindFFmpeg) + +find_package (JUCE REQUIRED) +find_package (FFmpeg REQUIRED) juce_add_module ("${CMAKE_CURRENT_LIST_DIR}/foleys_video_engine" ALIAS_NAMESPACE Foleys) target_compile_definitions (foleys_video_engine INTERFACE JUCE_MODAL_LOOPS_PERMITTED=1 JUCE_STRICT_REFCOUNTEDPOINTER=1 JUCE_PLUGINHOST_AU=1 JUCE_PLUGINHOST_VST3=1 JUCE_PLUGINHOST_LADSPA=1) -target_link_libraries (foleys_video_engine INTERFACE Foleys::foleys_ffmpeg Foleys::FoleysDefaultTarget) - -option (FOLEYS_BUILD_TESTS "" OFF) - -if (FOLEYS_BUILD_TESTS) - add_subdirectory (tests) -endif() +target_link_libraries (foleys_video_engine INTERFACE ffmpeg::ffmpeg Foleys::FoleysDefaultTarget) diff --git a/cmake/FindFFmpeg.cmake b/cmake/FindFFmpeg.cmake index 500c58df..0dd25b1c 100644 --- a/cmake/FindFFmpeg.cmake +++ b/cmake/FindFFmpeg.cmake @@ -2,26 +2,44 @@ cmake_minimum_required (VERSION 3.15 FATAL_ERROR) include_guard (GLOBAL) -set (foleys_ffmpeg_libs avutil swresample avcodec avformat swscale CACHE INTERNAL "") +include (FeatureSummary) -option (FOLEYS_USE_SYSTEM_FFMPEG "Use preinstalled ffmpeg found on system, if any" OFF) +set_package_properties (FFmpeg PROPERTIES + URL "https://www.ffmpeg.org/" + DESCRIPTION "Open source library for audio and video codecs") -if (FOLEYS_USE_SYSTEM_FFMPEG) +set (FFmpeg_FOUND FALSE) + +set (FFMPEG_LIBS avutil swresample avcodec avformat swscale CACHE INTERNAL "") + +option (FFMPEG_USE_SYSTEM_INSTALL "Use preinstalled ffmpeg found on system, if any" OFF) + +if (FFMPEG_USE_SYSTEM_INSTALL) include ("${CMAKE_CURRENT_LIST_DIR}/ffmpeg/FindInstalledFFmpeg.cmake") endif() -if (NOT TARGET foleys_ffmpeg) - if (FOLEYS_USE_SYSTEM_FFMPEG) - message (WARNING "System installation of FFmpeg was requested, but targets couldn't be imported. Configuring to build from source...") +if (TARGET ffmpeg) + if (NOT FFmpeg_FIND_QUIETLY) + message (STATUS "Using system installation of FFmpeg") + endif() +else() + if (FFMPEG_USE_SYSTEM_INSTALL) + if (NOT FFmpeg_FIND_QUIETLY) + message (WARNING "System installation of FFmpeg was requested, but targets couldn't be imported. Configuring to build from source...") + endif() endif() include ("${CMAKE_CURRENT_LIST_DIR}/ffmpeg/BuildFFmpeg.cmake") endif() -if (NOT TARGET foleys_ffmpeg) - message (FATAL_ERROR "Error creating foleys_ffmpeg target!") +if (NOT TARGET ffmpeg) + if (FFmpeg_FIND_REQUIRED) + message (FATAL_ERROR "Error creating ffmpeg target!") + endif() endif() -target_compile_definitions (foleys_ffmpeg INTERFACE FOLEYS_USE_FFMPEG=1) +target_compile_definitions (ffmpeg INTERFACE FOLEYS_USE_FFMPEG=1) + +add_library (ffmpeg::ffmpeg ALIAS ffmpeg) -add_library (Foleys::foleys_ffmpeg ALIAS foleys_ffmpeg) +set (FFmpeg_FOUND TRUE) diff --git a/cmake/FindJUCE.cmake b/cmake/FindJUCE.cmake index 0990edf9..30853199 100644 --- a/cmake/FindJUCE.cmake +++ b/cmake/FindJUCE.cmake @@ -2,6 +2,11 @@ cmake_minimum_required (VERSION 3.15 FATAL_ERROR) include_guard (GLOBAL) +include (FeatureSummary) + +set_package_properties (JUCE PROPERTIES URL "https://juce.com/" + DESCRIPTION "Cross platform framework for plugin and app development") + include ("${CMAKE_CURRENT_LIST_DIR}/AddCPM.cmake") CPMAddPackage (NAME JUCE @@ -9,3 +14,4 @@ CPMAddPackage (NAME JUCE GIT_TAG origin/develop OPTIONS "JUCE_BUILD_EXAMPLES OFF" "JUCE_BUILD_EXTRAS OFF" "JUCE_ENABLE_MODULE_SOURCE_GROUPS ON") +set (JUCE_FOUND TRUE) \ No newline at end of file diff --git a/cmake/FoleysDefaultSettings.cmake b/cmake/FoleysDefaultSettings.cmake index e583945c..e0a17cfc 100644 --- a/cmake/FoleysDefaultSettings.cmake +++ b/cmake/FoleysDefaultSettings.cmake @@ -5,7 +5,7 @@ include_guard (GLOBAL) set_property (GLOBAL PROPERTY USE_FOLDERS YES) set (ENV{CMAKE_EXPORT_COMPILE_COMMANDS} TRUE) -set (CMAKE_EXPORT_COMPILE_COMMANDS TRUE CACHE INTERNAL "") +set (CMAKE_EXPORT_COMPILE_COMMANDS TRUE) if (NOT DEFINED ENV{CMAKE_INSTALL_MODE}) set (ENV{CMAKE_INSTALL_MODE} ABS_SYMLINK_OR_COPY) @@ -22,14 +22,12 @@ if(result) endif() -# platform settings - if(APPLE) if(IOS) set (ENV{MACOSX_DEPLOYMENT_TARGET} 9.3) - set (CMAKE_OSX_DEPLOYMENT_TARGET "9.3" CACHE INTERNAL "") + set (CMAKE_OSX_DEPLOYMENT_TARGET 9.3) - set (CMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH NO CACHE INTERNAL "") + set (CMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH NO) option (FOLEYS_IOS_SIMULATOR "Build for an iOS simulator, rather than a real device" ON) @@ -55,21 +53,7 @@ if(APPLE) endif() else() set (ENV{MACOSX_DEPLOYMENT_TARGET} 10.11) - set (CMAKE_OSX_DEPLOYMENT_TARGET "10.11" CACHE INTERNAL "") - - set (FOLEYS_MAC_SDK_VERSION "10.13" CACHE STRING "") - mark_as_advanced (FOLEYS_MAC_SDK_VERSION FORCE) - - set ( - MAC_SDK_DIR - "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${FOLEYS_MAC_SDK_VERSION}.sdk" - ) - - if(IS_DIRECTORY ${MAC_SDK_DIR}) - set (CMAKE_OSX_SYSROOT ${MAC_SDK_DIR} CACHE INTERNAL "") - else() - message (DEBUG "Mac SDK dir ${MAC_SDK_DIR} doesn't exist!") - endif() + set (CMAKE_OSX_DEPLOYMENT_TARGET 10.11) option (FOLEYS_MAC_UNIVERSAL_BINARY "Builds for x86_64 and arm64" ON) @@ -79,16 +63,10 @@ if(APPLE) endif() endif() else() - set (CMAKE_INSTALL_RPATH $ORIGIN CACHE INTERNAL "") + set (CMAKE_INSTALL_RPATH $ORIGIN) if(WIN32) - set (CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" CACHE INTERNAL "") - else() - # fixes a bug with LTO on Ubuntu with Clang - set (CMAKE_AR ${CMAKE_CXX_COMPILER_AR} CACHE PATH "AR" FORCE) - set (CMAKE_RANLIB ${CMAKE_CXX_COMPILER_RANLIB} CACHE PATH "RANLIB" FORCE) - - mark_as_advanced (CMAKE_AR CMAKE_RANLIB FORCE) + set (CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") endif() endif() diff --git a/cmake/ffmpeg/BuildFFmpeg.cmake b/cmake/ffmpeg/BuildFFmpeg.cmake index 94aee42b..da557a60 100644 --- a/cmake/ffmpeg/BuildFFmpeg.cmake +++ b/cmake/ffmpeg/BuildFFmpeg.cmake @@ -2,20 +2,23 @@ cmake_minimum_required (VERSION 3.15 FATAL_ERROR) include_guard (GLOBAL) -find_program (MAKE_EXECUTABLE NAMES make gmake +find_program (FFMPEG_MAKE_EXECUTABLE NAMES make gmake nmake DOC "Path to the make executable used for building FFmpeg") -if (NOT MAKE_EXECUTABLE) +mark_as_advanced (FORCE FFMPEG_MAKE_EXECUTABLE) + +if (NOT FFMPEG_MAKE_EXECUTABLE) message (FATAL_ERROR "Make could not be found, and is required to build FFmpeg!") endif() -set (FFMPEG_CONFIGURE_EXTRAS "") -set (FFMPEG_EXTRA_C_FLAGS "") -set (FFMPEG_EXTRA_LD_FLAGS "") +set (FFMPEG_CONFIGURE_EXTRAS "" CACHE STRING "Extra flags passed to FFmpeg's configuration script") +set (FFMPEG_EXTRA_C_FLAGS "" CACHE STRING "Extra C flags for FFmpeg") +set (FFMPEG_EXTRA_LD_FLAGS "" CACHE STRING "Extra linker flags for FFmpeg") set (FFMPEG_VERSION 4.4.1 CACHE STRING "FFmpeg version") -set (FFMPEG_NAME "ffmpeg-${FFMPEG_VERSION}" CACHE INTERNAL "") -set (FFMPEG_URL "https://ffmpeg.org/releases/${FFMPEG_NAME}.tar.bz2") +mark_as_advanced (FORCE FFMPEG_CONFIGURE_EXTRAS FFMPEG_EXTRA_C_FLAGS FFMPEG_EXTRA_LD_FLAGS FFMPEG_VERSION) + +set (FFMPEG_NAME "ffmpeg-${FFMPEG_VERSION}") if (DEFINED ENV{CPM_SOURCE_CACHE}) set (FOLEYS_SOURCE_CACHE "$ENV{CPM_SOURCE_CACHE}") @@ -29,7 +32,11 @@ set (FFMPEG_SOURCE_DIR "${FOLEYS_SOURCE_CACHE}/${FFMPEG_NAME}") if (NOT EXISTS "${FFMPEG_SOURCE_DIR}") - message (STATUS "Downloading FFmpeg sources from ${FFMPEG_URL} to ${FFMPEG_SOURCE_DIR}...") + set (FFMPEG_URL "https://ffmpeg.org/releases/${FFMPEG_NAME}.tar.bz2") + + if (NOT FFmpeg_FIND_QUIETLY) + message (STATUS "Downloading FFmpeg sources from ${FFMPEG_URL} to ${FFMPEG_SOURCE_DIR}...") + endif() get_filename_component (FFMPEG_ARCHIVE_NAME "${FFMPEG_URL}" NAME) diff --git a/cmake/ffmpeg/ConfigureFFmpegBuild.cmake b/cmake/ffmpeg/ConfigureFFmpegBuild.cmake index 272f8dda..5d8fb2e0 100644 --- a/cmake/ffmpeg/ConfigureFFmpegBuild.cmake +++ b/cmake/ffmpeg/ConfigureFFmpegBuild.cmake @@ -71,9 +71,13 @@ function (foleys_preconfigure_ffmpeg_build) separate_arguments (ffmpeg_config_command UNIX_COMMAND "${CONFIGURE_COMMAND}") + if (NOT FFmpeg_FIND_QUIETLY) + set (cmd_echo_flag COMMAND_ECHO STDOUT) + endif() + execute_process (COMMAND ${ffmpeg_config_command} WORKING_DIRECTORY "${FOLEYS_ARG_SOURCE_DIR}" - COMMAND_ECHO STDOUT + ${cmd_echo_flag} COMMAND_ERROR_IS_FATAL ANY) endfunction() @@ -125,40 +129,36 @@ function (foleys_create_ffmpeg_build_target) # # the target should only already exist if this is a Mac universal binary build... - if (NOT TARGET foleys_ffmpeg) - add_library (foleys_ffmpeg INTERFACE) + if (NOT TARGET ffmpeg) + add_library (ffmpeg INTERFACE) endif() - #set (ffmpeg_libs_input_files "") set (ffmpeg_libs_output_files "") - foreach (libname ${foleys_ffmpeg_libs}) + foreach (libname ${FFMPEG_LIBS}) foleys_make_lib_filename ("${libname}" libfilename) - #list (APPEND ffmpeg_libs_input_files "${FOLEYS_ARG_OUTPUT_DIR}/${libfilename}") list (APPEND ffmpeg_libs_output_files "${FOLEYS_ARG_OUTPUT_DIR}/${libfilename}") - target_link_libraries (foleys_ffmpeg INTERFACE "${FOLEYS_ARG_OUTPUT_DIR}/${libfilename}") - + target_link_libraries (ffmpeg INTERFACE "${FOLEYS_ARG_OUTPUT_DIR}/${libfilename}") endforeach() # add_custom_target ("${FOLEYS_ARG_BUILD_TARGET}" - COMMAND "${MAKE_EXECUTABLE}" -j4 + COMMAND "${FFMPEG_MAKE_EXECUTABLE}" -j4 WORKING_DIRECTORY "${FOLEYS_ARG_SOURCE_DIR}" COMMENT "Building FFmpeg..." VERBATIM USES_TERMINAL) - #BYPRODUCTS "${ffmpeg_libs_input_files}") add_custom_command (TARGET "${FOLEYS_ARG_BUILD_TARGET}" POST_BUILD - COMMAND "${MAKE_EXECUTABLE}" install + COMMAND "${FFMPEG_MAKE_EXECUTABLE}" install BYPRODUCTS "${ffmpeg_libs_output_files}" WORKING_DIRECTORY "${FOLEYS_ARG_SOURCE_DIR}" VERBATIM USES_TERMINAL) - add_dependencies (foleys_ffmpeg "${FOLEYS_ARG_BUILD_TARGET}") + add_dependencies (ffmpeg "${FOLEYS_ARG_BUILD_TARGET}") endfunction() @@ -167,7 +167,7 @@ endfunction() function (foleys_configure_ffmpeg_build) set (options "") - set (oneValueArgs SOURCE_DIR) + set (oneValueArgs SOURCE_DIR OUTPUT_DIR) set (multiValueArgs "") cmake_parse_arguments (FOLEYS_ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) @@ -176,22 +176,24 @@ function (foleys_configure_ffmpeg_build) message (FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} called without required argument SOURCE_DIR!") endif() - set (outputDir "${CMAKE_CURRENT_BINARY_DIR}/ffmpeg") + if (NOT FOLEYS_ARG_OUTPUT_DIR) + set (FOLEYS_ARG_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/ffmpeg") + endif() if (APPLE AND NOT IOS) foleys_configure_ffmpeg_macos_universal_binary_build (SOURCE_DIR "${FOLEYS_ARG_SOURCE_DIR}" - OUTPUT_DIR "${outputDir}") + OUTPUT_DIR "${FOLEYS_ARG_OUTPUT_DIR}") else() message (STATUS "Configuring FFmpeg build...") foleys_preconfigure_ffmpeg_build (SOURCE_DIR "${FOLEYS_ARG_SOURCE_DIR}" - OUTPUT_DIR "${outputDir}") + OUTPUT_DIR "${FOLEYS_ARG_OUTPUT_DIR}") foleys_create_ffmpeg_build_target (SOURCE_DIR "${FOLEYS_ARG_SOURCE_DIR}" - OUTPUT_DIR "${outputDir}" + OUTPUT_DIR "${FOLEYS_ARG_OUTPUT_DIR}" BUILD_TARGET ffmpeg_build) endif() - target_include_directories (foleys_ffmpeg INTERFACE "${outputDir}/include") + target_include_directories (ffmpeg INTERFACE "${FOLEYS_ARG_OUTPUT_DIR}/include") endfunction() diff --git a/cmake/ffmpeg/FFmpegMacBuild.cmake b/cmake/ffmpeg/FFmpegMacBuild.cmake index e96f62d2..220ad8fa 100644 --- a/cmake/ffmpeg/FFmpegMacBuild.cmake +++ b/cmake/ffmpeg/FFmpegMacBuild.cmake @@ -5,8 +5,14 @@ include_guard (GLOBAL) # find_program (YASM yasm) +find_program (LIPO lipo) -if (NOT YASM) # install yasm via Homebrew +if (NOT YASM OR NOT LIPO) # install yasm and/or lipo via Homebrew + + if (NOT FFmpeg_FIND_QUIETLY) + message (STATUS "Installing YASM via Homebrew...") + set (cmd_echo_flag COMMAND_ECHO STDOUT) + endif() find_program (HOMEBREW brew) @@ -19,10 +25,12 @@ if (NOT YASM) # install yasm via Homebrew message (FATAL_ERROR "bash is required for installing Homebrew, and cannot be found!") endif() - message (STATUS "Installing Homebrew...") + if (NOT FFmpeg_FIND_QUIETLY) + message (STATUS "Installing Homebrew...") + endif() execute_process (COMMAND "${BASH}" "${CMAKE_CURRENT_LIST_DIR}/mac_install_homebrew.sh" - COMMAND_ECHO STDOUT + ${cmd_echo_flag} COMMAND_ERROR_IS_FATAL ANY) find_program (HOMEBREW brew) @@ -32,8 +40,8 @@ if (NOT YASM) # install yasm via Homebrew endif() endif() - execute_process (COMMAND "${HOMEBREW}" install yasm - COMMAND_ECHO STDOUT + execute_process (COMMAND "${HOMEBREW}" install yasm lipo + ${cmd_echo_flag} COMMAND_ERROR_IS_FATAL ANY) endif() @@ -59,7 +67,9 @@ function (foleys_configure_ffmpeg_macos_universal_binary_build) foreach (arch ${FFMPEG_ARCHITECTURES}) - message (STATUS "Configuring FFmpeg build for arch ${arch}...") + if (NOT FFmpeg_FIND_QUIETLY) + message (STATUS "Configuring FFmpeg build for arch ${arch}...") + endif() set (sourceDir "${CMAKE_CURRENT_BINARY_DIR}/ffmpeg_arch_sources/${arch}/${FFMPEG_NAME}") @@ -73,13 +83,35 @@ function (foleys_configure_ffmpeg_macos_universal_binary_build) foleys_preconfigure_ffmpeg_build (SOURCE_DIR "${sourceDir}" OUTPUT_DIR "${outputDir}" - EXTRA_ARGS "--arch=${arch} --target-os=darwin") + EXTRA_ARGS "--arch=${arch} --cc=clang --cxx=clang++") foleys_create_ffmpeg_build_target (SOURCE_DIR "${sourceDir}" OUTPUT_DIR "${outputDir}" BUILD_TARGET "ffmpeg_build_${arch}") + + set_target_properties (ffmpeg_build_x86_64 PROPERTIES OSX_ARCHITECTURES ${arch}) endforeach() + # foreach(ffmpeg_lib ${FFMPEG_LIBS}) + + # set (libFilename "lib${ffmpeg_lib}.dylib") + + # set (output_file "${FOLEYS_ARG_OUTPUT_DIR}/universal/${libFilename}") + + # add_custom_target (ffmpeg_${ffmpeg_lib}_lipo + # COMMAND lipo -create "${FOLEYS_ARG_OUTPUT_DIR}/x86_64/${libFilename}" "${FOLEYS_ARG_OUTPUT_DIR}/arm64/${libFilename}" -output "${output_file}" + # BYPRODUCTS "${output_file}" + # VERBATIM USES_TERMINAL + # COMMENT "FFmpeg - running lipo on ${ffmpeg_lib}...") + + # add_dependencies (ffmpeg_${ffmpeg_lib}_lipo ffmpeg_build_x86_64) + # add_dependencies (ffmpeg_${ffmpeg_lib}_lipo ffmpeg_build_arm64) + + # add_dependencies (foleys_ffmpeg ffmpeg_${ffmpeg_lib}_lipo) + + # target_link_libraries (foleys_ffmpeg INTERFACE "${output_file}") + # endforeach() + # Need to manually copy headers... file (GLOB libs ${FOLEYS_ARG_SOURCE_DIR}/lib*) diff --git a/cmake/ffmpeg/FindInstalledFFmpeg.cmake b/cmake/ffmpeg/FindInstalledFFmpeg.cmake index 9dedc4da..b2f699ee 100644 --- a/cmake/ffmpeg/FindInstalledFFmpeg.cmake +++ b/cmake/ffmpeg/FindInstalledFFmpeg.cmake @@ -8,7 +8,7 @@ if (NOT PkgConfig_FOUND) return() endif() -list (TRANSFORM foleys_ffmpeg_libs +list (TRANSFORM FFMPEG_LIBS PREPEND lib OUTPUT_VARIABLE libav_libs) @@ -18,6 +18,6 @@ if (NOT LIBAV_FOUND) return() endif() -add_library (foleys_ffmpeg INTERFACE) +add_library (ffmpeg INTERFACE) -target_link_libraries (foleys_ffmpeg INTERFACE PkgConfig::LIBAV) +target_link_libraries (ffmpeg INTERFACE PkgConfig::LIBAV) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt deleted file mode 100644 index 151a77b1..00000000 --- a/tests/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -set (CMAKE_SUPPRESS_REGENERATION TRUE) - -# juce_add_plugin (PluginTest) -# target_link_libraries (PluginTest PRIVATE Foleys::foleys_video_engine) - -juce_add_gui_app (AppTest) -target_link_libraries (AppTest PRIVATE Foleys::foleys_video_engine Foleys::FoleysDefaultTarget) -target_sources (AppTest PRIVATE TestAppMain.cpp) diff --git a/tests/TestAppMain.cpp b/tests/TestAppMain.cpp deleted file mode 100644 index ed30a9fc..00000000 --- a/tests/TestAppMain.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include - -using juce::String; - -struct FoleysVideoTest final : public juce::JUCEApplication -{ - const String getApplicationName() final { return "Foleys video engine test"; } - - const String getApplicationVersion() final { return "0.0.1"; } - - void initialise (const String&) final { } - - void shutdown() const final { } -}; - -START_JUCE_APPLICATION (FoleysVideoTest) From 5f8b39296d090bbd81ee3b26cf6c2fb109a53a4c Mon Sep 17 00:00:00 2001 From: andorxornot Date: Thu, 7 Apr 2022 22:02:11 +0300 Subject: [PATCH 17/44] fixied audio stream init --- Basics/foleys_AudioFifo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Basics/foleys_AudioFifo.cpp b/Basics/foleys_AudioFifo.cpp index 7c40b660..13df9026 100644 --- a/Basics/foleys_AudioFifo.cpp +++ b/Basics/foleys_AudioFifo.cpp @@ -45,7 +45,7 @@ void AudioFifo::pushSamples (const juce::AudioBuffer& samples) void AudioFifo::setNumSamples (int samples) { audioFifo.setTotalSize (samples); - audioBuffer.setSize (2, samples); + audioBuffer.setSize (audioBuffer.getNumChannels(), samples); } void AudioFifo::pullSamples (const juce::AudioSourceChannelInfo& info) From f2a441c39944a14434270a08c131a89942aaefae Mon Sep 17 00:00:00 2001 From: andorxornot Date: Thu, 7 Apr 2022 22:02:36 +0300 Subject: [PATCH 18/44] removed avresample --- ReadWrite/FFmpeg/foleys_FFmpegHelpers.h | 1 - 1 file changed, 1 deletion(-) diff --git a/ReadWrite/FFmpeg/foleys_FFmpegHelpers.h b/ReadWrite/FFmpeg/foleys_FFmpegHelpers.h index 07007739..875b62db 100644 --- a/ReadWrite/FFmpeg/foleys_FFmpegHelpers.h +++ b/ReadWrite/FFmpeg/foleys_FFmpegHelpers.h @@ -35,7 +35,6 @@ #pragma comment (lib, "avcodec.lib") #pragma comment (lib, "swscale.lib") #pragma comment (lib, "swresample.lib") -#pragma comment (lib, "avresample.lib") #endif #ifdef __cplusplus From 070ef720cc6788d8cbad62c45eae879187459ae5 Mon Sep 17 00:00:00 2001 From: andorxornot Date: Thu, 7 Apr 2022 22:04:41 +0300 Subject: [PATCH 19/44] fixed gl namespace for last JUCE --- Widgets/foleys_OpenGLDraw.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Widgets/foleys_OpenGLDraw.h b/Widgets/foleys_OpenGLDraw.h index d57e1fee..86ca3767 100644 --- a/Widgets/foleys_OpenGLDraw.h +++ b/Widgets/foleys_OpenGLDraw.h @@ -27,6 +27,7 @@ namespace foleys namespace OpenGLDrawing { +using namespace juce::gl; #if JUCE_DEBUG static const char* getGLErrorMessage (const GLenum e) noexcept From 0eafa66dbf282316dce4076dd9a490a40a2c7418 Mon Sep 17 00:00:00 2001 From: andorxornot Date: Thu, 7 Apr 2022 22:08:59 +0300 Subject: [PATCH 20/44] fixed another gl namespace --- Widgets/foleys_OpenGLView.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Widgets/foleys_OpenGLView.cpp b/Widgets/foleys_OpenGLView.cpp index 85e8e8d2..83f562d3 100644 --- a/Widgets/foleys_OpenGLView.cpp +++ b/Widgets/foleys_OpenGLView.cpp @@ -22,6 +22,7 @@ namespace foleys { +using namespace juce::gl; OpenGLView::OpenGLView() { From 8d8d5d4baf4fb582b08bb0a48ae80401099f2550 Mon Sep 17 00:00:00 2001 From: andorxornot Date: Thu, 7 Apr 2022 22:16:00 +0300 Subject: [PATCH 21/44] added relative ffmpeg header path --- foleys_video_engine.h | 1 + 1 file changed, 1 insertion(+) diff --git a/foleys_video_engine.h b/foleys_video_engine.h index b90bd974..4d0ce7f0 100644 --- a/foleys_video_engine.h +++ b/foleys_video_engine.h @@ -28,6 +28,7 @@ dependencies: juce_audio_basics juce_audio_formats juce_gui_basics juce_graphics juce_core juce_audio_utils minimumCppStandard: 17 + searchpaths: ffmpeg/include website: https://foleysfinest.com/ From 8462010de202ff502cdf9ac2c2691e960e77e032 Mon Sep 17 00:00:00 2001 From: Dylan Marcus Date: Fri, 8 Apr 2022 11:34:45 -0400 Subject: [PATCH 22/44] fixed linking for ffmpeg libs to expected juce library paths, included paths via gitkeep but ignore all other contents --- .gitignore | 5 +++++ ffmpeg/include/.gitkeep | 0 foleys_video_engine.h | 2 ++ libs/MacOSX/x86_64/.gitkeep | 0 libs/VisualStudio2019/x64/MD/.gitkeep | 0 libs/VisualStudio2019/x64/MDd/.gitkeep | 0 6 files changed, 7 insertions(+) create mode 100644 ffmpeg/include/.gitkeep create mode 100644 libs/MacOSX/x86_64/.gitkeep create mode 100644 libs/VisualStudio2019/x64/MD/.gitkeep create mode 100644 libs/VisualStudio2019/x64/MDd/.gitkeep diff --git a/.gitignore b/.gitignore index b3ba47ba..e4144a57 100755 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,9 @@ **/Builds/ **/JuceLibraryCode/ **/!JuceLibraryCode/AppConfig.h + +# ingore ffmpeg lib folder contents libs/ +ffmpeg/ +# except for the .gitkeep(s) +!.gitkeep \ No newline at end of file diff --git a/ffmpeg/include/.gitkeep b/ffmpeg/include/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/foleys_video_engine.h b/foleys_video_engine.h index 4d0ce7f0..1f864a14 100644 --- a/foleys_video_engine.h +++ b/foleys_video_engine.h @@ -29,6 +29,8 @@ juce_graphics juce_core juce_audio_utils minimumCppStandard: 17 searchpaths: ffmpeg/include + windowsLibs: avformat,avutil,avcodec,swscale,swresample,avdevice,avfilter,avresample,postproc + OSXLibs: avformat,avutil,avcodec,swscale,swresample,avdevice,avfilter,avresample,postproc website: https://foleysfinest.com/ diff --git a/libs/MacOSX/x86_64/.gitkeep b/libs/MacOSX/x86_64/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/libs/VisualStudio2019/x64/MD/.gitkeep b/libs/VisualStudio2019/x64/MD/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/libs/VisualStudio2019/x64/MDd/.gitkeep b/libs/VisualStudio2019/x64/MDd/.gitkeep new file mode 100644 index 00000000..e69de29b From 46f4fe3acc511b575116227cd93bca790780e46d Mon Sep 17 00:00:00 2001 From: andorxornot Date: Fri, 8 Apr 2022 18:54:39 +0300 Subject: [PATCH 23/44] removed unnecessary ffmpeg libs for windows --- ReadWrite/FFmpeg/foleys_FFmpegHelpers.h | 8 -------- foleys_video_engine.h | 2 +- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/ReadWrite/FFmpeg/foleys_FFmpegHelpers.h b/ReadWrite/FFmpeg/foleys_FFmpegHelpers.h index 875b62db..58616865 100644 --- a/ReadWrite/FFmpeg/foleys_FFmpegHelpers.h +++ b/ReadWrite/FFmpeg/foleys_FFmpegHelpers.h @@ -29,14 +29,6 @@ #pragma clang diagnostic ignored "-Wfloat-conversion" #endif -#if JUCE_MSVC -#pragma comment (lib, "avformat.lib") -#pragma comment (lib, "avutil.lib") -#pragma comment (lib, "avcodec.lib") -#pragma comment (lib, "swscale.lib") -#pragma comment (lib, "swresample.lib") -#endif - #ifdef __cplusplus extern "C" { #endif diff --git a/foleys_video_engine.h b/foleys_video_engine.h index 1f864a14..97feb8dc 100644 --- a/foleys_video_engine.h +++ b/foleys_video_engine.h @@ -29,7 +29,7 @@ juce_graphics juce_core juce_audio_utils minimumCppStandard: 17 searchpaths: ffmpeg/include - windowsLibs: avformat,avutil,avcodec,swscale,swresample,avdevice,avfilter,avresample,postproc + windowsLibs: avformat,avutil,avcodec,swscale,swresample OSXLibs: avformat,avutil,avcodec,swscale,swresample,avdevice,avfilter,avresample,postproc website: https://foleysfinest.com/ From 55c34e78e92354747a76e77fb91ca54ad5e249f3 Mon Sep 17 00:00:00 2001 From: Dylan Marcus Date: Fri, 8 Apr 2022 15:37:17 -0400 Subject: [PATCH 24/44] removed some unused libs --- foleys_video_engine.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/foleys_video_engine.h b/foleys_video_engine.h index 97feb8dc..a2cf9d8c 100644 --- a/foleys_video_engine.h +++ b/foleys_video_engine.h @@ -30,7 +30,7 @@ minimumCppStandard: 17 searchpaths: ffmpeg/include windowsLibs: avformat,avutil,avcodec,swscale,swresample - OSXLibs: avformat,avutil,avcodec,swscale,swresample,avdevice,avfilter,avresample,postproc + OSXLibs: avformat,avutil,avcodec,swscale,swresample,avresample website: https://foleysfinest.com/ From 478810c7cd8778b818063957cc1b08d0aeceee4d Mon Sep 17 00:00:00 2001 From: Dylan Marcus Date: Fri, 8 Apr 2022 16:46:06 -0400 Subject: [PATCH 25/44] updated macos ffmpeg setup script to use homebrew entirely on stable ffmpeg version --- scripts/build-ffmpeg-osx.sh | 38 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/scripts/build-ffmpeg-osx.sh b/scripts/build-ffmpeg-osx.sh index aed04dc1..1b503f70 100755 --- a/scripts/build-ffmpeg-osx.sh +++ b/scripts/build-ffmpeg-osx.sh @@ -2,33 +2,31 @@ set -e -if [[ $# -ne 2 ]]; then - echo "Please add the path to the ffmpeg repository as first argument" - exit 1 +if [ ! `which brew` ] +then + echo 'Homebrew not found. Trying to install...' + ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" \ + || exit 1 fi -mkdir -p ../libs -pushd ../libs -mkdir -p ffmpeg.build -pushd ffmpeg.build - if [ ! `which yasm` ] then echo 'Yasm not found' - if [ ! `which brew` ] - then - echo 'Homebrew not found. Trying to install...' - ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" \ - || exit 1 - fi echo 'Trying to install Yasm...' brew install yasm || exit 1 fi -# ../ffmpeg/configure --enable-shared --disable-static --enable-gpl --enable-libx264 --install-name-dir='@executable_path/../Resources/ffmpeg_libs' --prefix=`pwd` --libdir=`pwd`/ffmpeg_libs -../$1/configure --enable-shared --disable-static --install-name-dir='@executable_path/../Resources/x86_64' --libdir=`pwd`/../MacOSX/x86_64 --prefix=`pwd` --incdir=`pwd`/../include -make -j 8 -make install +echo 'Removing old tap' +brew uninstall ffmpeg@4.3 +brew untap $USER/ffmpeg-4-3 + +echo 'Installing FFmpeg 4.3.2_4' +# TODO: Add error handling for this install (will fail if already exists) +brew tap-new $USER/ffmpeg-4-3 +brew extract --version=4.3 ffmpeg $USER/ffmpeg-4-3 +brew install $USER/ffmpeg-4-3/ffmpeg@4.3 -popd -popd +echo 'Copying include directory to module' +rsync -rl /usr/local/Cellar/ffmpeg@4.3/4.3.2_4/include/ ../ffmpeg/include +echo 'Copying macOS libs to module' +rsync -rl /usr/local/Cellar/ffmpeg@4.3/4.3.2_4/lib/ ../libs/MacOSX/x86_64 \ No newline at end of file From 14cbbbed739531acae52c0c33c1df70f6e10fe5d Mon Sep 17 00:00:00 2001 From: Dylan Marcus Date: Fri, 8 Apr 2022 18:08:18 -0400 Subject: [PATCH 26/44] remove explicit error handling --- scripts/build-ffmpeg-osx.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/build-ffmpeg-osx.sh b/scripts/build-ffmpeg-osx.sh index 1b503f70..aac09c8d 100755 --- a/scripts/build-ffmpeg-osx.sh +++ b/scripts/build-ffmpeg-osx.sh @@ -1,7 +1,5 @@ #!/bin/bash -set -e - if [ ! `which brew` ] then echo 'Homebrew not found. Trying to install...' From bde013c624608b7be3a6adc426b7bcc81951318f Mon Sep 17 00:00:00 2001 From: andorxornot Date: Sat, 23 Apr 2022 01:10:23 +0300 Subject: [PATCH 27/44] Added getNumChannels method --- Clips/foleys_AVClip.h | 2 ++ Clips/foleys_AudioClip.h | 2 ++ Clips/foleys_ComposedClip.cpp | 5 +++++ Clips/foleys_ComposedClip.h | 2 ++ Clips/foleys_ImageClip.cpp | 6 ++++++ Clips/foleys_ImageClip.h | 2 ++ Clips/foleys_MovieClip.cpp | 5 +++++ Clips/foleys_MovieClip.h | 2 ++ 8 files changed, 26 insertions(+) diff --git a/Clips/foleys_AVClip.h b/Clips/foleys_AVClip.h index 114bd492..76521d1d 100644 --- a/Clips/foleys_AVClip.h +++ b/Clips/foleys_AVClip.h @@ -97,6 +97,8 @@ class AVClip : public juce::PositionableAudioSource, /** Returns true, if this clip will produce audio */ virtual bool hasAudio() const = 0; + virtual int getNumChannels() const = 0; + /** This is the samplerate supplied from prepareToPlay and the sample rate this clip will produce audio and use as clock source. */ diff --git a/Clips/foleys_AudioClip.h b/Clips/foleys_AudioClip.h index 39b27470..8e6c9cd5 100644 --- a/Clips/foleys_AudioClip.h +++ b/Clips/foleys_AudioClip.h @@ -86,6 +86,8 @@ class AudioClip : public AVClip std::shared_ptr createCopy (StreamTypes types) override; + int getNumChannels() const override { return reader.get() ? reader->numChannels : 0; } + double getSampleRate() const override { return sampleRate; } private: diff --git a/Clips/foleys_ComposedClip.cpp b/Clips/foleys_ComposedClip.cpp index 542a2419..bf0db016 100644 --- a/Clips/foleys_ComposedClip.cpp +++ b/Clips/foleys_ComposedClip.cpp @@ -354,6 +354,11 @@ std::shared_ptr ComposedClip::createCopy (StreamTypes) return clipCopy; } +int ComposedClip::getNumChannels() const +{ + return audioSettings.numChannels; +} + double ComposedClip::getSampleRate() const { return audioSettings.timebase; diff --git a/Clips/foleys_ComposedClip.h b/Clips/foleys_ComposedClip.h index cf44c415..07d32a40 100644 --- a/Clips/foleys_ComposedClip.h +++ b/Clips/foleys_ComposedClip.h @@ -94,6 +94,8 @@ class ComposedClip : public AVClip, std::shared_ptr createCopy (StreamTypes types) override; + int getNumChannels() const override; + double getSampleRate() const override; /** When rendering non realtime (bounce), use this to wait for background diff --git a/Clips/foleys_ImageClip.cpp b/Clips/foleys_ImageClip.cpp index 5f942409..d90e8414 100644 --- a/Clips/foleys_ImageClip.cpp +++ b/Clips/foleys_ImageClip.cpp @@ -143,6 +143,12 @@ std::shared_ptr ImageClip::createCopy (StreamTypes types) return engine->createClipFromFile (getMediaFile(), types); } + +int ImageClip::getNumChannels() const +{ + return 0; +} + double ImageClip::getSampleRate() const { return sampleRate; diff --git a/Clips/foleys_ImageClip.h b/Clips/foleys_ImageClip.h index 99e6ade1..c53e20d9 100644 --- a/Clips/foleys_ImageClip.h +++ b/Clips/foleys_ImageClip.h @@ -78,6 +78,8 @@ class ImageClip : public AVClip std::shared_ptr createCopy (StreamTypes types) override; + int getNumChannels() const override; + double getSampleRate() const override; private: diff --git a/Clips/foleys_MovieClip.cpp b/Clips/foleys_MovieClip.cpp index 999c1aad..8d83828b 100644 --- a/Clips/foleys_MovieClip.cpp +++ b/Clips/foleys_MovieClip.cpp @@ -242,6 +242,11 @@ double MovieClip::getSampleRate() const return sampleRate; } +int MovieClip::getNumChannels() const +{ + return movieReader ? movieReader->numChannels : 0; +} + void MovieClip::handleAsyncUpdate() { if (sampleRate > 0 && hasVideo()) diff --git a/Clips/foleys_MovieClip.h b/Clips/foleys_MovieClip.h index 7b9c9d14..8f9ab39b 100644 --- a/Clips/foleys_MovieClip.h +++ b/Clips/foleys_MovieClip.h @@ -89,6 +89,8 @@ class MovieClip : public AVClip, std::shared_ptr createCopy (StreamTypes types) override; + int getNumChannels() const override; + double getSampleRate() const override; /** When rendering non realtime (bounce), use this to wait for background From 805906ded18e37fa39b636797d7a6bd9aab7c88c Mon Sep 17 00:00:00 2001 From: Ben Vining Date: Fri, 17 Jun 2022 16:59:33 -0500 Subject: [PATCH 28/44] Removed inner nested directory; configured CMake package file exporting --- .../Basics => Basics}/foleys_AudioFifo.cpp | 0 .../Basics => Basics}/foleys_AudioFifo.h | 0 .../Basics => Basics}/foleys_Structures.h | 0 .../foleys_TimeCodeAware.cpp | 0 .../Basics => Basics}/foleys_TimeCodeAware.h | 0 .../Basics => Basics}/foleys_Usage.cpp | 0 .../Basics => Basics}/foleys_Usage.h | 0 .../Basics => Basics}/foleys_VideoEngine.cpp | 0 .../Basics => Basics}/foleys_VideoEngine.h | 0 .../Basics => Basics}/foleys_VideoFifo.cpp | 0 .../Basics => Basics}/foleys_VideoFifo.h | 0 .../Basics => Basics}/foleys_VideoFrame.h | 0 CMakeLists.txt | 64 +- CMakePresets.json | 97 ++ .../Clips => Clips}/foleys_AVClip.cpp | 0 .../Clips => Clips}/foleys_AVClip.h | 0 .../Clips => Clips}/foleys_AudioClip.cpp | 0 .../Clips => Clips}/foleys_AudioClip.h | 0 .../Clips => Clips}/foleys_ClipDescriptor.cpp | 0 .../Clips => Clips}/foleys_ClipDescriptor.h | 0 .../Clips => Clips}/foleys_ComposedClip.cpp | 0 .../Clips => Clips}/foleys_ComposedClip.h | 0 .../Clips => Clips}/foleys_ImageClip.cpp | 0 .../Clips => Clips}/foleys_ImageClip.h | 0 .../Clips => Clips}/foleys_MovieClip.cpp | 0 .../Clips => Clips}/foleys_MovieClip.h | 0 Makefile | 60 - .../foleys_AudioPluginManager.cpp | 0 .../foleys_AudioPluginManager.h | 0 .../foleys_ColourCurveVideoProcessor.h | 0 .../foleys_VideoPluginManager.cpp | 0 .../foleys_VideoPluginManager.h | 0 .../foleys_VideoProcessor.h | 0 .../foleys_AudioMixer.h | 0 .../foleys_ColourLookuptables.h | 0 .../foleys_ControllableBase.cpp | 0 .../foleys_ControllableBase.h | 0 .../foleys_DefaultAudioMixer.cpp | 0 .../foleys_DefaultAudioMixer.h | 0 .../foleys_ParameterAutomation.cpp | 0 .../foleys_ParameterAutomation.h | 0 .../foleys_ProcessorController.cpp | 0 .../foleys_ProcessorController.h | 0 .../foleys_ProcessorParameter.cpp | 0 .../foleys_ProcessorParameter.h | 0 .../foleys_SoftwareVideoMixer.cpp | 0 .../foleys_SoftwareVideoMixer.h | 0 .../foleys_VideoMixer.h | 0 README.md | 10 + .../FFmpeg/foleys_FFmpegFormat.cpp | 0 .../FFmpeg/foleys_FFmpegFormat.h | 0 .../FFmpeg/foleys_FFmpegHelpers.h | 0 .../FFmpeg/foleys_FFmpegReader.cpp | 0 .../FFmpeg/foleys_FFmpegReader.h | 0 .../FFmpeg/foleys_FFmpegWriter.cpp | 0 .../FFmpeg/foleys_FFmpegWriter.h | 0 .../foleys_AVFormatManager.cpp | 0 .../foleys_AVFormatManager.h | 0 .../ReadWrite => ReadWrite}/foleys_AVReader.h | 0 .../ReadWrite => ReadWrite}/foleys_AVWriter.h | 0 .../foleys_ClipRenderer.cpp | 0 .../foleys_ClipRenderer.h | 0 .../Widgets => Widgets}/foleys_AudioStrip.cpp | 0 .../Widgets => Widgets}/foleys_AudioStrip.h | 0 .../Widgets => Widgets}/foleys_FilmStrip.cpp | 0 .../Widgets => Widgets}/foleys_FilmStrip.h | 0 .../Widgets => Widgets}/foleys_OpenGLDraw.h | 0 .../Widgets => Widgets}/foleys_OpenGLView.cpp | 0 .../Widgets => Widgets}/foleys_OpenGLView.h | 0 .../foleys_SoftwareView.cpp | 0 .../Widgets => Widgets}/foleys_SoftwareView.h | 0 .../Widgets => Widgets}/foleys_VideoView.h | 0 cmake/AddCPM.cmake | 11 - cmake/CPM.cmake | 1033 ----------------- cmake/FindFFmpeg.cmake | 49 +- cmake/FindJUCE.cmake | 27 +- cmake/FoleysDefaultSettings.cmake | 72 -- cmake/FoleysDefaultTarget.cmake | 86 -- cmake/config.cmake | 51 + cmake/ffmpeg/BuildFFmpeg.cmake | 65 -- cmake/ffmpeg/ConfigureFFmpegBuild.cmake | 199 ---- cmake/ffmpeg/FFmpegMacBuild.cmake | 122 -- cmake/ffmpeg/FindInstalledFFmpeg.cmake | 23 - cmake/ffmpeg/mac_install_homebrew.sh | 7 - ...ideo_engine.cpp => foleys_video_engine.cpp | 0 ...ys_video_engine.h => foleys_video_engine.h | 0 86 files changed, 244 insertions(+), 1732 deletions(-) rename {foleys_video_engine/Basics => Basics}/foleys_AudioFifo.cpp (100%) rename {foleys_video_engine/Basics => Basics}/foleys_AudioFifo.h (100%) rename {foleys_video_engine/Basics => Basics}/foleys_Structures.h (100%) rename {foleys_video_engine/Basics => Basics}/foleys_TimeCodeAware.cpp (100%) rename {foleys_video_engine/Basics => Basics}/foleys_TimeCodeAware.h (100%) rename {foleys_video_engine/Basics => Basics}/foleys_Usage.cpp (100%) rename {foleys_video_engine/Basics => Basics}/foleys_Usage.h (100%) rename {foleys_video_engine/Basics => Basics}/foleys_VideoEngine.cpp (100%) rename {foleys_video_engine/Basics => Basics}/foleys_VideoEngine.h (100%) rename {foleys_video_engine/Basics => Basics}/foleys_VideoFifo.cpp (100%) rename {foleys_video_engine/Basics => Basics}/foleys_VideoFifo.h (100%) rename {foleys_video_engine/Basics => Basics}/foleys_VideoFrame.h (100%) create mode 100644 CMakePresets.json rename {foleys_video_engine/Clips => Clips}/foleys_AVClip.cpp (100%) rename {foleys_video_engine/Clips => Clips}/foleys_AVClip.h (100%) rename {foleys_video_engine/Clips => Clips}/foleys_AudioClip.cpp (100%) rename {foleys_video_engine/Clips => Clips}/foleys_AudioClip.h (100%) rename {foleys_video_engine/Clips => Clips}/foleys_ClipDescriptor.cpp (100%) rename {foleys_video_engine/Clips => Clips}/foleys_ClipDescriptor.h (100%) rename {foleys_video_engine/Clips => Clips}/foleys_ComposedClip.cpp (100%) rename {foleys_video_engine/Clips => Clips}/foleys_ComposedClip.h (100%) rename {foleys_video_engine/Clips => Clips}/foleys_ImageClip.cpp (100%) rename {foleys_video_engine/Clips => Clips}/foleys_ImageClip.h (100%) rename {foleys_video_engine/Clips => Clips}/foleys_MovieClip.cpp (100%) rename {foleys_video_engine/Clips => Clips}/foleys_MovieClip.h (100%) delete mode 100644 Makefile rename {foleys_video_engine/Plugins => Plugins}/foleys_AudioPluginManager.cpp (100%) rename {foleys_video_engine/Plugins => Plugins}/foleys_AudioPluginManager.h (100%) rename {foleys_video_engine/Plugins => Plugins}/foleys_ColourCurveVideoProcessor.h (100%) rename {foleys_video_engine/Plugins => Plugins}/foleys_VideoPluginManager.cpp (100%) rename {foleys_video_engine/Plugins => Plugins}/foleys_VideoPluginManager.h (100%) rename {foleys_video_engine/Plugins => Plugins}/foleys_VideoProcessor.h (100%) rename {foleys_video_engine/Processing => Processing}/foleys_AudioMixer.h (100%) rename {foleys_video_engine/Processing => Processing}/foleys_ColourLookuptables.h (100%) rename {foleys_video_engine/Processing => Processing}/foleys_ControllableBase.cpp (100%) rename {foleys_video_engine/Processing => Processing}/foleys_ControllableBase.h (100%) rename {foleys_video_engine/Processing => Processing}/foleys_DefaultAudioMixer.cpp (100%) rename {foleys_video_engine/Processing => Processing}/foleys_DefaultAudioMixer.h (100%) rename {foleys_video_engine/Processing => Processing}/foleys_ParameterAutomation.cpp (100%) rename {foleys_video_engine/Processing => Processing}/foleys_ParameterAutomation.h (100%) rename {foleys_video_engine/Processing => Processing}/foleys_ProcessorController.cpp (100%) rename {foleys_video_engine/Processing => Processing}/foleys_ProcessorController.h (100%) rename {foleys_video_engine/Processing => Processing}/foleys_ProcessorParameter.cpp (100%) rename {foleys_video_engine/Processing => Processing}/foleys_ProcessorParameter.h (100%) rename {foleys_video_engine/Processing => Processing}/foleys_SoftwareVideoMixer.cpp (100%) rename {foleys_video_engine/Processing => Processing}/foleys_SoftwareVideoMixer.h (100%) rename {foleys_video_engine/Processing => Processing}/foleys_VideoMixer.h (100%) rename {foleys_video_engine/ReadWrite => ReadWrite}/FFmpeg/foleys_FFmpegFormat.cpp (100%) rename {foleys_video_engine/ReadWrite => ReadWrite}/FFmpeg/foleys_FFmpegFormat.h (100%) rename {foleys_video_engine/ReadWrite => ReadWrite}/FFmpeg/foleys_FFmpegHelpers.h (100%) rename {foleys_video_engine/ReadWrite => ReadWrite}/FFmpeg/foleys_FFmpegReader.cpp (100%) rename {foleys_video_engine/ReadWrite => ReadWrite}/FFmpeg/foleys_FFmpegReader.h (100%) rename {foleys_video_engine/ReadWrite => ReadWrite}/FFmpeg/foleys_FFmpegWriter.cpp (100%) rename {foleys_video_engine/ReadWrite => ReadWrite}/FFmpeg/foleys_FFmpegWriter.h (100%) rename {foleys_video_engine/ReadWrite => ReadWrite}/foleys_AVFormatManager.cpp (100%) rename {foleys_video_engine/ReadWrite => ReadWrite}/foleys_AVFormatManager.h (100%) rename {foleys_video_engine/ReadWrite => ReadWrite}/foleys_AVReader.h (100%) rename {foleys_video_engine/ReadWrite => ReadWrite}/foleys_AVWriter.h (100%) rename {foleys_video_engine/ReadWrite => ReadWrite}/foleys_ClipRenderer.cpp (100%) rename {foleys_video_engine/ReadWrite => ReadWrite}/foleys_ClipRenderer.h (100%) rename {foleys_video_engine/Widgets => Widgets}/foleys_AudioStrip.cpp (100%) rename {foleys_video_engine/Widgets => Widgets}/foleys_AudioStrip.h (100%) rename {foleys_video_engine/Widgets => Widgets}/foleys_FilmStrip.cpp (100%) rename {foleys_video_engine/Widgets => Widgets}/foleys_FilmStrip.h (100%) rename {foleys_video_engine/Widgets => Widgets}/foleys_OpenGLDraw.h (100%) rename {foleys_video_engine/Widgets => Widgets}/foleys_OpenGLView.cpp (100%) rename {foleys_video_engine/Widgets => Widgets}/foleys_OpenGLView.h (100%) rename {foleys_video_engine/Widgets => Widgets}/foleys_SoftwareView.cpp (100%) rename {foleys_video_engine/Widgets => Widgets}/foleys_SoftwareView.h (100%) rename {foleys_video_engine/Widgets => Widgets}/foleys_VideoView.h (100%) delete mode 100644 cmake/AddCPM.cmake delete mode 100644 cmake/CPM.cmake delete mode 100644 cmake/FoleysDefaultSettings.cmake delete mode 100644 cmake/FoleysDefaultTarget.cmake create mode 100644 cmake/config.cmake delete mode 100644 cmake/ffmpeg/BuildFFmpeg.cmake delete mode 100644 cmake/ffmpeg/ConfigureFFmpegBuild.cmake delete mode 100644 cmake/ffmpeg/FFmpegMacBuild.cmake delete mode 100644 cmake/ffmpeg/FindInstalledFFmpeg.cmake delete mode 100644 cmake/ffmpeg/mac_install_homebrew.sh rename foleys_video_engine/foleys_video_engine.cpp => foleys_video_engine.cpp (100%) rename foleys_video_engine/foleys_video_engine.h => foleys_video_engine.h (100%) diff --git a/foleys_video_engine/Basics/foleys_AudioFifo.cpp b/Basics/foleys_AudioFifo.cpp similarity index 100% rename from foleys_video_engine/Basics/foleys_AudioFifo.cpp rename to Basics/foleys_AudioFifo.cpp diff --git a/foleys_video_engine/Basics/foleys_AudioFifo.h b/Basics/foleys_AudioFifo.h similarity index 100% rename from foleys_video_engine/Basics/foleys_AudioFifo.h rename to Basics/foleys_AudioFifo.h diff --git a/foleys_video_engine/Basics/foleys_Structures.h b/Basics/foleys_Structures.h similarity index 100% rename from foleys_video_engine/Basics/foleys_Structures.h rename to Basics/foleys_Structures.h diff --git a/foleys_video_engine/Basics/foleys_TimeCodeAware.cpp b/Basics/foleys_TimeCodeAware.cpp similarity index 100% rename from foleys_video_engine/Basics/foleys_TimeCodeAware.cpp rename to Basics/foleys_TimeCodeAware.cpp diff --git a/foleys_video_engine/Basics/foleys_TimeCodeAware.h b/Basics/foleys_TimeCodeAware.h similarity index 100% rename from foleys_video_engine/Basics/foleys_TimeCodeAware.h rename to Basics/foleys_TimeCodeAware.h diff --git a/foleys_video_engine/Basics/foleys_Usage.cpp b/Basics/foleys_Usage.cpp similarity index 100% rename from foleys_video_engine/Basics/foleys_Usage.cpp rename to Basics/foleys_Usage.cpp diff --git a/foleys_video_engine/Basics/foleys_Usage.h b/Basics/foleys_Usage.h similarity index 100% rename from foleys_video_engine/Basics/foleys_Usage.h rename to Basics/foleys_Usage.h diff --git a/foleys_video_engine/Basics/foleys_VideoEngine.cpp b/Basics/foleys_VideoEngine.cpp similarity index 100% rename from foleys_video_engine/Basics/foleys_VideoEngine.cpp rename to Basics/foleys_VideoEngine.cpp diff --git a/foleys_video_engine/Basics/foleys_VideoEngine.h b/Basics/foleys_VideoEngine.h similarity index 100% rename from foleys_video_engine/Basics/foleys_VideoEngine.h rename to Basics/foleys_VideoEngine.h diff --git a/foleys_video_engine/Basics/foleys_VideoFifo.cpp b/Basics/foleys_VideoFifo.cpp similarity index 100% rename from foleys_video_engine/Basics/foleys_VideoFifo.cpp rename to Basics/foleys_VideoFifo.cpp diff --git a/foleys_video_engine/Basics/foleys_VideoFifo.h b/Basics/foleys_VideoFifo.h similarity index 100% rename from foleys_video_engine/Basics/foleys_VideoFifo.h rename to Basics/foleys_VideoFifo.h diff --git a/foleys_video_engine/Basics/foleys_VideoFrame.h b/Basics/foleys_VideoFrame.h similarity index 100% rename from foleys_video_engine/Basics/foleys_VideoFrame.h rename to Basics/foleys_VideoFrame.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 42760fb7..bcbb0dd9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,22 +1,64 @@ cmake_minimum_required (VERSION 3.15 FATAL_ERROR) -project (FoleysVideoEngine VERSION 0.2.0 LANGUAGES CXX OBJC C) +project (FoleysVideoEngine + VERSION 0.2.0 + LANGUAGES CXX OBJC C + DESCRIPTION "A video engine module for JUCE" + HOMEPAGE_URL "https://foleysfinest.com/foleys_video_engine/") +list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") -set (CMAKE_SUPPRESS_REGENERATION TRUE) +find_package (FFmpeg REQUIRED) +find_package (JUCE 6 REQUIRED) +juce_add_module ("${CMAKE_CURRENT_LIST_DIR}" + ALIAS_NAMESPACE Foleys) -list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") +target_compile_definitions (foleys_video_engine INTERFACE + JUCE_MODAL_LOOPS_PERMITTED=1 + JUCE_STRICT_REFCOUNTEDPOINTER=1 + JUCE_PLUGINHOST_AU=1 + JUCE_PLUGINHOST_VST3=1 + JUCE_PLUGINHOST_LADSPA=1) -include (FoleysDefaultSettings) -include (FoleysDefaultTarget) +target_link_libraries (foleys_video_engine INTERFACE ffmpeg::ffmpeg) -find_package (JUCE REQUIRED) -find_package (FFmpeg REQUIRED) +# + +set (FVE_INSTALL_DEST "${CMAKE_INSTALL_LIBDIR}/cmake/foleys_video_engine" + CACHE STRING + "Directory below INSTALL_PREFIX where the foleys_video_engine CMake package files will be installed to") + +install (DIRECTORY "${CMAKE_CURRENT_LIST_DIR}" + DESTINATION "${FVE_INSTALL_DEST}/.." + COMPONENT foleys_video_engine + PATTERN *.md EXCLUDE + PATTERN .git/* EXCLUDE + PATTERN .github/* EXCLUDE + PATTERN *.json EXCLUDE + PATTERN CMakeLists.txt EXCLUDE + PATTERN "${CMAKE_CURRENT_BINARY_DIR}/" EXCLUDE) + +include (CPackComponent) + +cpack_add_component (foleys_video_engine + GROUP Foleys + INSTALL_TYPES Developer) + +include (CMakePackageConfigHelpers) + +write_basic_package_version_file (foleys_video_engine-config-version.cmake + VERSION "${PROJECT_VERSION}" + COMPATIBILITY SameMajorVersion + ARCH_INDEPENDENT) -juce_add_module ("${CMAKE_CURRENT_LIST_DIR}/foleys_video_engine" ALIAS_NAMESPACE Foleys) +configure_package_config_file (cmake/config.cmake foleys_video_engine-config.cmake + INSTALL_DESTINATION "${FVE_INSTALL_DEST}" + NO_SET_AND_CHECK_MACRO) -target_compile_definitions (foleys_video_engine INTERFACE JUCE_MODAL_LOOPS_PERMITTED=1 JUCE_STRICT_REFCOUNTEDPOINTER=1 - JUCE_PLUGINHOST_AU=1 JUCE_PLUGINHOST_VST3=1 JUCE_PLUGINHOST_LADSPA=1) +install (FILES "${CMAKE_CURRENT_BINARY_DIR}/foleys_video_engine-config-version.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/foleys_video_engine-config.cmake" + DESTINATION "${FVE_INSTALL_DEST}" + COMPONENT foleys_video_engine) -target_link_libraries (foleys_video_engine INTERFACE ffmpeg::ffmpeg Foleys::FoleysDefaultTarget) +export (PACKAGE foleys_video_engine) diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 00000000..4c3ea148 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,97 @@ +{ + "buildPresets": [ + { + "cleanFirst": true, + "configuration": "Debug", + "configurePreset": "default", + "displayName": "The default build", + "jobs": 4, + "name": "default" + }, + { + "displayName": "Maintainer build", + "inherits": "default", + "name": "maintainer", + "verbose": true + } + ], + "cmakeMinimumRequired": { + "major": 3, + "minor": 15, + "patch": 0 + }, + "configurePresets": [ + { + "binaryDir": "${sourceDir}/Builds", + "displayName": "The default CMake configuration", + "name": "default", + "warnings": { + "unusedCli": false + } + }, + { + "displayName": "CMake configuration for development of foleys_video_engine", + "inherits": "default", + "name": "maintainer", + "warnings": { + "deprecated": true, + "dev": true, + "uninitialized": true + } + }, + { + "cacheVariables": { + "CMAKE_CXX_COMPILER": "g++-11", + "CMAKE_C_COMPILER": "gcc-11" + }, + "displayName": "Build with Ninja and GCC", + "generator": "Ninja Multi-Config", + "inherits": "maintainer", + "name": "ninja-gcc" + }, + { + "cacheVariables": { + "CMAKE_CXX_COMPILER": "clang++", + "CMAKE_C_COMPILER": "clang" + }, + "displayName": "Build with Ninja and Clang", + "generator": "Ninja Multi-Config", + "inherits": "maintainer", + "name": "ninja-clang" + }, + { + "cacheVariables": { + "CMAKE_SYSTEM_NAME": "iOS", + "CMAKE_XCODE_EFFECTIVE_PLATFORMS": "-iphoneos" + }, + "condition": { + "lhs": "${hostSystemName}", + "rhs": "Darwin", + "type": "equals" + }, + "displayName": "Configure cross-compiling for iOS", + "generator": "Xcode", + "inherits": "default", + "name": "iOS" + }, + { + "cacheVariables": { + "CMAKE_SYSTEM_NAME": "tvOS", + "CMAKE_XCODE_EFFECTIVE_PLATFORMS": "-appletvos" + }, + "displayName": "Configure cross-compiling for tvOS", + "inherits": "iOS", + "name": "tvOS" + }, + { + "cacheVariables": { + "CMAKE_SYSTEM_NAME": "watchOS", + "CMAKE_XCODE_EFFECTIVE_PLATFORMS": "-watchos" + }, + "displayName": "Configure cross-compiling for watchOS", + "inherits": "iOS", + "name": "watchOS" + } + ], + "version": 3 +} \ No newline at end of file diff --git a/foleys_video_engine/Clips/foleys_AVClip.cpp b/Clips/foleys_AVClip.cpp similarity index 100% rename from foleys_video_engine/Clips/foleys_AVClip.cpp rename to Clips/foleys_AVClip.cpp diff --git a/foleys_video_engine/Clips/foleys_AVClip.h b/Clips/foleys_AVClip.h similarity index 100% rename from foleys_video_engine/Clips/foleys_AVClip.h rename to Clips/foleys_AVClip.h diff --git a/foleys_video_engine/Clips/foleys_AudioClip.cpp b/Clips/foleys_AudioClip.cpp similarity index 100% rename from foleys_video_engine/Clips/foleys_AudioClip.cpp rename to Clips/foleys_AudioClip.cpp diff --git a/foleys_video_engine/Clips/foleys_AudioClip.h b/Clips/foleys_AudioClip.h similarity index 100% rename from foleys_video_engine/Clips/foleys_AudioClip.h rename to Clips/foleys_AudioClip.h diff --git a/foleys_video_engine/Clips/foleys_ClipDescriptor.cpp b/Clips/foleys_ClipDescriptor.cpp similarity index 100% rename from foleys_video_engine/Clips/foleys_ClipDescriptor.cpp rename to Clips/foleys_ClipDescriptor.cpp diff --git a/foleys_video_engine/Clips/foleys_ClipDescriptor.h b/Clips/foleys_ClipDescriptor.h similarity index 100% rename from foleys_video_engine/Clips/foleys_ClipDescriptor.h rename to Clips/foleys_ClipDescriptor.h diff --git a/foleys_video_engine/Clips/foleys_ComposedClip.cpp b/Clips/foleys_ComposedClip.cpp similarity index 100% rename from foleys_video_engine/Clips/foleys_ComposedClip.cpp rename to Clips/foleys_ComposedClip.cpp diff --git a/foleys_video_engine/Clips/foleys_ComposedClip.h b/Clips/foleys_ComposedClip.h similarity index 100% rename from foleys_video_engine/Clips/foleys_ComposedClip.h rename to Clips/foleys_ComposedClip.h diff --git a/foleys_video_engine/Clips/foleys_ImageClip.cpp b/Clips/foleys_ImageClip.cpp similarity index 100% rename from foleys_video_engine/Clips/foleys_ImageClip.cpp rename to Clips/foleys_ImageClip.cpp diff --git a/foleys_video_engine/Clips/foleys_ImageClip.h b/Clips/foleys_ImageClip.h similarity index 100% rename from foleys_video_engine/Clips/foleys_ImageClip.h rename to Clips/foleys_ImageClip.h diff --git a/foleys_video_engine/Clips/foleys_MovieClip.cpp b/Clips/foleys_MovieClip.cpp similarity index 100% rename from foleys_video_engine/Clips/foleys_MovieClip.cpp rename to Clips/foleys_MovieClip.cpp diff --git a/foleys_video_engine/Clips/foleys_MovieClip.h b/Clips/foleys_MovieClip.h similarity index 100% rename from foleys_video_engine/Clips/foleys_MovieClip.h rename to Clips/foleys_MovieClip.h diff --git a/Makefile b/Makefile deleted file mode 100644 index 51a7e363..00000000 --- a/Makefile +++ /dev/null @@ -1,60 +0,0 @@ -SHELL = /bin/sh -.ONESHELL: -.SHELLFLAGS: -euo -.DEFAULT_GOAL: help -.NOTPARALLEL: -.POSIX: - -# - -CMAKE = cmake -RM = rm -rf - -ifeq ($(OS),Windows_NT) - NUM_CORES = $(NUMBER_OF_PROCESSORS) - CMAKE_GENERATOR = Visual Studio 16 2019 -else ifeq ($(shell uname -s),Darwin) - NUM_CORES = $(shell sysctl hw.ncpu | awk '{print $$2}') - CMAKE_GENERATOR = Xcode -else - NUM_CORES = $(shell grep -c ^processor /proc/cpuinfo) - CMAKE_GENERATOR = Ninja -endif - -BUILDS = Builds -CACHE = Cache - -# - -override FOLEYS_ROOT := $(patsubst %/,%,$(strip $(dir $(realpath $(firstword $(MAKEFILE_LIST)))))) - -override THIS_MAKEFILE := $(FOLEYS_ROOT)/Makefile - -override cmake_config = cd $(FOLEYS_ROOT) && $(CMAKE) -B $(BUILDS) -G "$(CMAKE_GENERATOR)" --log-level=DEBUG - -override cmake_build_configuration = echo "Building $(1) configuration..."; $(CMAKE) --build $(BUILDS) -j $(NUM_CORES) --config $(1) - -# - -help: ## Print this message - @grep -E '^[a-zA-Z_-]+:.*?\#\# .*$$' $(THIS_MAKEFILE) | sort | awk 'BEGIN {FS = ":.*?\#\# "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' - -# - -clean: ## Removes the builds directory - cd $(FOLEYS_ROOT) && $(RM) $(BUILDS) - -wipe: clean ## Removes the builds directory and the dependencies cache - cd $(FOLEYS_ROOT) && $(RM) $(CACHE) - -# - -config: ## Configure the tests - $(call cmake_config) -D FOLEYS_BUILD_TESTS=1 - -tests: config ## Build the tests - @$(call cmake_build_configuration,Debug) - -# - -.PHONY: $(shell grep -E '^[a-zA-Z_-]+:.*?\#\# .*$$' $(THIS_MAKEFILE) | sed 's/:.*/\ /' | tr '\n' ' ') diff --git a/foleys_video_engine/Plugins/foleys_AudioPluginManager.cpp b/Plugins/foleys_AudioPluginManager.cpp similarity index 100% rename from foleys_video_engine/Plugins/foleys_AudioPluginManager.cpp rename to Plugins/foleys_AudioPluginManager.cpp diff --git a/foleys_video_engine/Plugins/foleys_AudioPluginManager.h b/Plugins/foleys_AudioPluginManager.h similarity index 100% rename from foleys_video_engine/Plugins/foleys_AudioPluginManager.h rename to Plugins/foleys_AudioPluginManager.h diff --git a/foleys_video_engine/Plugins/foleys_ColourCurveVideoProcessor.h b/Plugins/foleys_ColourCurveVideoProcessor.h similarity index 100% rename from foleys_video_engine/Plugins/foleys_ColourCurveVideoProcessor.h rename to Plugins/foleys_ColourCurveVideoProcessor.h diff --git a/foleys_video_engine/Plugins/foleys_VideoPluginManager.cpp b/Plugins/foleys_VideoPluginManager.cpp similarity index 100% rename from foleys_video_engine/Plugins/foleys_VideoPluginManager.cpp rename to Plugins/foleys_VideoPluginManager.cpp diff --git a/foleys_video_engine/Plugins/foleys_VideoPluginManager.h b/Plugins/foleys_VideoPluginManager.h similarity index 100% rename from foleys_video_engine/Plugins/foleys_VideoPluginManager.h rename to Plugins/foleys_VideoPluginManager.h diff --git a/foleys_video_engine/Plugins/foleys_VideoProcessor.h b/Plugins/foleys_VideoProcessor.h similarity index 100% rename from foleys_video_engine/Plugins/foleys_VideoProcessor.h rename to Plugins/foleys_VideoProcessor.h diff --git a/foleys_video_engine/Processing/foleys_AudioMixer.h b/Processing/foleys_AudioMixer.h similarity index 100% rename from foleys_video_engine/Processing/foleys_AudioMixer.h rename to Processing/foleys_AudioMixer.h diff --git a/foleys_video_engine/Processing/foleys_ColourLookuptables.h b/Processing/foleys_ColourLookuptables.h similarity index 100% rename from foleys_video_engine/Processing/foleys_ColourLookuptables.h rename to Processing/foleys_ColourLookuptables.h diff --git a/foleys_video_engine/Processing/foleys_ControllableBase.cpp b/Processing/foleys_ControllableBase.cpp similarity index 100% rename from foleys_video_engine/Processing/foleys_ControllableBase.cpp rename to Processing/foleys_ControllableBase.cpp diff --git a/foleys_video_engine/Processing/foleys_ControllableBase.h b/Processing/foleys_ControllableBase.h similarity index 100% rename from foleys_video_engine/Processing/foleys_ControllableBase.h rename to Processing/foleys_ControllableBase.h diff --git a/foleys_video_engine/Processing/foleys_DefaultAudioMixer.cpp b/Processing/foleys_DefaultAudioMixer.cpp similarity index 100% rename from foleys_video_engine/Processing/foleys_DefaultAudioMixer.cpp rename to Processing/foleys_DefaultAudioMixer.cpp diff --git a/foleys_video_engine/Processing/foleys_DefaultAudioMixer.h b/Processing/foleys_DefaultAudioMixer.h similarity index 100% rename from foleys_video_engine/Processing/foleys_DefaultAudioMixer.h rename to Processing/foleys_DefaultAudioMixer.h diff --git a/foleys_video_engine/Processing/foleys_ParameterAutomation.cpp b/Processing/foleys_ParameterAutomation.cpp similarity index 100% rename from foleys_video_engine/Processing/foleys_ParameterAutomation.cpp rename to Processing/foleys_ParameterAutomation.cpp diff --git a/foleys_video_engine/Processing/foleys_ParameterAutomation.h b/Processing/foleys_ParameterAutomation.h similarity index 100% rename from foleys_video_engine/Processing/foleys_ParameterAutomation.h rename to Processing/foleys_ParameterAutomation.h diff --git a/foleys_video_engine/Processing/foleys_ProcessorController.cpp b/Processing/foleys_ProcessorController.cpp similarity index 100% rename from foleys_video_engine/Processing/foleys_ProcessorController.cpp rename to Processing/foleys_ProcessorController.cpp diff --git a/foleys_video_engine/Processing/foleys_ProcessorController.h b/Processing/foleys_ProcessorController.h similarity index 100% rename from foleys_video_engine/Processing/foleys_ProcessorController.h rename to Processing/foleys_ProcessorController.h diff --git a/foleys_video_engine/Processing/foleys_ProcessorParameter.cpp b/Processing/foleys_ProcessorParameter.cpp similarity index 100% rename from foleys_video_engine/Processing/foleys_ProcessorParameter.cpp rename to Processing/foleys_ProcessorParameter.cpp diff --git a/foleys_video_engine/Processing/foleys_ProcessorParameter.h b/Processing/foleys_ProcessorParameter.h similarity index 100% rename from foleys_video_engine/Processing/foleys_ProcessorParameter.h rename to Processing/foleys_ProcessorParameter.h diff --git a/foleys_video_engine/Processing/foleys_SoftwareVideoMixer.cpp b/Processing/foleys_SoftwareVideoMixer.cpp similarity index 100% rename from foleys_video_engine/Processing/foleys_SoftwareVideoMixer.cpp rename to Processing/foleys_SoftwareVideoMixer.cpp diff --git a/foleys_video_engine/Processing/foleys_SoftwareVideoMixer.h b/Processing/foleys_SoftwareVideoMixer.h similarity index 100% rename from foleys_video_engine/Processing/foleys_SoftwareVideoMixer.h rename to Processing/foleys_SoftwareVideoMixer.h diff --git a/foleys_video_engine/Processing/foleys_VideoMixer.h b/Processing/foleys_VideoMixer.h similarity index 100% rename from foleys_video_engine/Processing/foleys_VideoMixer.h rename to Processing/foleys_VideoMixer.h diff --git a/README.md b/README.md index 2871017d..2f5563f9 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,16 @@ Foleys Finest Audio Ltd. With the module foleys_video_engine we offer a simple way to implement reading, writing, displaying and editing of videos using the audio framework JUCE (https://juce.com) +Setup +-------- + +To use the video engine, add this module via Projucer or CMake to your JUCE project. + +If you are using CMake and the CPM.cmake package manager to add this repository, be aware that: +- JUCE's module system expects the root folder of a module to have the same name as the module +- By default, CPM.cmake will download the source code into a nested folder named with the version, for example `foleys_video_engine//` +This can cause the JUCE module system to get confused. If you are using CPM.cmake, we recommend you set the `CPM_USE_NAMED_CACHE_DIRECTORIES` CMake or environment variable to `ON` to prevent this issue. + Features -------- diff --git a/foleys_video_engine/ReadWrite/FFmpeg/foleys_FFmpegFormat.cpp b/ReadWrite/FFmpeg/foleys_FFmpegFormat.cpp similarity index 100% rename from foleys_video_engine/ReadWrite/FFmpeg/foleys_FFmpegFormat.cpp rename to ReadWrite/FFmpeg/foleys_FFmpegFormat.cpp diff --git a/foleys_video_engine/ReadWrite/FFmpeg/foleys_FFmpegFormat.h b/ReadWrite/FFmpeg/foleys_FFmpegFormat.h similarity index 100% rename from foleys_video_engine/ReadWrite/FFmpeg/foleys_FFmpegFormat.h rename to ReadWrite/FFmpeg/foleys_FFmpegFormat.h diff --git a/foleys_video_engine/ReadWrite/FFmpeg/foleys_FFmpegHelpers.h b/ReadWrite/FFmpeg/foleys_FFmpegHelpers.h similarity index 100% rename from foleys_video_engine/ReadWrite/FFmpeg/foleys_FFmpegHelpers.h rename to ReadWrite/FFmpeg/foleys_FFmpegHelpers.h diff --git a/foleys_video_engine/ReadWrite/FFmpeg/foleys_FFmpegReader.cpp b/ReadWrite/FFmpeg/foleys_FFmpegReader.cpp similarity index 100% rename from foleys_video_engine/ReadWrite/FFmpeg/foleys_FFmpegReader.cpp rename to ReadWrite/FFmpeg/foleys_FFmpegReader.cpp diff --git a/foleys_video_engine/ReadWrite/FFmpeg/foleys_FFmpegReader.h b/ReadWrite/FFmpeg/foleys_FFmpegReader.h similarity index 100% rename from foleys_video_engine/ReadWrite/FFmpeg/foleys_FFmpegReader.h rename to ReadWrite/FFmpeg/foleys_FFmpegReader.h diff --git a/foleys_video_engine/ReadWrite/FFmpeg/foleys_FFmpegWriter.cpp b/ReadWrite/FFmpeg/foleys_FFmpegWriter.cpp similarity index 100% rename from foleys_video_engine/ReadWrite/FFmpeg/foleys_FFmpegWriter.cpp rename to ReadWrite/FFmpeg/foleys_FFmpegWriter.cpp diff --git a/foleys_video_engine/ReadWrite/FFmpeg/foleys_FFmpegWriter.h b/ReadWrite/FFmpeg/foleys_FFmpegWriter.h similarity index 100% rename from foleys_video_engine/ReadWrite/FFmpeg/foleys_FFmpegWriter.h rename to ReadWrite/FFmpeg/foleys_FFmpegWriter.h diff --git a/foleys_video_engine/ReadWrite/foleys_AVFormatManager.cpp b/ReadWrite/foleys_AVFormatManager.cpp similarity index 100% rename from foleys_video_engine/ReadWrite/foleys_AVFormatManager.cpp rename to ReadWrite/foleys_AVFormatManager.cpp diff --git a/foleys_video_engine/ReadWrite/foleys_AVFormatManager.h b/ReadWrite/foleys_AVFormatManager.h similarity index 100% rename from foleys_video_engine/ReadWrite/foleys_AVFormatManager.h rename to ReadWrite/foleys_AVFormatManager.h diff --git a/foleys_video_engine/ReadWrite/foleys_AVReader.h b/ReadWrite/foleys_AVReader.h similarity index 100% rename from foleys_video_engine/ReadWrite/foleys_AVReader.h rename to ReadWrite/foleys_AVReader.h diff --git a/foleys_video_engine/ReadWrite/foleys_AVWriter.h b/ReadWrite/foleys_AVWriter.h similarity index 100% rename from foleys_video_engine/ReadWrite/foleys_AVWriter.h rename to ReadWrite/foleys_AVWriter.h diff --git a/foleys_video_engine/ReadWrite/foleys_ClipRenderer.cpp b/ReadWrite/foleys_ClipRenderer.cpp similarity index 100% rename from foleys_video_engine/ReadWrite/foleys_ClipRenderer.cpp rename to ReadWrite/foleys_ClipRenderer.cpp diff --git a/foleys_video_engine/ReadWrite/foleys_ClipRenderer.h b/ReadWrite/foleys_ClipRenderer.h similarity index 100% rename from foleys_video_engine/ReadWrite/foleys_ClipRenderer.h rename to ReadWrite/foleys_ClipRenderer.h diff --git a/foleys_video_engine/Widgets/foleys_AudioStrip.cpp b/Widgets/foleys_AudioStrip.cpp similarity index 100% rename from foleys_video_engine/Widgets/foleys_AudioStrip.cpp rename to Widgets/foleys_AudioStrip.cpp diff --git a/foleys_video_engine/Widgets/foleys_AudioStrip.h b/Widgets/foleys_AudioStrip.h similarity index 100% rename from foleys_video_engine/Widgets/foleys_AudioStrip.h rename to Widgets/foleys_AudioStrip.h diff --git a/foleys_video_engine/Widgets/foleys_FilmStrip.cpp b/Widgets/foleys_FilmStrip.cpp similarity index 100% rename from foleys_video_engine/Widgets/foleys_FilmStrip.cpp rename to Widgets/foleys_FilmStrip.cpp diff --git a/foleys_video_engine/Widgets/foleys_FilmStrip.h b/Widgets/foleys_FilmStrip.h similarity index 100% rename from foleys_video_engine/Widgets/foleys_FilmStrip.h rename to Widgets/foleys_FilmStrip.h diff --git a/foleys_video_engine/Widgets/foleys_OpenGLDraw.h b/Widgets/foleys_OpenGLDraw.h similarity index 100% rename from foleys_video_engine/Widgets/foleys_OpenGLDraw.h rename to Widgets/foleys_OpenGLDraw.h diff --git a/foleys_video_engine/Widgets/foleys_OpenGLView.cpp b/Widgets/foleys_OpenGLView.cpp similarity index 100% rename from foleys_video_engine/Widgets/foleys_OpenGLView.cpp rename to Widgets/foleys_OpenGLView.cpp diff --git a/foleys_video_engine/Widgets/foleys_OpenGLView.h b/Widgets/foleys_OpenGLView.h similarity index 100% rename from foleys_video_engine/Widgets/foleys_OpenGLView.h rename to Widgets/foleys_OpenGLView.h diff --git a/foleys_video_engine/Widgets/foleys_SoftwareView.cpp b/Widgets/foleys_SoftwareView.cpp similarity index 100% rename from foleys_video_engine/Widgets/foleys_SoftwareView.cpp rename to Widgets/foleys_SoftwareView.cpp diff --git a/foleys_video_engine/Widgets/foleys_SoftwareView.h b/Widgets/foleys_SoftwareView.h similarity index 100% rename from foleys_video_engine/Widgets/foleys_SoftwareView.h rename to Widgets/foleys_SoftwareView.h diff --git a/foleys_video_engine/Widgets/foleys_VideoView.h b/Widgets/foleys_VideoView.h similarity index 100% rename from foleys_video_engine/Widgets/foleys_VideoView.h rename to Widgets/foleys_VideoView.h diff --git a/cmake/AddCPM.cmake b/cmake/AddCPM.cmake deleted file mode 100644 index 928b5ae5..00000000 --- a/cmake/AddCPM.cmake +++ /dev/null @@ -1,11 +0,0 @@ -cmake_minimum_required (VERSION 3.15 FATAL_ERROR) - -include_guard (GLOBAL) - -if (NOT DEFINED ENV{CPM_SOURCE_CACHE}) - set (ENV{CPM_SOURCE_CACHE} "${PROJECT_SOURCE_DIR}/Cache") -endif() - -if (NOT COMMAND CPMAddPackage) - include ("${CMAKE_CURRENT_LIST_DIR}/CPM.cmake") -endif() diff --git a/cmake/CPM.cmake b/cmake/CPM.cmake deleted file mode 100644 index d1237a15..00000000 --- a/cmake/CPM.cmake +++ /dev/null @@ -1,1033 +0,0 @@ -# CPM.cmake - CMake's missing package manager -# =========================================== -# See https://github.com/cpm-cmake/CPM.cmake for usage and update instructions. -# -# MIT License -# ----------- -#[[ - Copyright (c) 2019-2022 Lars Melchior and contributors - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -]] - -cmake_minimum_required(VERSION 3.14 FATAL_ERROR) - -set(CURRENT_CPM_VERSION 1.0.0-development-version) - -if(CPM_DIRECTORY) - if(NOT CPM_DIRECTORY STREQUAL CMAKE_CURRENT_LIST_DIR) - if(CPM_VERSION VERSION_LESS CURRENT_CPM_VERSION) - message( - AUTHOR_WARNING - "${CPM_INDENT} \ -A dependency is using a more recent CPM version (${CURRENT_CPM_VERSION}) than the current project (${CPM_VERSION}). \ -It is recommended to upgrade CPM to the most recent version. \ -See https://github.com/cpm-cmake/CPM.cmake for more information." - ) - endif() - if(${CMAKE_VERSION} VERSION_LESS "3.17.0") - include(FetchContent) - endif() - return() - endif() - - get_property( - CPM_INITIALIZED GLOBAL "" - PROPERTY CPM_INITIALIZED - SET - ) - if(CPM_INITIALIZED) - return() - endif() -endif() - -if(CURRENT_CPM_VERSION MATCHES "development-version") - message(WARNING "Your project is using an unstable development version of CPM.cmake. \ -Please update to a recent release if possible. \ -See https://github.com/cpm-cmake/CPM.cmake for details." - ) -endif() - -set_property(GLOBAL PROPERTY CPM_INITIALIZED true) - -option(CPM_USE_LOCAL_PACKAGES "Always try to use `find_package` to get dependencies" - $ENV{CPM_USE_LOCAL_PACKAGES} -) -option(CPM_LOCAL_PACKAGES_ONLY "Only use `find_package` to get dependencies" - $ENV{CPM_LOCAL_PACKAGES_ONLY} -) -option(CPM_DOWNLOAD_ALL "Always download dependencies from source" $ENV{CPM_DOWNLOAD_ALL}) -option(CPM_DONT_UPDATE_MODULE_PATH "Don't update the module path to allow using find_package" - $ENV{CPM_DONT_UPDATE_MODULE_PATH} -) -option(CPM_DONT_CREATE_PACKAGE_LOCK "Don't create a package lock file in the binary path" - $ENV{CPM_DONT_CREATE_PACKAGE_LOCK} -) -option(CPM_INCLUDE_ALL_IN_PACKAGE_LOCK - "Add all packages added through CPM.cmake to the package lock" - $ENV{CPM_INCLUDE_ALL_IN_PACKAGE_LOCK} -) -option(CPM_USE_NAMED_CACHE_DIRECTORIES - "Use additional directory of package name in cache on the most nested level." - $ENV{CPM_USE_NAMED_CACHE_DIRECTORIES} -) - -set(CPM_VERSION - ${CURRENT_CPM_VERSION} - CACHE INTERNAL "" -) -set(CPM_DIRECTORY - ${CMAKE_CURRENT_LIST_DIR} - CACHE INTERNAL "" -) -set(CPM_FILE - ${CMAKE_CURRENT_LIST_FILE} - CACHE INTERNAL "" -) -set(CPM_PACKAGES - "" - CACHE INTERNAL "" -) -set(CPM_DRY_RUN - OFF - CACHE INTERNAL "Don't download or configure dependencies (for testing)" -) - -if(DEFINED ENV{CPM_SOURCE_CACHE}) - set(CPM_SOURCE_CACHE_DEFAULT $ENV{CPM_SOURCE_CACHE}) -else() - set(CPM_SOURCE_CACHE_DEFAULT OFF) -endif() - -set(CPM_SOURCE_CACHE - ${CPM_SOURCE_CACHE_DEFAULT} - CACHE PATH "Directory to download CPM dependencies" -) - -if(NOT CPM_DONT_UPDATE_MODULE_PATH) - set(CPM_MODULE_PATH - "${CMAKE_BINARY_DIR}/CPM_modules" - CACHE INTERNAL "" - ) - # remove old modules - file(REMOVE_RECURSE ${CPM_MODULE_PATH}) - file(MAKE_DIRECTORY ${CPM_MODULE_PATH}) - # locally added CPM modules should override global packages - set(CMAKE_MODULE_PATH "${CPM_MODULE_PATH};${CMAKE_MODULE_PATH}") -endif() - -if(NOT CPM_DONT_CREATE_PACKAGE_LOCK) - set(CPM_PACKAGE_LOCK_FILE - "${CMAKE_BINARY_DIR}/cpm-package-lock.cmake" - CACHE INTERNAL "" - ) - file(WRITE ${CPM_PACKAGE_LOCK_FILE} - "# CPM Package Lock\n# This file should be committed to version control\n\n" - ) -endif() - -include(FetchContent) - -# Try to infer package name from git repository uri (path or url) -function(cpm_package_name_from_git_uri URI RESULT) - if("${URI}" MATCHES "([^/:]+)/?.git/?$") - set(${RESULT} - ${CMAKE_MATCH_1} - PARENT_SCOPE - ) - else() - unset(${RESULT} PARENT_SCOPE) - endif() -endfunction() - -# Try to infer package name and version from a url -function(cpm_package_name_and_ver_from_url url outName outVer) - if(url MATCHES "[/\\?]([a-zA-Z0-9_\\.-]+)\\.(tar|tar\\.gz|tar\\.bz2|zip|ZIP)(\\?|/|$)") - # We matched an archive - set(filename "${CMAKE_MATCH_1}") - - if(filename MATCHES "([a-zA-Z0-9_\\.-]+)[_-]v?(([0-9]+\\.)*[0-9]+[a-zA-Z0-9]*)") - # We matched - (ie foo-1.2.3) - set(${outName} - "${CMAKE_MATCH_1}" - PARENT_SCOPE - ) - set(${outVer} - "${CMAKE_MATCH_2}" - PARENT_SCOPE - ) - elseif(filename MATCHES "(([0-9]+\\.)+[0-9]+[a-zA-Z0-9]*)") - # We couldn't find a name, but we found a version - # - # In many cases (which we don't handle here) the url would look something like - # `irrelevant/ACTUAL_PACKAGE_NAME/irrelevant/1.2.3.zip`. In such a case we can't possibly - # distinguish the package name from the irrelevant bits. Moreover if we try to match the - # package name from the filename, we'd get bogus at best. - unset(${outName} PARENT_SCOPE) - set(${outVer} - "${CMAKE_MATCH_1}" - PARENT_SCOPE - ) - else() - # Boldly assume that the file name is the package name. - # - # Yes, something like `irrelevant/ACTUAL_NAME/irrelevant/download.zip` will ruin our day, but - # such cases should be quite rare. No popular service does this... we think. - set(${outName} - "${filename}" - PARENT_SCOPE - ) - unset(${outVer} PARENT_SCOPE) - endif() - else() - # No ideas yet what to do with non-archives - unset(${outName} PARENT_SCOPE) - unset(${outVer} PARENT_SCOPE) - endif() -endfunction() - -# Initialize logging prefix -if(NOT CPM_INDENT) - set(CPM_INDENT - "CPM:" - CACHE INTERNAL "" - ) -endif() - -function(cpm_find_package NAME VERSION) - string(REPLACE " " ";" EXTRA_ARGS "${ARGN}") - find_package(${NAME} ${VERSION} ${EXTRA_ARGS} QUIET) - if(${CPM_ARGS_NAME}_FOUND) - message(STATUS "${CPM_INDENT} using local package ${CPM_ARGS_NAME}@${VERSION}") - CPMRegisterPackage(${CPM_ARGS_NAME} "${VERSION}") - set(CPM_PACKAGE_FOUND - YES - PARENT_SCOPE - ) - else() - set(CPM_PACKAGE_FOUND - NO - PARENT_SCOPE - ) - endif() -endfunction() - -# Create a custom FindXXX.cmake module for a CPM package This prevents `find_package(NAME)` from -# finding the system library -function(cpm_create_module_file Name) - if(NOT CPM_DONT_UPDATE_MODULE_PATH) - # erase any previous modules - file(WRITE ${CPM_MODULE_PATH}/Find${Name}.cmake - "include(\"${CPM_FILE}\")\n${ARGN}\nset(${Name}_FOUND TRUE)" - ) - endif() -endfunction() - -# Find a package locally or fallback to CPMAddPackage -function(CPMFindPackage) - set(oneValueArgs NAME VERSION GIT_TAG FIND_PACKAGE_ARGUMENTS) - - cmake_parse_arguments(CPM_ARGS "" "${oneValueArgs}" "" ${ARGN}) - - if(NOT DEFINED CPM_ARGS_VERSION) - if(DEFINED CPM_ARGS_GIT_TAG) - cpm_get_version_from_git_tag("${CPM_ARGS_GIT_TAG}" CPM_ARGS_VERSION) - endif() - endif() - - set(downloadPackage ${CPM_DOWNLOAD_ALL}) - if(DEFINED CPM_DOWNLOAD_${CPM_ARGS_NAME}) - set(downloadPackage ${CPM_DOWNLOAD_${CPM_ARGS_NAME}}) - elseif(DEFINED ENV{CPM_DOWNLOAD_${CPM_ARGS_NAME}}) - set(downloadPackage $ENV{CPM_DOWNLOAD_${CPM_ARGS_NAME}}) - endif() - if(downloadPackage) - CPMAddPackage(${ARGN}) - cpm_export_variables(${CPM_ARGS_NAME}) - return() - endif() - - cpm_check_if_package_already_added(${CPM_ARGS_NAME} "${CPM_ARGS_VERSION}") - if(CPM_PACKAGE_ALREADY_ADDED) - cpm_export_variables(${CPM_ARGS_NAME}) - return() - endif() - - cpm_find_package(${CPM_ARGS_NAME} "${CPM_ARGS_VERSION}" ${CPM_ARGS_FIND_PACKAGE_ARGUMENTS}) - - if(NOT CPM_PACKAGE_FOUND) - CPMAddPackage(${ARGN}) - cpm_export_variables(${CPM_ARGS_NAME}) - endif() - -endfunction() - -# checks if a package has been added before -function(cpm_check_if_package_already_added CPM_ARGS_NAME CPM_ARGS_VERSION) - if("${CPM_ARGS_NAME}" IN_LIST CPM_PACKAGES) - CPMGetPackageVersion(${CPM_ARGS_NAME} CPM_PACKAGE_VERSION) - if("${CPM_PACKAGE_VERSION}" VERSION_LESS "${CPM_ARGS_VERSION}") - message( - WARNING - "${CPM_INDENT} requires a newer version of ${CPM_ARGS_NAME} (${CPM_ARGS_VERSION}) than currently included (${CPM_PACKAGE_VERSION})." - ) - endif() - cpm_get_fetch_properties(${CPM_ARGS_NAME}) - set(${CPM_ARGS_NAME}_ADDED NO) - set(CPM_PACKAGE_ALREADY_ADDED - YES - PARENT_SCOPE - ) - cpm_export_variables(${CPM_ARGS_NAME}) - else() - set(CPM_PACKAGE_ALREADY_ADDED - NO - PARENT_SCOPE - ) - endif() -endfunction() - -# Parse the argument of CPMAddPackage in case a single one was provided and convert it to a list of -# arguments which can then be parsed idiomatically. For example gh:foo/bar@1.2.3 will be converted -# to: GITHUB_REPOSITORY;foo/bar;VERSION;1.2.3 -function(cpm_parse_add_package_single_arg arg outArgs) - # Look for a scheme - if("${arg}" MATCHES "^([a-zA-Z]+):(.+)$") - string(TOLOWER "${CMAKE_MATCH_1}" scheme) - set(uri "${CMAKE_MATCH_2}") - - # Check for CPM-specific schemes - if(scheme STREQUAL "gh") - set(out "GITHUB_REPOSITORY;${uri}") - set(packageType "git") - elseif(scheme STREQUAL "gl") - set(out "GITLAB_REPOSITORY;${uri}") - set(packageType "git") - elseif(scheme STREQUAL "bb") - set(out "BITBUCKET_REPOSITORY;${uri}") - set(packageType "git") - # A CPM-specific scheme was not found. Looks like this is a generic URL so try to determine - # type - elseif(arg MATCHES ".git/?(@|#|$)") - set(out "GIT_REPOSITORY;${arg}") - set(packageType "git") - else() - # Fall back to a URL - set(out "URL;${arg}") - set(packageType "archive") - - # We could also check for SVN since FetchContent supports it, but SVN is so rare these days. - # We just won't bother with the additional complexity it will induce in this function. SVN is - # done by multi-arg - endif() - else() - if(arg MATCHES ".git/?(@|#|$)") - set(out "GIT_REPOSITORY;${arg}") - set(packageType "git") - else() - # Give up - message(FATAL_ERROR "CPM: Can't determine package type of '${arg}'") - endif() - endif() - - # For all packages we interpret @... as version. Only replace the last occurrence. Thus URIs - # containing '@' can be used - string(REGEX REPLACE "@([^@]+)$" ";VERSION;\\1" out "${out}") - - # Parse the rest according to package type - if(packageType STREQUAL "git") - # For git repos we interpret #... as a tag or branch or commit hash - string(REGEX REPLACE "#([^#]+)$" ";GIT_TAG;\\1" out "${out}") - elseif(packageType STREQUAL "archive") - # For archives we interpret #... as a URL hash. - string(REGEX REPLACE "#([^#]+)$" ";URL_HASH;\\1" out "${out}") - # We don't try to parse the version if it's not provided explicitly. cpm_get_version_from_url - # should do this at a later point - else() - # We should never get here. This is an assertion and hitting it means there's a bug in the code - # above. A packageType was set, but not handled by this if-else. - message(FATAL_ERROR "CPM: Unsupported package type '${packageType}' of '${arg}'") - endif() - - set(${outArgs} - ${out} - PARENT_SCOPE - ) -endfunction() - -# Check that the working directory for a git repo is clean -function(cpm_check_git_working_dir_is_clean repoPath gitTag isClean) - - find_package(Git REQUIRED) - - if(NOT GIT_EXECUTABLE) - # No git executable, assume directory is clean - set(${isClean} - TRUE - PARENT_SCOPE - ) - return() - endif() - - # check for uncommitted changes - execute_process( - COMMAND ${GIT_EXECUTABLE} status --porcelain - RESULT_VARIABLE resultGitStatus - OUTPUT_VARIABLE repoStatus - OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET - WORKING_DIRECTORY ${repoPath} - ) - if(resultGitStatus) - # not supposed to happen, assume clean anyway - message(WARNING "Calling git status on folder ${repoPath} failed") - set(${isClean} - TRUE - PARENT_SCOPE - ) - return() - endif() - - if(NOT "${repoStatus}" STREQUAL "") - set(${isClean} - FALSE - PARENT_SCOPE - ) - return() - endif() - - # check for committed changes - execute_process( - COMMAND ${GIT_EXECUTABLE} diff -s --exit-code ${gitTag} - RESULT_VARIABLE resultGitDiff - OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_QUIET - WORKING_DIRECTORY ${repoPath} - ) - - if(${resultGitDiff} EQUAL 0) - set(${isClean} - TRUE - PARENT_SCOPE - ) - else() - set(${isClean} - FALSE - PARENT_SCOPE - ) - endif() - -endfunction() - -# Download and add a package from source -function(CPMAddPackage) - list(LENGTH ARGN argnLength) - if(argnLength EQUAL 1) - cpm_parse_add_package_single_arg("${ARGN}" ARGN) - - # The shorthand syntax implies EXCLUDE_FROM_ALL - set(ARGN "${ARGN};EXCLUDE_FROM_ALL;YES") - endif() - - set(oneValueArgs - NAME - FORCE - VERSION - GIT_TAG - DOWNLOAD_ONLY - GITHUB_REPOSITORY - GITLAB_REPOSITORY - BITBUCKET_REPOSITORY - GIT_REPOSITORY - SOURCE_DIR - DOWNLOAD_COMMAND - FIND_PACKAGE_ARGUMENTS - NO_CACHE - GIT_SHALLOW - EXCLUDE_FROM_ALL - SOURCE_SUBDIR - ) - - set(multiValueArgs URL OPTIONS) - - cmake_parse_arguments(CPM_ARGS "" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}") - - # Set default values for arguments - - if(NOT DEFINED CPM_ARGS_VERSION) - if(DEFINED CPM_ARGS_GIT_TAG) - cpm_get_version_from_git_tag("${CPM_ARGS_GIT_TAG}" CPM_ARGS_VERSION) - endif() - endif() - - if(CPM_ARGS_DOWNLOAD_ONLY) - set(DOWNLOAD_ONLY ${CPM_ARGS_DOWNLOAD_ONLY}) - else() - set(DOWNLOAD_ONLY NO) - endif() - - if(DEFINED CPM_ARGS_GITHUB_REPOSITORY) - set(CPM_ARGS_GIT_REPOSITORY "https://github.com/${CPM_ARGS_GITHUB_REPOSITORY}.git") - elseif(DEFINED CPM_ARGS_GITLAB_REPOSITORY) - set(CPM_ARGS_GIT_REPOSITORY "https://gitlab.com/${CPM_ARGS_GITLAB_REPOSITORY}.git") - elseif(DEFINED CPM_ARGS_BITBUCKET_REPOSITORY) - set(CPM_ARGS_GIT_REPOSITORY "https://bitbucket.org/${CPM_ARGS_BITBUCKET_REPOSITORY}.git") - endif() - - if(DEFINED CPM_ARGS_GIT_REPOSITORY) - list(APPEND CPM_ARGS_UNPARSED_ARGUMENTS GIT_REPOSITORY ${CPM_ARGS_GIT_REPOSITORY}) - if(NOT DEFINED CPM_ARGS_GIT_TAG) - set(CPM_ARGS_GIT_TAG v${CPM_ARGS_VERSION}) - endif() - - # If a name wasn't provided, try to infer it from the git repo - if(NOT DEFINED CPM_ARGS_NAME) - cpm_package_name_from_git_uri(${CPM_ARGS_GIT_REPOSITORY} CPM_ARGS_NAME) - endif() - endif() - - set(CPM_SKIP_FETCH FALSE) - - if(DEFINED CPM_ARGS_GIT_TAG) - list(APPEND CPM_ARGS_UNPARSED_ARGUMENTS GIT_TAG ${CPM_ARGS_GIT_TAG}) - # If GIT_SHALLOW is explicitly specified, honor the value. - if(DEFINED CPM_ARGS_GIT_SHALLOW) - list(APPEND CPM_ARGS_UNPARSED_ARGUMENTS GIT_SHALLOW ${CPM_ARGS_GIT_SHALLOW}) - endif() - endif() - - if(DEFINED CPM_ARGS_URL) - # If a name or version aren't provided, try to infer them from the URL - list(GET CPM_ARGS_URL 0 firstUrl) - cpm_package_name_and_ver_from_url(${firstUrl} nameFromUrl verFromUrl) - # If we fail to obtain name and version from the first URL, we could try other URLs if any. - # However multiple URLs are expected to be quite rare, so for now we won't bother. - - # If the caller provided their own name and version, they trump the inferred ones. - if(NOT DEFINED CPM_ARGS_NAME) - set(CPM_ARGS_NAME ${nameFromUrl}) - endif() - if(NOT DEFINED CPM_ARGS_VERSION) - set(CPM_ARGS_VERSION ${verFromUrl}) - endif() - - list(APPEND CPM_ARGS_UNPARSED_ARGUMENTS URL "${CPM_ARGS_URL}") - endif() - - # Check for required arguments - - if(NOT DEFINED CPM_ARGS_NAME) - message( - FATAL_ERROR - "CPM: 'NAME' was not provided and couldn't be automatically inferred for package added with arguments: '${ARGN}'" - ) - endif() - - # Check if package has been added before - cpm_check_if_package_already_added(${CPM_ARGS_NAME} "${CPM_ARGS_VERSION}") - if(CPM_PACKAGE_ALREADY_ADDED) - cpm_export_variables(${CPM_ARGS_NAME}) - return() - endif() - - # Check for manual overrides - if(NOT CPM_ARGS_FORCE AND NOT "${CPM_${CPM_ARGS_NAME}_SOURCE}" STREQUAL "") - set(PACKAGE_SOURCE ${CPM_${CPM_ARGS_NAME}_SOURCE}) - set(CPM_${CPM_ARGS_NAME}_SOURCE "") - CPMAddPackage( - NAME "${CPM_ARGS_NAME}" - SOURCE_DIR "${PACKAGE_SOURCE}" - EXCLUDE_FROM_ALL "${CPM_ARGS_EXCLUDE_FROM_ALL}" - OPTIONS "${CPM_ARGS_OPTIONS}" - SOURCE_SUBDIR "${CPM_ARGS_SOURCE_SUBDIR}" - DOWNLOAD_ONLY "${DOWNLOAD_ONLY}" - FORCE True - ) - cpm_export_variables(${CPM_ARGS_NAME}) - return() - endif() - - # Check for available declaration - if(NOT CPM_ARGS_FORCE AND NOT "${CPM_DECLARATION_${CPM_ARGS_NAME}}" STREQUAL "") - set(declaration ${CPM_DECLARATION_${CPM_ARGS_NAME}}) - set(CPM_DECLARATION_${CPM_ARGS_NAME} "") - CPMAddPackage(${declaration}) - cpm_export_variables(${CPM_ARGS_NAME}) - # checking again to ensure version and option compatibility - cpm_check_if_package_already_added(${CPM_ARGS_NAME} "${CPM_ARGS_VERSION}") - return() - endif() - - if(CPM_USE_LOCAL_PACKAGES OR CPM_LOCAL_PACKAGES_ONLY) - cpm_find_package(${CPM_ARGS_NAME} "${CPM_ARGS_VERSION}" ${CPM_ARGS_FIND_PACKAGE_ARGUMENTS}) - - if(CPM_PACKAGE_FOUND) - cpm_export_variables(${CPM_ARGS_NAME}) - return() - endif() - - if(CPM_LOCAL_PACKAGES_ONLY) - message( - SEND_ERROR - "CPM: ${CPM_ARGS_NAME} not found via find_package(${CPM_ARGS_NAME} ${CPM_ARGS_VERSION})" - ) - endif() - endif() - - CPMRegisterPackage("${CPM_ARGS_NAME}" "${CPM_ARGS_VERSION}") - - if(DEFINED CPM_ARGS_GIT_TAG) - set(PACKAGE_INFO "${CPM_ARGS_GIT_TAG}") - elseif(DEFINED CPM_ARGS_SOURCE_DIR) - set(PACKAGE_INFO "${CPM_ARGS_SOURCE_DIR}") - else() - set(PACKAGE_INFO "${CPM_ARGS_VERSION}") - endif() - - if(DEFINED FETCHCONTENT_BASE_DIR) - # respect user's FETCHCONTENT_BASE_DIR if set - set(CPM_FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR}) - else() - set(CPM_FETCHCONTENT_BASE_DIR ${CMAKE_BINARY_DIR}/_deps) - endif() - - if(DEFINED CPM_ARGS_DOWNLOAD_COMMAND) - list(APPEND CPM_ARGS_UNPARSED_ARGUMENTS DOWNLOAD_COMMAND ${CPM_ARGS_DOWNLOAD_COMMAND}) - elseif(DEFINED CPM_ARGS_SOURCE_DIR) - list(APPEND CPM_ARGS_UNPARSED_ARGUMENTS SOURCE_DIR ${CPM_ARGS_SOURCE_DIR}) - elseif(CPM_SOURCE_CACHE AND NOT CPM_ARGS_NO_CACHE) - string(TOLOWER ${CPM_ARGS_NAME} lower_case_name) - set(origin_parameters ${CPM_ARGS_UNPARSED_ARGUMENTS}) - list(SORT origin_parameters) - if(CPM_USE_NAMED_CACHE_DIRECTORIES) - string(SHA1 origin_hash "${origin_parameters};NEW_CACHE_STRUCTURE_TAG") - set(download_directory ${CPM_SOURCE_CACHE}/${lower_case_name}/${origin_hash}/${CPM_ARGS_NAME}) - else() - string(SHA1 origin_hash "${origin_parameters}") - set(download_directory ${CPM_SOURCE_CACHE}/${lower_case_name}/${origin_hash}) - endif() - # Expand `download_directory` relative path. This is important because EXISTS doesn't work for - # relative paths. - get_filename_component(download_directory ${download_directory} ABSOLUTE) - list(APPEND CPM_ARGS_UNPARSED_ARGUMENTS SOURCE_DIR ${download_directory}) - if(EXISTS ${download_directory}) - cpm_store_fetch_properties( - ${CPM_ARGS_NAME} "${download_directory}" - "${CPM_FETCHCONTENT_BASE_DIR}/${lower_case_name}-build" - ) - cpm_get_fetch_properties("${CPM_ARGS_NAME}") - - if(DEFINED CPM_ARGS_GIT_TAG) - # warn if cache has been changed since checkout - cpm_check_git_working_dir_is_clean(${download_directory} ${CPM_ARGS_GIT_TAG} IS_CLEAN) - if(NOT ${IS_CLEAN}) - message(WARNING "Cache for ${CPM_ARGS_NAME} (${download_directory}) is dirty") - endif() - endif() - - cpm_add_subdirectory( - "${CPM_ARGS_NAME}" "${DOWNLOAD_ONLY}" - "${${CPM_ARGS_NAME}_SOURCE_DIR}/${CPM_ARGS_SOURCE_SUBDIR}" "${${CPM_ARGS_NAME}_BINARY_DIR}" - "${CPM_ARGS_EXCLUDE_FROM_ALL}" "${CPM_ARGS_OPTIONS}" - ) - set(CPM_SKIP_FETCH TRUE) - set(PACKAGE_INFO "${PACKAGE_INFO} at ${download_directory}") - else() - # Enable shallow clone when GIT_TAG is not a commit hash. Our guess may not be accurate, but - # it should guarantee no commit hash get mis-detected. - if(NOT DEFINED CPM_ARGS_GIT_SHALLOW) - cpm_is_git_tag_commit_hash("${CPM_ARGS_GIT_TAG}" IS_HASH) - if(NOT ${IS_HASH}) - list(APPEND CPM_ARGS_UNPARSED_ARGUMENTS GIT_SHALLOW TRUE) - endif() - endif() - - # remove timestamps so CMake will re-download the dependency - file(REMOVE_RECURSE ${CPM_FETCHCONTENT_BASE_DIR}/${lower_case_name}-subbuild) - set(PACKAGE_INFO "${PACKAGE_INFO} to ${download_directory}") - endif() - endif() - - cpm_create_module_file(${CPM_ARGS_NAME} "CPMAddPackage(\"${ARGN}\")") - - if(CPM_PACKAGE_LOCK_ENABLED) - if((CPM_ARGS_VERSION AND NOT CPM_ARGS_SOURCE_DIR) OR CPM_INCLUDE_ALL_IN_PACKAGE_LOCK) - cpm_add_to_package_lock(${CPM_ARGS_NAME} "${ARGN}") - elseif(CPM_ARGS_SOURCE_DIR) - cpm_add_comment_to_package_lock(${CPM_ARGS_NAME} "local directory") - else() - cpm_add_comment_to_package_lock(${CPM_ARGS_NAME} "${ARGN}") - endif() - endif() - - message( - STATUS "${CPM_INDENT} adding package ${CPM_ARGS_NAME}@${CPM_ARGS_VERSION} (${PACKAGE_INFO})" - ) - - if(NOT CPM_SKIP_FETCH) - cpm_declare_fetch( - "${CPM_ARGS_NAME}" "${CPM_ARGS_VERSION}" "${PACKAGE_INFO}" "${CPM_ARGS_UNPARSED_ARGUMENTS}" - ) - cpm_fetch_package("${CPM_ARGS_NAME}" populated) - if(${populated}) - cpm_add_subdirectory( - "${CPM_ARGS_NAME}" "${DOWNLOAD_ONLY}" - "${${CPM_ARGS_NAME}_SOURCE_DIR}/${CPM_ARGS_SOURCE_SUBDIR}" "${${CPM_ARGS_NAME}_BINARY_DIR}" - "${CPM_ARGS_EXCLUDE_FROM_ALL}" "${CPM_ARGS_OPTIONS}" - ) - endif() - cpm_get_fetch_properties("${CPM_ARGS_NAME}") - endif() - - set(${CPM_ARGS_NAME}_ADDED YES) - cpm_export_variables("${CPM_ARGS_NAME}") -endfunction() - -# Fetch a previously declared package -macro(CPMGetPackage Name) - if(DEFINED "CPM_DECLARATION_${Name}") - CPMAddPackage(NAME ${Name}) - else() - message(SEND_ERROR "Cannot retrieve package ${Name}: no declaration available") - endif() -endmacro() - -# export variables available to the caller to the parent scope expects ${CPM_ARGS_NAME} to be set -macro(cpm_export_variables name) - set(${name}_SOURCE_DIR - "${${name}_SOURCE_DIR}" - PARENT_SCOPE - ) - set(${name}_BINARY_DIR - "${${name}_BINARY_DIR}" - PARENT_SCOPE - ) - set(${name}_ADDED - "${${name}_ADDED}" - PARENT_SCOPE - ) -endmacro() - -# declares a package, so that any call to CPMAddPackage for the package name will use these -# arguments instead. Previous declarations will not be overridden. -macro(CPMDeclarePackage Name) - if(NOT DEFINED "CPM_DECLARATION_${Name}") - set("CPM_DECLARATION_${Name}" "${ARGN}") - endif() -endmacro() - -function(cpm_add_to_package_lock Name) - if(NOT CPM_DONT_CREATE_PACKAGE_LOCK) - cpm_prettify_package_arguments(PRETTY_ARGN false ${ARGN}) - file(APPEND ${CPM_PACKAGE_LOCK_FILE} "# ${Name}\nCPMDeclarePackage(${Name}\n${PRETTY_ARGN})\n") - endif() -endfunction() - -function(cpm_add_comment_to_package_lock Name) - if(NOT CPM_DONT_CREATE_PACKAGE_LOCK) - cpm_prettify_package_arguments(PRETTY_ARGN true ${ARGN}) - file(APPEND ${CPM_PACKAGE_LOCK_FILE} - "# ${Name} (unversioned)\n# CPMDeclarePackage(${Name}\n${PRETTY_ARGN}#)\n" - ) - endif() -endfunction() - -# includes the package lock file if it exists and creates a target `cpm-update-package-lock` to -# update it -macro(CPMUsePackageLock file) - if(NOT CPM_DONT_CREATE_PACKAGE_LOCK) - get_filename_component(CPM_ABSOLUTE_PACKAGE_LOCK_PATH ${file} ABSOLUTE) - if(EXISTS ${CPM_ABSOLUTE_PACKAGE_LOCK_PATH}) - include(${CPM_ABSOLUTE_PACKAGE_LOCK_PATH}) - endif() - if(NOT TARGET cpm-update-package-lock) - add_custom_target( - cpm-update-package-lock COMMAND ${CMAKE_COMMAND} -E copy ${CPM_PACKAGE_LOCK_FILE} - ${CPM_ABSOLUTE_PACKAGE_LOCK_PATH} - ) - endif() - set(CPM_PACKAGE_LOCK_ENABLED true) - endif() -endmacro() - -# registers a package that has been added to CPM -function(CPMRegisterPackage PACKAGE VERSION) - list(APPEND CPM_PACKAGES ${PACKAGE}) - set(CPM_PACKAGES - ${CPM_PACKAGES} - CACHE INTERNAL "" - ) - set("CPM_PACKAGE_${PACKAGE}_VERSION" - ${VERSION} - CACHE INTERNAL "" - ) -endfunction() - -# retrieve the current version of the package to ${OUTPUT} -function(CPMGetPackageVersion PACKAGE OUTPUT) - set(${OUTPUT} - "${CPM_PACKAGE_${PACKAGE}_VERSION}" - PARENT_SCOPE - ) -endfunction() - -# declares a package in FetchContent_Declare -function(cpm_declare_fetch PACKAGE VERSION INFO) - if(${CPM_DRY_RUN}) - message(STATUS "${CPM_INDENT} package not declared (dry run)") - return() - endif() - - FetchContent_Declare(${PACKAGE} ${ARGN}) -endfunction() - -# returns properties for a package previously defined by cpm_declare_fetch -function(cpm_get_fetch_properties PACKAGE) - if(${CPM_DRY_RUN}) - return() - endif() - - set(${PACKAGE}_SOURCE_DIR - "${CPM_PACKAGE_${PACKAGE}_SOURCE_DIR}" - PARENT_SCOPE - ) - set(${PACKAGE}_BINARY_DIR - "${CPM_PACKAGE_${PACKAGE}_BINARY_DIR}" - PARENT_SCOPE - ) -endfunction() - -function(cpm_store_fetch_properties PACKAGE source_dir binary_dir) - if(${CPM_DRY_RUN}) - return() - endif() - - set(CPM_PACKAGE_${PACKAGE}_SOURCE_DIR - "${source_dir}" - CACHE INTERNAL "" - ) - set(CPM_PACKAGE_${PACKAGE}_BINARY_DIR - "${binary_dir}" - CACHE INTERNAL "" - ) -endfunction() - -# adds a package as a subdirectory if viable, according to provided options -function( - cpm_add_subdirectory - PACKAGE - DOWNLOAD_ONLY - SOURCE_DIR - BINARY_DIR - EXCLUDE - OPTIONS -) - if(NOT DOWNLOAD_ONLY AND EXISTS ${SOURCE_DIR}/CMakeLists.txt) - if(EXCLUDE) - set(addSubdirectoryExtraArgs EXCLUDE_FROM_ALL) - else() - set(addSubdirectoryExtraArgs "") - endif() - if(OPTIONS) - # the policy allows us to change options without caching - cmake_policy(SET CMP0077 NEW) - set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) - - # the policy allows us to change set(CACHE) without caching - if(POLICY CMP0126) - cmake_policy(SET CMP0126 NEW) - set(CMAKE_POLICY_DEFAULT_CMP0126 NEW) - endif() - - foreach(OPTION ${OPTIONS}) - cpm_parse_option("${OPTION}") - set(${OPTION_KEY} "${OPTION_VALUE}") - endforeach() - endif() - set(CPM_OLD_INDENT "${CPM_INDENT}") - set(CPM_INDENT "${CPM_INDENT} ${PACKAGE}:") - add_subdirectory(${SOURCE_DIR} ${BINARY_DIR} ${addSubdirectoryExtraArgs}) - set(CPM_INDENT "${CPM_OLD_INDENT}") - endif() -endfunction() - -# downloads a previously declared package via FetchContent and exports the variables -# `${PACKAGE}_SOURCE_DIR` and `${PACKAGE}_BINARY_DIR` to the parent scope -function(cpm_fetch_package PACKAGE populated) - set(${populated} - FALSE - PARENT_SCOPE - ) - if(${CPM_DRY_RUN}) - message(STATUS "${CPM_INDENT} package ${PACKAGE} not fetched (dry run)") - return() - endif() - - FetchContent_GetProperties(${PACKAGE}) - - string(TOLOWER "${PACKAGE}" lower_case_name) - - if(NOT ${lower_case_name}_POPULATED) - FetchContent_Populate(${PACKAGE}) - set(${populated} - TRUE - PARENT_SCOPE - ) - endif() - - cpm_store_fetch_properties( - ${CPM_ARGS_NAME} ${${lower_case_name}_SOURCE_DIR} ${${lower_case_name}_BINARY_DIR} - ) - - set(${PACKAGE}_SOURCE_DIR - ${${lower_case_name}_SOURCE_DIR} - PARENT_SCOPE - ) - set(${PACKAGE}_BINARY_DIR - ${${lower_case_name}_BINARY_DIR} - PARENT_SCOPE - ) -endfunction() - -# splits a package option -function(cpm_parse_option OPTION) - string(REGEX MATCH "^[^ ]+" OPTION_KEY "${OPTION}") - string(LENGTH "${OPTION}" OPTION_LENGTH) - string(LENGTH "${OPTION_KEY}" OPTION_KEY_LENGTH) - if(OPTION_KEY_LENGTH STREQUAL OPTION_LENGTH) - # no value for key provided, assume user wants to set option to "ON" - set(OPTION_VALUE "ON") - else() - math(EXPR OPTION_KEY_LENGTH "${OPTION_KEY_LENGTH}+1") - string(SUBSTRING "${OPTION}" "${OPTION_KEY_LENGTH}" "-1" OPTION_VALUE) - endif() - set(OPTION_KEY - "${OPTION_KEY}" - PARENT_SCOPE - ) - set(OPTION_VALUE - "${OPTION_VALUE}" - PARENT_SCOPE - ) -endfunction() - -# guesses the package version from a git tag -function(cpm_get_version_from_git_tag GIT_TAG RESULT) - string(LENGTH ${GIT_TAG} length) - if(length EQUAL 40) - # GIT_TAG is probably a git hash - set(${RESULT} - 0 - PARENT_SCOPE - ) - else() - string(REGEX MATCH "v?([0123456789.]*).*" _ ${GIT_TAG}) - set(${RESULT} - ${CMAKE_MATCH_1} - PARENT_SCOPE - ) - endif() -endfunction() - -# guesses if the git tag is a commit hash or an actual tag or a branch name. -function(cpm_is_git_tag_commit_hash GIT_TAG RESULT) - string(LENGTH "${GIT_TAG}" length) - # full hash has 40 characters, and short hash has at least 7 characters. - if(length LESS 7 OR length GREATER 40) - set(${RESULT} - 0 - PARENT_SCOPE - ) - else() - if(${GIT_TAG} MATCHES "^[a-fA-F0-9]+$") - set(${RESULT} - 1 - PARENT_SCOPE - ) - else() - set(${RESULT} - 0 - PARENT_SCOPE - ) - endif() - endif() -endfunction() - -function(cpm_prettify_package_arguments OUT_VAR IS_IN_COMMENT) - set(oneValueArgs - NAME - FORCE - VERSION - GIT_TAG - DOWNLOAD_ONLY - GITHUB_REPOSITORY - GITLAB_REPOSITORY - GIT_REPOSITORY - SOURCE_DIR - DOWNLOAD_COMMAND - FIND_PACKAGE_ARGUMENTS - NO_CACHE - GIT_SHALLOW - ) - set(multiValueArgs OPTIONS) - cmake_parse_arguments(CPM_ARGS "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - foreach(oneArgName ${oneValueArgs}) - if(DEFINED CPM_ARGS_${oneArgName}) - if(${IS_IN_COMMENT}) - string(APPEND PRETTY_OUT_VAR "#") - endif() - if(${oneArgName} STREQUAL "SOURCE_DIR") - string(REPLACE ${CMAKE_SOURCE_DIR} "\${CMAKE_SOURCE_DIR}" CPM_ARGS_${oneArgName} - ${CPM_ARGS_${oneArgName}} - ) - endif() - string(APPEND PRETTY_OUT_VAR " ${oneArgName} ${CPM_ARGS_${oneArgName}}\n") - endif() - endforeach() - foreach(multiArgName ${multiValueArgs}) - if(DEFINED CPM_ARGS_${multiArgName}) - if(${IS_IN_COMMENT}) - string(APPEND PRETTY_OUT_VAR "#") - endif() - string(APPEND PRETTY_OUT_VAR " ${multiArgName}\n") - foreach(singleOption ${CPM_ARGS_${multiArgName}}) - if(${IS_IN_COMMENT}) - string(APPEND PRETTY_OUT_VAR "#") - endif() - string(APPEND PRETTY_OUT_VAR " \"${singleOption}\"\n") - endforeach() - endif() - endforeach() - - if(NOT "${CPM_ARGS_UNPARSED_ARGUMENTS}" STREQUAL "") - if(${IS_IN_COMMENT}) - string(APPEND PRETTY_OUT_VAR "#") - endif() - string(APPEND PRETTY_OUT_VAR " ") - foreach(CPM_ARGS_UNPARSED_ARGUMENT ${CPM_ARGS_UNPARSED_ARGUMENTS}) - string(APPEND PRETTY_OUT_VAR " ${CPM_ARGS_UNPARSED_ARGUMENT}") - endforeach() - string(APPEND PRETTY_OUT_VAR "\n") - endif() - - set(${OUT_VAR} - ${PRETTY_OUT_VAR} - PARENT_SCOPE - ) - -endfunction() \ No newline at end of file diff --git a/cmake/FindFFmpeg.cmake b/cmake/FindFFmpeg.cmake index 0dd25b1c..b55373c8 100644 --- a/cmake/FindFFmpeg.cmake +++ b/cmake/FindFFmpeg.cmake @@ -2,44 +2,23 @@ cmake_minimum_required (VERSION 3.15 FATAL_ERROR) include_guard (GLOBAL) +include (FetchContent) include (FeatureSummary) +include (FindPackageMessage) -set_package_properties (FFmpeg PROPERTIES - URL "https://www.ffmpeg.org/" - DESCRIPTION "Open source library for audio and video codecs") +set_package_properties ("${CMAKE_FIND_PACKAGE_NAME}" + PROPERTIES + URL "https://www.ffmpeg.org/" + DESCRIPTION "Audio and video codecs") -set (FFmpeg_FOUND FALSE) +FetchContent_Declare (FFmpeg + GIT_REPOSITORY "https://github.com/ffAudio/FFmpegBuild.git" + GIT_TAG origin/main) -set (FFMPEG_LIBS avutil swresample avcodec avformat swscale CACHE INTERNAL "") +FetchContent_MakeAvailable (FFmpeg) -option (FFMPEG_USE_SYSTEM_INSTALL "Use preinstalled ffmpeg found on system, if any" OFF) +find_package_message ("${CMAKE_FIND_PACKAGE_NAME}" + "FFmpeg package found -- Sources downloaded" + "FFmpeg (GitHub)") -if (FFMPEG_USE_SYSTEM_INSTALL) - include ("${CMAKE_CURRENT_LIST_DIR}/ffmpeg/FindInstalledFFmpeg.cmake") -endif() - -if (TARGET ffmpeg) - if (NOT FFmpeg_FIND_QUIETLY) - message (STATUS "Using system installation of FFmpeg") - endif() -else() - if (FFMPEG_USE_SYSTEM_INSTALL) - if (NOT FFmpeg_FIND_QUIETLY) - message (WARNING "System installation of FFmpeg was requested, but targets couldn't be imported. Configuring to build from source...") - endif() - endif() - - include ("${CMAKE_CURRENT_LIST_DIR}/ffmpeg/BuildFFmpeg.cmake") -endif() - -if (NOT TARGET ffmpeg) - if (FFmpeg_FIND_REQUIRED) - message (FATAL_ERROR "Error creating ffmpeg target!") - endif() -endif() - -target_compile_definitions (ffmpeg INTERFACE FOLEYS_USE_FFMPEG=1) - -add_library (ffmpeg::ffmpeg ALIAS ffmpeg) - -set (FFmpeg_FOUND TRUE) +set (${CMAKE_FIND_PACKAGE_NAME}_FOUND TRUE) diff --git a/cmake/FindJUCE.cmake b/cmake/FindJUCE.cmake index 30853199..5875405b 100644 --- a/cmake/FindJUCE.cmake +++ b/cmake/FindJUCE.cmake @@ -2,16 +2,27 @@ cmake_minimum_required (VERSION 3.15 FATAL_ERROR) include_guard (GLOBAL) +include (FetchContent) include (FeatureSummary) +include (FindPackageMessage) -set_package_properties (JUCE PROPERTIES URL "https://juce.com/" - DESCRIPTION "Cross platform framework for plugin and app development") +set_package_properties ("${CMAKE_FIND_PACKAGE_NAME}" + PROPERTIES + URL "https://juce.com/" + DESCRIPTION "Cross platform framework for plugin and app development") -include ("${CMAKE_CURRENT_LIST_DIR}/AddCPM.cmake") +FetchContent_Declare (JUCE + GIT_REPOSITORY https://github.com/juce-framework/JUCE.git + GIT_TAG origin/master) -CPMAddPackage (NAME JUCE - GITHUB_REPOSITORY juce-framework/JUCE - GIT_TAG origin/develop - OPTIONS "JUCE_BUILD_EXAMPLES OFF" "JUCE_BUILD_EXTRAS OFF" "JUCE_ENABLE_MODULE_SOURCE_GROUPS ON") +set (JUCE_BUILD_EXAMPLES OFF) +set (JUCE_BUILD_EXTRAS OFF) +set (JUCE_ENABLE_MODULE_SOURCE_GROUPS ON) -set (JUCE_FOUND TRUE) \ No newline at end of file +FetchContent_MakeAvailable (JUCE) + +find_package_message ("${CMAKE_FIND_PACKAGE_NAME}" + "JUCE package found -- Sources downloaded" + "JUCE (GitHub)") + +set (${CMAKE_FIND_PACKAGE_NAME}_FOUND TRUE) diff --git a/cmake/FoleysDefaultSettings.cmake b/cmake/FoleysDefaultSettings.cmake deleted file mode 100644 index e0a17cfc..00000000 --- a/cmake/FoleysDefaultSettings.cmake +++ /dev/null @@ -1,72 +0,0 @@ -cmake_minimum_required (VERSION 3.15 FATAL_ERROR) - -include_guard (GLOBAL) - -set_property (GLOBAL PROPERTY USE_FOLDERS YES) - -set (ENV{CMAKE_EXPORT_COMPILE_COMMANDS} TRUE) -set (CMAKE_EXPORT_COMPILE_COMMANDS TRUE) - -if (NOT DEFINED ENV{CMAKE_INSTALL_MODE}) - set (ENV{CMAKE_INSTALL_MODE} ABS_SYMLINK_OR_COPY) -endif() - -include (CheckIPOSupported) - -check_ipo_supported (RESULT result OUTPUT output) - -if(result) - set (ENV{CMAKE_INTERPROCEDURAL_OPTIMIZATION} ON) - set (CMAKE_INTERPROCEDURAL_OPTIMIZATION ON CACHE INTERNAL "") - message (VERBOSE "Enabling IPO") -endif() - - -if(APPLE) - if(IOS) - set (ENV{MACOSX_DEPLOYMENT_TARGET} 9.3) - set (CMAKE_OSX_DEPLOYMENT_TARGET 9.3) - - set (CMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH NO) - - option (FOLEYS_IOS_SIMULATOR "Build for an iOS simulator, rather than a real device" ON) - - if(FOLEYS_IOS_SIMULATOR) - set (CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "\"iPhone Developer\"" CACHE INTERNAL "") - - set (IOS_PLATFORM_LOCATION "iPhoneSimulator.platform" CACHE INTERNAL "") - set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphonesimulator" CACHE INTERNAL "") - - set (ENV{CMAKE_OSX_ARCHITECTURES} "i386;x86_64") - set (CMAKE_OSX_ARCHITECTURES "i386;x86_64" CACHE INTERNAL "") - - else() # Options for building for a real device - - set (CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM "" CACHE STRING "") - - set (IOS_PLATFORM_LOCATION "iPhoneOS.platform" CACHE INTERNAL "") - set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos" CACHE INTERNAL "") - - set (ENV{CMAKE_OSX_ARCHITECTURES} "armv7;armv7s;arm64;i386;x86_64") - set (CMAKE_OSX_ARCHITECTURES "armv7;armv7s;arm64;i386;x86_64" CACHE INTERNAL "") - - endif() - else() - set (ENV{MACOSX_DEPLOYMENT_TARGET} 10.11) - set (CMAKE_OSX_DEPLOYMENT_TARGET 10.11) - - option (FOLEYS_MAC_UNIVERSAL_BINARY "Builds for x86_64 and arm64" ON) - - if(FOLEYS_MAC_UNIVERSAL_BINARY) - set (ENV{CMAKE_OSX_ARCHITECTURES} "x86_64;arm64") - set (CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE INTERNAL "") - endif() - endif() -else() - set (CMAKE_INSTALL_RPATH $ORIGIN) - - if(WIN32) - set (CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") - endif() -endif() - diff --git a/cmake/FoleysDefaultTarget.cmake b/cmake/FoleysDefaultTarget.cmake deleted file mode 100644 index 82dd3c1b..00000000 --- a/cmake/FoleysDefaultTarget.cmake +++ /dev/null @@ -1,86 +0,0 @@ -cmake_minimum_required (VERSION 3.15 FATAL_ERROR) - -include_guard (GLOBAL) - -include (FoleysDefaultSettings) - -add_library (FoleysDefaultTarget INTERFACE) - -set_target_properties (FoleysDefaultTarget PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON) - -target_compile_features (FoleysDefaultTarget INTERFACE cxx_std_17) - -if((CMAKE_CXX_COMPILER_ID MATCHES "MSVC") OR (CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES "MSVC")) - - # config flags - target_compile_options ( - FoleysDefaultTarget INTERFACE $,/Od /Zi,/Ox> - $<$:/MP> /EHsc) - - # LTO - target_compile_options ( - FoleysDefaultTarget - INTERFACE $<$:$,-GL,-flto>> - ) - - target_link_libraries ( - FoleysDefaultTarget - INTERFACE $<$:$<$:-LTCG>>) - -elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang|GNU") - - # config flags - target_compile_options (FoleysDefaultTarget INTERFACE $<$:-g -O0> - $<$:-O3>) - - # LTO - if(NOT MINGW) - target_compile_options (FoleysDefaultTarget INTERFACE $<$:-flto>) - target_link_libraries (FoleysDefaultTarget INTERFACE $<$:-flto>) - endif() - -endif() - - -# MacOS options - -if(APPLE) - - set_target_properties (FoleysDefaultTarget PROPERTIES XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME YES) - target_compile_definitions (FoleysDefaultTarget INTERFACE JUCE_USE_VDSP_FRAMEWORK=1) - - if(IOS) - - set_target_properties (FoleysDefaultTarget PROPERTIES - ARCHIVE_OUTPUT_DIRECTORY "./" - XCODE_ATTRIBUTE_INSTALL_PATH "$(LOCAL_APPS_DIR)" - XCODE_ATTRIBUTE_SKIP_INSTALL "NO" - XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH "NO" - XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET "9.3") - - target_compile_options (FoleysDefaultTarget INTERFACE "-mmacosx-version-min=9.3") - target_link_options (FoleysDefaultTarget INTERFACE "-mmacosx-version-min=9.3") - - else() - - option (FOLEYS_MAC_UNIVERSAL_BINARY "Builds for x86_64 and arm64" ON) - - if (FOLEYS_MAC_UNIVERSAL_BINARY AND XCODE) - - execute_process (COMMAND uname -m RESULT_VARIABLE result OUTPUT_VARIABLE osx_native_arch - OUTPUT_STRIP_TRAILING_WHITESPACE) - - if ("${osx_native_arch}" STREQUAL "arm64") - set_target_properties (FoleysDefaultTarget PROPERTIES OSX_ARCHITECTURES "x86_64;arm64") - message (STATUS "Enabling Mac universal binary") - endif() - endif() - - set_target_properties (FoleysDefaultTarget PROPERTIES XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET "10.11") - - target_compile_options (FoleysDefaultTarget INTERFACE "-mmacosx-version-min=10.11") - target_link_options (FoleysDefaultTarget INTERFACE "-mmacosx-version-min=10.11") - endif() -endif() - -add_library (Foleys::FoleysDefaultTarget ALIAS FoleysDefaultTarget) diff --git a/cmake/config.cmake b/cmake/config.cmake new file mode 100644 index 00000000..eeefbcbb --- /dev/null +++ b/cmake/config.cmake @@ -0,0 +1,51 @@ +#[[ + +CMake package configuration file for foleys_video_engine + +This file is loaded by the find_package command to load an installed copy of foleys_video_engine +and bring it into another CMake build tree. + +The way our install works is that we replicate the layout of the source tree in the package root, and +in this file we call juce_add_module just the same way that building this project does. + +]] + +@PACKAGE_INIT@ + +check_required_components ("@PROJECT_NAME@") + +# + +include (FeatureSummary) +include (FindPackageMessage) + +set_package_properties ("${CMAKE_FIND_PACKAGE_NAME}" + PROPERTIES + URL "https://foleysfinest.com/foleys_video_engine/" + DESCRIPTION "A video engine module for JUCE") + +# + +list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") + +include (CMakeFindDependencyMacro) + +find_dependency (JUCE 6) +find_dependency (FFmpeg) + +juce_add_module ("${CMAKE_CURRENT_LIST_DIR}" + ALIAS_NAMESPACE Foleys) + +target_compile_definitions (foleys_video_engine INTERFACE + JUCE_MODAL_LOOPS_PERMITTED=1 + JUCE_STRICT_REFCOUNTEDPOINTER=1 + JUCE_PLUGINHOST_AU=1 + JUCE_PLUGINHOST_VST3=1 + JUCE_PLUGINHOST_LADSPA=1) + +target_link_libraries (foleys_video_engine INTERFACE ffmpeg::ffmpeg) + +find_package_message ("${CMAKE_FIND_PACKAGE_NAME}" + "foleys_video_engine - local install" + "foleys_video_engine [${CMAKE_CURRENT_LIST_DIR}]") + diff --git a/cmake/ffmpeg/BuildFFmpeg.cmake b/cmake/ffmpeg/BuildFFmpeg.cmake deleted file mode 100644 index da557a60..00000000 --- a/cmake/ffmpeg/BuildFFmpeg.cmake +++ /dev/null @@ -1,65 +0,0 @@ -cmake_minimum_required (VERSION 3.15 FATAL_ERROR) - -include_guard (GLOBAL) - -find_program (FFMPEG_MAKE_EXECUTABLE NAMES make gmake nmake - DOC "Path to the make executable used for building FFmpeg") - -mark_as_advanced (FORCE FFMPEG_MAKE_EXECUTABLE) - -if (NOT FFMPEG_MAKE_EXECUTABLE) - message (FATAL_ERROR "Make could not be found, and is required to build FFmpeg!") -endif() - -set (FFMPEG_CONFIGURE_EXTRAS "" CACHE STRING "Extra flags passed to FFmpeg's configuration script") -set (FFMPEG_EXTRA_C_FLAGS "" CACHE STRING "Extra C flags for FFmpeg") -set (FFMPEG_EXTRA_LD_FLAGS "" CACHE STRING "Extra linker flags for FFmpeg") -set (FFMPEG_VERSION 4.4.1 CACHE STRING "FFmpeg version") - -mark_as_advanced (FORCE FFMPEG_CONFIGURE_EXTRAS FFMPEG_EXTRA_C_FLAGS FFMPEG_EXTRA_LD_FLAGS FFMPEG_VERSION) - -set (FFMPEG_NAME "ffmpeg-${FFMPEG_VERSION}") - -if (DEFINED ENV{CPM_SOURCE_CACHE}) - set (FOLEYS_SOURCE_CACHE "$ENV{CPM_SOURCE_CACHE}") -else() - set (FOLEYS_SOURCE_CACHE "${PROJECT_SOURCE_DIR}/Cache") -endif() - -set (FFMPEG_SOURCE_DIR "${FOLEYS_SOURCE_CACHE}/${FFMPEG_NAME}") - -# - -if (NOT EXISTS "${FFMPEG_SOURCE_DIR}") - - set (FFMPEG_URL "https://ffmpeg.org/releases/${FFMPEG_NAME}.tar.bz2") - - if (NOT FFmpeg_FIND_QUIETLY) - message (STATUS "Downloading FFmpeg sources from ${FFMPEG_URL} to ${FFMPEG_SOURCE_DIR}...") - endif() - - get_filename_component (FFMPEG_ARCHIVE_NAME "${FFMPEG_URL}" NAME) - - set (ffmpeg_tarball "${FOLEYS_SOURCE_CACHE}/${FFMPEG_ARCHIVE_NAME}") - - file (DOWNLOAD "${FFMPEG_URL}" "${ffmpeg_tarball}") - - execute_process (COMMAND "${CMAKE_COMMAND}" -E tar xzf "${ffmpeg_tarball}" - WORKING_DIRECTORY "${FOLEYS_SOURCE_CACHE}") - - file (REMOVE "${ffmpeg_tarball}") - -endif() - -# - -string (REPLACE " -Wl,--fatal-warnings" "" FFMPEG_LD_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") -set (FFMPEG_LD_FLAGS "${FFMPEG_C_FLAGS} ${FFMPEG_LD_FLAGS} ${FFMPEG_EXTRA_LD_FLAGS}") - -# - -include ("${CMAKE_CURRENT_LIST_DIR}/ConfigureFFmpegBuild.cmake") - -foleys_configure_ffmpeg_build (SOURCE_DIR "${FFMPEG_SOURCE_DIR}") - - diff --git a/cmake/ffmpeg/ConfigureFFmpegBuild.cmake b/cmake/ffmpeg/ConfigureFFmpegBuild.cmake deleted file mode 100644 index 5d8fb2e0..00000000 --- a/cmake/ffmpeg/ConfigureFFmpegBuild.cmake +++ /dev/null @@ -1,199 +0,0 @@ -cmake_minimum_required (VERSION 3.15 FATAL_ERROR) - -include_guard (GLOBAL) - -if (APPLE AND NOT IOS) - include ("${CMAKE_CURRENT_LIST_DIR}/FFmpegMacBuild.cmake") -endif() - - -# - -# Runs FFmpeg's configure script (at CMake configure time) -function (foleys_preconfigure_ffmpeg_build) - - set (options "") - set (oneValueArgs OUTPUT_DIR SOURCE_DIR EXTRA_ARGS C_FLAGS LD_FLAGS) - set (multiValueArgs "") - - cmake_parse_arguments (FOLEYS_ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - if (NOT FOLEYS_ARG_OUTPUT_DIR) - message (FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} called without required argument OUTPUT_DIR!") - endif() - - if (NOT FOLEYS_ARG_SOURCE_DIR) - message (FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} called without required argument SOURCE_DIR!") - endif() - - set (CONFIGURE_COMMAND - "./configure - --disable-static - --disable-doc - --disable-asm - --enable-shared - --enable-protocol=file - --shlibdir=${FOLEYS_ARG_OUTPUT_DIR} - --libdir=${FOLEYS_ARG_OUTPUT_DIR} - --incdir=${FOLEYS_ARG_OUTPUT_DIR}/include - --prefix=${FOLEYS_ARG_OUTPUT_DIR}") - - if (FOLEYS_ARG_EXTRA_ARGS) - set (CONFIGURE_COMMAND "${CONFIGURE_COMMAND} ${FOLEYS_ARG_EXTRA_ARGS}") - endif() - - if (FOLEYS_ARG_C_FLAGS) - set (CONFIGURE_COMMAND "${CONFIGURE_COMMAND} --extra-cflags=${FOLEYS_ARG_C_FLAGS}") - endif() - - if (FOLEYS_ARG_LD_FLAGS) - set (CONFIGURE_COMMAND "${CONFIGURE_COMMAND} --extra-ldflags=${FOLEYS_ARG_LD_FLAGS}") - endif() - - if (CMAKE_SYSROOT) - set (CONFIGURE_COMMAND "${CONFIGURE_COMMAND} --sysroot=${CMAKE_SYSROOT}") - endif() - - if (IOS OR ANDROID) - set (CONFIGURE_COMMAND - "${CONFIGURE_COMMAND} - --enable-cross-compile - --disable-programs - --enable-pic" - ) - - if (IOS) - set (CONFIGURE_COMMAND "${CONFIGURE_COMMAND} --target-os=darwin") - elseif (ANDROID) - set (CONFIGURE_COMMAND "${CONFIGURE_COMMAND} --target-os=android") - endif() - endif() - - separate_arguments (ffmpeg_config_command UNIX_COMMAND "${CONFIGURE_COMMAND}") - - if (NOT FFmpeg_FIND_QUIETLY) - set (cmd_echo_flag COMMAND_ECHO STDOUT) - endif() - - execute_process (COMMAND ${ffmpeg_config_command} - WORKING_DIRECTORY "${FOLEYS_ARG_SOURCE_DIR}" - ${cmd_echo_flag} - COMMAND_ERROR_IS_FATAL ANY) - -endfunction() - -# - -# Creates targets that execute the FFmpeg build and can be linked to from elsewhere in CMake -# BUILD_TARGET - name used for the actual underlying custom command target that executes the FFmpeg build -function (foleys_create_ffmpeg_build_target) - - set (options "") - set (oneValueArgs BUILD_TARGET SOURCE_DIR OUTPUT_DIR) - set (multiValueArgs "") - - cmake_parse_arguments (FOLEYS_ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - if (NOT FOLEYS_ARG_BUILD_TARGET) - message (FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} called without required argument BUILD_TARGET!") - endif() - - if (NOT FOLEYS_ARG_SOURCE_DIR) - message (FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} called without required argument SOURCE_DIR!") - endif() - - if (NOT FOLEYS_ARG_OUTPUT_DIR) - message (FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} called without required argument OUTPUT_DIR!") - endif() - - # - - function (foleys_make_lib_filename libname filename_out) - - set (filename "") - - if (CMAKE_SHARED_LIBRARY_PREFIX) - set (filename "${CMAKE_SHARED_LIBRARY_PREFIX}") - endif() - - set (filename "${filename}${libname}") - - if (CMAKE_SHARED_LIBRARY_SUFFIX) - set (filename "${filename}${CMAKE_SHARED_LIBRARY_SUFFIX}") - endif() - - set (${filename_out} "${filename}" PARENT_SCOPE) - - endfunction() - - # - - # the target should only already exist if this is a Mac universal binary build... - if (NOT TARGET ffmpeg) - add_library (ffmpeg INTERFACE) - endif() - - set (ffmpeg_libs_output_files "") - - foreach (libname ${FFMPEG_LIBS}) - foleys_make_lib_filename ("${libname}" libfilename) - - list (APPEND ffmpeg_libs_output_files "${FOLEYS_ARG_OUTPUT_DIR}/${libfilename}") - - target_link_libraries (ffmpeg INTERFACE "${FOLEYS_ARG_OUTPUT_DIR}/${libfilename}") - endforeach() - - # - - add_custom_target ("${FOLEYS_ARG_BUILD_TARGET}" - COMMAND "${FFMPEG_MAKE_EXECUTABLE}" -j4 - WORKING_DIRECTORY "${FOLEYS_ARG_SOURCE_DIR}" - COMMENT "Building FFmpeg..." - VERBATIM USES_TERMINAL) - - add_custom_command (TARGET "${FOLEYS_ARG_BUILD_TARGET}" - POST_BUILD - COMMAND "${FFMPEG_MAKE_EXECUTABLE}" install - BYPRODUCTS "${ffmpeg_libs_output_files}" - WORKING_DIRECTORY "${FOLEYS_ARG_SOURCE_DIR}" - VERBATIM USES_TERMINAL) - - add_dependencies (ffmpeg "${FOLEYS_ARG_BUILD_TARGET}") - -endfunction() - -# - -function (foleys_configure_ffmpeg_build) - - set (options "") - set (oneValueArgs SOURCE_DIR OUTPUT_DIR) - set (multiValueArgs "") - - cmake_parse_arguments (FOLEYS_ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - if (NOT FOLEYS_ARG_SOURCE_DIR) - message (FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} called without required argument SOURCE_DIR!") - endif() - - if (NOT FOLEYS_ARG_OUTPUT_DIR) - set (FOLEYS_ARG_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/ffmpeg") - endif() - - if (APPLE AND NOT IOS) - foleys_configure_ffmpeg_macos_universal_binary_build (SOURCE_DIR "${FOLEYS_ARG_SOURCE_DIR}" - OUTPUT_DIR "${FOLEYS_ARG_OUTPUT_DIR}") - else() - message (STATUS "Configuring FFmpeg build...") - - foleys_preconfigure_ffmpeg_build (SOURCE_DIR "${FOLEYS_ARG_SOURCE_DIR}" - OUTPUT_DIR "${FOLEYS_ARG_OUTPUT_DIR}") - - foleys_create_ffmpeg_build_target (SOURCE_DIR "${FOLEYS_ARG_SOURCE_DIR}" - OUTPUT_DIR "${FOLEYS_ARG_OUTPUT_DIR}" - BUILD_TARGET ffmpeg_build) - endif() - - target_include_directories (ffmpeg INTERFACE "${FOLEYS_ARG_OUTPUT_DIR}/include") - -endfunction() diff --git a/cmake/ffmpeg/FFmpegMacBuild.cmake b/cmake/ffmpeg/FFmpegMacBuild.cmake deleted file mode 100644 index 220ad8fa..00000000 --- a/cmake/ffmpeg/FFmpegMacBuild.cmake +++ /dev/null @@ -1,122 +0,0 @@ -cmake_minimum_required (VERSION 3.15 FATAL_ERROR) - -include_guard (GLOBAL) - -# - -find_program (YASM yasm) -find_program (LIPO lipo) - -if (NOT YASM OR NOT LIPO) # install yasm and/or lipo via Homebrew - - if (NOT FFmpeg_FIND_QUIETLY) - message (STATUS "Installing YASM via Homebrew...") - set (cmd_echo_flag COMMAND_ECHO STDOUT) - endif() - - find_program (HOMEBREW brew) - - if (NOT HOMEBREW) - unset (CACHE{HOMEBREW}) - - find_program (BASH bash) - - if (NOT BASH) - message (FATAL_ERROR "bash is required for installing Homebrew, and cannot be found!") - endif() - - if (NOT FFmpeg_FIND_QUIETLY) - message (STATUS "Installing Homebrew...") - endif() - - execute_process (COMMAND "${BASH}" "${CMAKE_CURRENT_LIST_DIR}/mac_install_homebrew.sh" - ${cmd_echo_flag} - COMMAND_ERROR_IS_FATAL ANY) - - find_program (HOMEBREW brew) - - if (NOT HOMEBREW) - message (FATAL_ERROR "Error installing Homebrew!") - endif() - endif() - - execute_process (COMMAND "${HOMEBREW}" install yasm lipo - ${cmd_echo_flag} - COMMAND_ERROR_IS_FATAL ANY) -endif() - -# - -function (foleys_configure_ffmpeg_macos_universal_binary_build) - - set (options "") - set (oneValueArgs SOURCE_DIR OUTPUT_DIR) - set (multiValueArgs "") - - cmake_parse_arguments (FOLEYS_ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - if (NOT FOLEYS_ARG_SOURCE_DIR) - message (FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} called without required argument SOURCE_DIR!") - endif() - - if (NOT FOLEYS_ARG_OUTPUT_DIR) - message (FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} called without required argument OUTPUT_DIR!") - endif() - - set (FFMPEG_ARCHITECTURES "x86_64;arm64") - - foreach (arch ${FFMPEG_ARCHITECTURES}) - - if (NOT FFmpeg_FIND_QUIETLY) - message (STATUS "Configuring FFmpeg build for arch ${arch}...") - endif() - - set (sourceDir "${CMAKE_CURRENT_BINARY_DIR}/ffmpeg_arch_sources/${arch}/${FFMPEG_NAME}") - - # each arch needs its own copy of the source tree ¯\_(ツ)_/¯ - file (COPY "${FOLEYS_ARG_SOURCE_DIR}" - DESTINATION "${sourceDir}/.." # silly cmake adds an extra nested directory when copying - USE_SOURCE_PERMISSIONS - FOLLOW_SYMLINK_CHAIN) - - set (outputDir "${FOLEYS_ARG_OUTPUT_DIR}/${arch}") - - foleys_preconfigure_ffmpeg_build (SOURCE_DIR "${sourceDir}" - OUTPUT_DIR "${outputDir}" - EXTRA_ARGS "--arch=${arch} --cc=clang --cxx=clang++") - - foleys_create_ffmpeg_build_target (SOURCE_DIR "${sourceDir}" - OUTPUT_DIR "${outputDir}" - BUILD_TARGET "ffmpeg_build_${arch}") - - set_target_properties (ffmpeg_build_x86_64 PROPERTIES OSX_ARCHITECTURES ${arch}) - endforeach() - - # foreach(ffmpeg_lib ${FFMPEG_LIBS}) - - # set (libFilename "lib${ffmpeg_lib}.dylib") - - # set (output_file "${FOLEYS_ARG_OUTPUT_DIR}/universal/${libFilename}") - - # add_custom_target (ffmpeg_${ffmpeg_lib}_lipo - # COMMAND lipo -create "${FOLEYS_ARG_OUTPUT_DIR}/x86_64/${libFilename}" "${FOLEYS_ARG_OUTPUT_DIR}/arm64/${libFilename}" -output "${output_file}" - # BYPRODUCTS "${output_file}" - # VERBATIM USES_TERMINAL - # COMMENT "FFmpeg - running lipo on ${ffmpeg_lib}...") - - # add_dependencies (ffmpeg_${ffmpeg_lib}_lipo ffmpeg_build_x86_64) - # add_dependencies (ffmpeg_${ffmpeg_lib}_lipo ffmpeg_build_arm64) - - # add_dependencies (foleys_ffmpeg ffmpeg_${ffmpeg_lib}_lipo) - - # target_link_libraries (foleys_ffmpeg INTERFACE "${output_file}") - # endforeach() - - # Need to manually copy headers... - file (GLOB libs ${FOLEYS_ARG_SOURCE_DIR}/lib*) - - file (COPY ${libs} "${FOLEYS_ARG_SOURCE_DIR}/config.h" "${FOLEYS_ARG_SOURCE_DIR}/compat" - DESTINATION "${FOLEYS_ARG_OUTPUT_DIR}/include" - FILES_MATCHING PATTERN *.h) - -endfunction() diff --git a/cmake/ffmpeg/FindInstalledFFmpeg.cmake b/cmake/ffmpeg/FindInstalledFFmpeg.cmake deleted file mode 100644 index b2f699ee..00000000 --- a/cmake/ffmpeg/FindInstalledFFmpeg.cmake +++ /dev/null @@ -1,23 +0,0 @@ -cmake_minimum_required (VERSION 3.15 FATAL_ERROR) - -include_guard (GLOBAL) - -find_package (PkgConfig) - -if (NOT PkgConfig_FOUND) - return() -endif() - -list (TRANSFORM FFMPEG_LIBS - PREPEND lib - OUTPUT_VARIABLE libav_libs) - -pkg_check_modules (LIBAV IMPORTED_TARGET ${libav_libs}) - -if (NOT LIBAV_FOUND) - return() -endif() - -add_library (ffmpeg INTERFACE) - -target_link_libraries (ffmpeg INTERFACE PkgConfig::LIBAV) diff --git a/cmake/ffmpeg/mac_install_homebrew.sh b/cmake/ffmpeg/mac_install_homebrew.sh deleted file mode 100644 index 6760b92a..00000000 --- a/cmake/ffmpeg/mac_install_homebrew.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -set -euo pipefail - -/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - -exit 0 diff --git a/foleys_video_engine/foleys_video_engine.cpp b/foleys_video_engine.cpp similarity index 100% rename from foleys_video_engine/foleys_video_engine.cpp rename to foleys_video_engine.cpp diff --git a/foleys_video_engine/foleys_video_engine.h b/foleys_video_engine.h similarity index 100% rename from foleys_video_engine/foleys_video_engine.h rename to foleys_video_engine.h From 7bb79943bb85783de5dc5b273cc5c1498123d9b0 Mon Sep 17 00:00:00 2001 From: Dylan Marcus Date: Mon, 11 Jul 2022 16:42:46 -0400 Subject: [PATCH 29/44] small improvements to script for safer usage --- scripts/build-ffmpeg-osx.sh | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/scripts/build-ffmpeg-osx.sh b/scripts/build-ffmpeg-osx.sh index aac09c8d..2a4d35f5 100755 --- a/scripts/build-ffmpeg-osx.sh +++ b/scripts/build-ffmpeg-osx.sh @@ -15,16 +15,17 @@ then fi echo 'Removing old tap' -brew uninstall ffmpeg@4.3 -brew untap $USER/ffmpeg-4-3 +brew uninstall ffmpeg@4.4 +brew untap $USER/ffmpeg-4-4 -echo 'Installing FFmpeg 4.3.2_4' -# TODO: Add error handling for this install (will fail if already exists) -brew tap-new $USER/ffmpeg-4-3 -brew extract --version=4.3 ffmpeg $USER/ffmpeg-4-3 -brew install $USER/ffmpeg-4-3/ffmpeg@4.3 +echo 'Installing FFmpeg 4.4' +brew tap-new $USER/ffmpeg-4-4 +brew extract --version=4.4 ffmpeg $USER/ffmpeg-4-4 +brew install $USER/ffmpeg-4-4/ffmpeg@4.4 +# unlinking this flavor of ffmpeg so its not used elsewhere and is just being used to download and locally compile this specific version +brew unlink $USER/ffmpeg-4-4/ffmpeg@4.4 echo 'Copying include directory to module' -rsync -rl /usr/local/Cellar/ffmpeg@4.3/4.3.2_4/include/ ../ffmpeg/include +rsync -rl /usr/local/Cellar/ffmpeg@4.4/*/include/ ../ffmpeg/include echo 'Copying macOS libs to module' -rsync -rl /usr/local/Cellar/ffmpeg@4.3/4.3.2_4/lib/ ../libs/MacOSX/x86_64 \ No newline at end of file +rsync -rl /usr/local/Cellar/ffmpeg@4.4/*/lib/ ../libs/MacOSX/x86_64 \ No newline at end of file From 015bf1df8370702493c9f99c4935591bd1443df3 Mon Sep 17 00:00:00 2001 From: Ben Vining Date: Tue, 12 Jul 2022 21:23:34 -0500 Subject: [PATCH 30/44] fix: updating JUCE hash to latest JUCE6 commit --- CMakeLists.txt | 24 ++++++++++++------------ cmake/FindJUCE.cmake | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bcbb0dd9..eff913e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,25 +1,25 @@ cmake_minimum_required (VERSION 3.15 FATAL_ERROR) project (FoleysVideoEngine - VERSION 0.2.0 - LANGUAGES CXX OBJC C - DESCRIPTION "A video engine module for JUCE" + VERSION 0.2.0 + LANGUAGES CXX OBJC C + DESCRIPTION "A video engine module for JUCE" HOMEPAGE_URL "https://foleysfinest.com/foleys_video_engine/") list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") -find_package (FFmpeg REQUIRED) +find_package (FFmpeg MODULE REQUIRED) find_package (JUCE 6 REQUIRED) juce_add_module ("${CMAKE_CURRENT_LIST_DIR}" - ALIAS_NAMESPACE Foleys) + ALIAS_NAMESPACE Foleys) target_compile_definitions (foleys_video_engine INTERFACE - JUCE_MODAL_LOOPS_PERMITTED=1 - JUCE_STRICT_REFCOUNTEDPOINTER=1 - JUCE_PLUGINHOST_AU=1 - JUCE_PLUGINHOST_VST3=1 - JUCE_PLUGINHOST_LADSPA=1) + JUCE_MODAL_LOOPS_PERMITTED=1 + JUCE_STRICT_REFCOUNTEDPOINTER=1 + JUCE_PLUGINHOST_AU=1 + JUCE_PLUGINHOST_VST3=1 + JUCE_PLUGINHOST_LADSPA=1) target_link_libraries (foleys_video_engine INTERFACE ffmpeg::ffmpeg) @@ -42,8 +42,8 @@ install (DIRECTORY "${CMAKE_CURRENT_LIST_DIR}" include (CPackComponent) cpack_add_component (foleys_video_engine - GROUP Foleys - INSTALL_TYPES Developer) + GROUP Foleys + INSTALL_TYPES Developer) include (CMakePackageConfigHelpers) diff --git a/cmake/FindJUCE.cmake b/cmake/FindJUCE.cmake index 5875405b..6941f94f 100644 --- a/cmake/FindJUCE.cmake +++ b/cmake/FindJUCE.cmake @@ -13,7 +13,7 @@ set_package_properties ("${CMAKE_FIND_PACKAGE_NAME}" FetchContent_Declare (JUCE GIT_REPOSITORY https://github.com/juce-framework/JUCE.git - GIT_TAG origin/master) + GIT_TAG 37d6161da2aa94d1530cef860b1642e1e4d9e08d) # most recent JUCE 6 commit set (JUCE_BUILD_EXAMPLES OFF) set (JUCE_BUILD_EXTRAS OFF) From 90152cd6e85a4a1ee5c944e3cedd781e85954b4b Mon Sep 17 00:00:00 2001 From: Ben Vining Date: Thu, 14 Jul 2022 03:49:07 -0500 Subject: [PATCH 31/44] refactor: updating fetch logic for ffmpeg --- CMakeLists.txt | 3 ++- README.md | 19 +++++++++++++++++++ cmake/FindFFmpeg.cmake | 8 ++++---- cmake/FindJUCE.cmake | 6 ++++-- cmake/config.cmake | 2 +- 5 files changed, 30 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eff913e9..929272b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,8 @@ project (FoleysVideoEngine list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") -find_package (FFmpeg MODULE REQUIRED) +find_package (ffmpeg REQUIRED) + find_package (JUCE 6 REQUIRED) juce_add_module ("${CMAKE_CURRENT_LIST_DIR}" diff --git a/README.md b/README.md index 2f5563f9..d1fe82d7 100644 --- a/README.md +++ b/README.md @@ -13,11 +13,30 @@ Setup To use the video engine, add this module via Projucer or CMake to your JUCE project. +In CMake, this module can be added like this: +```cmake +add_subdirectory (foleys_video_engine) +``` +or like this: +```cmake +find_package (foleys_video_engine) +``` +This repo's CMake scripts add JUCE by calling `find_package()`. Foleys video engine requires JUCE version 6, and may +be incompatible with JUCE version 7. + +You can override the path to JUCE on the command line like so: +```shell +cmake -B Builds -D FETCHCONTENT_SOURCE_DIR_JUCE= +``` + If you are using CMake and the CPM.cmake package manager to add this repository, be aware that: - JUCE's module system expects the root folder of a module to have the same name as the module - By default, CPM.cmake will download the source code into a nested folder named with the version, for example `foleys_video_engine//` This can cause the JUCE module system to get confused. If you are using CPM.cmake, we recommend you set the `CPM_USE_NAMED_CACHE_DIRECTORIES` CMake or environment variable to `ON` to prevent this issue. +foleys_video_engine requires [ffmpeg](https://www.ffmpeg.org/), which is built in CMake using [this repository](https://github.com/ffAudio/FFmpegBuild). The CMake configuration should "just work" out of the box, you don't need +to download or install anything. + Features -------- diff --git a/cmake/FindFFmpeg.cmake b/cmake/FindFFmpeg.cmake index b55373c8..c0435a39 100644 --- a/cmake/FindFFmpeg.cmake +++ b/cmake/FindFFmpeg.cmake @@ -11,14 +11,14 @@ set_package_properties ("${CMAKE_FIND_PACKAGE_NAME}" URL "https://www.ffmpeg.org/" DESCRIPTION "Audio and video codecs") -FetchContent_Declare (FFmpeg +FetchContent_Declare (ffmpeg GIT_REPOSITORY "https://github.com/ffAudio/FFmpegBuild.git" GIT_TAG origin/main) -FetchContent_MakeAvailable (FFmpeg) +FetchContent_MakeAvailable (ffmpeg) find_package_message ("${CMAKE_FIND_PACKAGE_NAME}" - "FFmpeg package found -- Sources downloaded" - "FFmpeg (GitHub)") + "ffmpeg package found -- Sources downloaded" + "ffmpeg (GitHub)") set (${CMAKE_FIND_PACKAGE_NAME}_FOUND TRUE) diff --git a/cmake/FindJUCE.cmake b/cmake/FindJUCE.cmake index 6941f94f..0f14ec4e 100644 --- a/cmake/FindJUCE.cmake +++ b/cmake/FindJUCE.cmake @@ -11,9 +11,11 @@ set_package_properties ("${CMAKE_FIND_PACKAGE_NAME}" URL "https://juce.com/" DESCRIPTION "Cross platform framework for plugin and app development") +set (juce_git_hash 37d6161da2aa94d1530cef860b1642e1e4d9e08d) # most recent JUCE 6 commit + FetchContent_Declare (JUCE GIT_REPOSITORY https://github.com/juce-framework/JUCE.git - GIT_TAG 37d6161da2aa94d1530cef860b1642e1e4d9e08d) # most recent JUCE 6 commit + GIT_TAG "${juce_git_hash}") set (JUCE_BUILD_EXAMPLES OFF) set (JUCE_BUILD_EXTRAS OFF) @@ -23,6 +25,6 @@ FetchContent_MakeAvailable (JUCE) find_package_message ("${CMAKE_FIND_PACKAGE_NAME}" "JUCE package found -- Sources downloaded" - "JUCE (GitHub)") + "JUCE (GitHub) [${juce_git_hash}]") set (${CMAKE_FIND_PACKAGE_NAME}_FOUND TRUE) diff --git a/cmake/config.cmake b/cmake/config.cmake index eeefbcbb..3d270550 100644 --- a/cmake/config.cmake +++ b/cmake/config.cmake @@ -31,7 +31,7 @@ list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") include (CMakeFindDependencyMacro) find_dependency (JUCE 6) -find_dependency (FFmpeg) +find_dependency (ffmpeg) juce_add_module ("${CMAKE_CURRENT_LIST_DIR}" ALIAS_NAMESPACE Foleys) From 072101856d715b3337a30f18cbd55c2a67cb1068 Mon Sep 17 00:00:00 2001 From: Ben Vining Date: Thu, 14 Jul 2022 04:06:02 -0500 Subject: [PATCH 32/44] fix: renaming ffmpeg find module --- cmake/{FindFFmpeg.cmake => Findffmpeg.cmake} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename cmake/{FindFFmpeg.cmake => Findffmpeg.cmake} (100%) diff --git a/cmake/FindFFmpeg.cmake b/cmake/Findffmpeg.cmake similarity index 100% rename from cmake/FindFFmpeg.cmake rename to cmake/Findffmpeg.cmake From 61972a60a24ecaa40102d9a184afcda7e50e46fd Mon Sep 17 00:00:00 2001 From: Dylan Marcus Date: Tue, 30 Aug 2022 12:12:53 +0200 Subject: [PATCH 33/44] pathing error --- scripts/build-ffmpeg-osx.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/build-ffmpeg-osx.sh b/scripts/build-ffmpeg-osx.sh index 2a4d35f5..e4a66e18 100755 --- a/scripts/build-ffmpeg-osx.sh +++ b/scripts/build-ffmpeg-osx.sh @@ -26,6 +26,6 @@ brew install $USER/ffmpeg-4-4/ffmpeg@4.4 brew unlink $USER/ffmpeg-4-4/ffmpeg@4.4 echo 'Copying include directory to module' -rsync -rl /usr/local/Cellar/ffmpeg@4.4/*/include/ ../ffmpeg/include +rsync -rl /usr/local/Cellar/ffmpeg@4.4/*/include/ ffmpeg/include echo 'Copying macOS libs to module' -rsync -rl /usr/local/Cellar/ffmpeg@4.4/*/lib/ ../libs/MacOSX/x86_64 \ No newline at end of file +rsync -rl /usr/local/Cellar/ffmpeg@4.4/*/lib/ libs/MacOSX/x86_64 \ No newline at end of file From c3a181c23d3a55b6cb712342a8468949d6e929b4 Mon Sep 17 00:00:00 2001 From: Dylan Marcus Date: Thu, 16 Mar 2023 16:14:56 -0400 Subject: [PATCH 34/44] changed cmake behavior to not require juce if included as a module --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 929272b8..f5771659 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,10 @@ list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") find_package (ffmpeg REQUIRED) -find_package (JUCE 6 REQUIRED) +if(PROJECT_IS_TOP_LEVEL) + message(STATUS "No parent project found, requiring JUCE") + find_package (JUCE 6 REQUIRED) +endif() juce_add_module ("${CMAKE_CURRENT_LIST_DIR}" ALIAS_NAMESPACE Foleys) From e8f8d9224cabad7aed24c8fb8243f377fdbe3cdf Mon Sep 17 00:00:00 2001 From: Dylan Marcus Date: Mon, 20 Mar 2023 21:17:30 -0400 Subject: [PATCH 35/44] more protections for usage as module, pointed the ffmpeg cmake to custom --- cmake/Findffmpeg.cmake | 2 +- cmake/config.cmake | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cmake/Findffmpeg.cmake b/cmake/Findffmpeg.cmake index c0435a39..090ac3e1 100644 --- a/cmake/Findffmpeg.cmake +++ b/cmake/Findffmpeg.cmake @@ -12,7 +12,7 @@ set_package_properties ("${CMAKE_FIND_PACKAGE_NAME}" DESCRIPTION "Audio and video codecs") FetchContent_Declare (ffmpeg - GIT_REPOSITORY "https://github.com/ffAudio/FFmpegBuild.git" + GIT_REPOSITORY "https://github.com/mach1studios/FFmpegBuild.git" GIT_TAG origin/main) FetchContent_MakeAvailable (ffmpeg) diff --git a/cmake/config.cmake b/cmake/config.cmake index 3d270550..b276eb95 100644 --- a/cmake/config.cmake +++ b/cmake/config.cmake @@ -30,7 +30,10 @@ list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") include (CMakeFindDependencyMacro) +if(PROJECT_IS_TOP_LEVEL) + message(STATUS "No parent project found, requiring JUCE") find_dependency (JUCE 6) +endif() find_dependency (ffmpeg) juce_add_module ("${CMAKE_CURRENT_LIST_DIR}" From faea1e3cb07c718c490b96a8373e7920cf0564ea Mon Sep 17 00:00:00 2001 From: Dylan Marcus Date: Tue, 21 Mar 2023 16:22:28 -0400 Subject: [PATCH 36/44] remove some dead files --- ffmpeg/include/.gitkeep | 0 libs/MacOSX/x86_64/.gitkeep | 0 libs/VisualStudio2019/x64/MD/.gitkeep | 0 libs/VisualStudio2019/x64/MDd/.gitkeep | 0 4 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 ffmpeg/include/.gitkeep delete mode 100644 libs/MacOSX/x86_64/.gitkeep delete mode 100644 libs/VisualStudio2019/x64/MD/.gitkeep delete mode 100644 libs/VisualStudio2019/x64/MDd/.gitkeep diff --git a/ffmpeg/include/.gitkeep b/ffmpeg/include/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/libs/MacOSX/x86_64/.gitkeep b/libs/MacOSX/x86_64/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/libs/VisualStudio2019/x64/MD/.gitkeep b/libs/VisualStudio2019/x64/MD/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/libs/VisualStudio2019/x64/MDd/.gitkeep b/libs/VisualStudio2019/x64/MDd/.gitkeep deleted file mode 100644 index e69de29b..00000000 From 5b4b1d97837f160da5affadf18b932b7b04e6a04 Mon Sep 17 00:00:00 2001 From: Dylan Marcus Date: Wed, 22 Mar 2023 12:08:29 -0400 Subject: [PATCH 37/44] removed conflicting linking declarations --- foleys_video_engine.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/foleys_video_engine.h b/foleys_video_engine.h index d7543fc7..b00fb2db 100644 --- a/foleys_video_engine.h +++ b/foleys_video_engine.h @@ -27,10 +27,6 @@ mux audio into an existing video dependencies: juce_audio_basics juce_audio_devices juce_audio_formats juce_gui_basics juce_graphics juce_core juce_audio_utils juce_audio_processors minimumCppStandard: 17 - searchpaths: ffmpeg/include - windowsLibs: avformat,avutil,avcodec,swscale,swresample - OSXLibs: avformat,avutil,avcodec,swscale,swresample,avresample - website: https://foleysfinest.com/ END_JUCE_MODULE_DECLARATION From d2593cf7cbf424d7f2325968d3e0b2ce800bd731 Mon Sep 17 00:00:00 2001 From: andorxornot Date: Fri, 19 May 2023 02:06:05 +0400 Subject: [PATCH 38/44] fix: JUCE7, last ffmpeg --- Processing/foleys_ProcessorController.cpp | 13 ++++++++++++- ReadWrite/FFmpeg/foleys_FFmpegHelpers.h | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Processing/foleys_ProcessorController.cpp b/Processing/foleys_ProcessorController.cpp index 8b0d5c2a..c3d29d9c 100644 --- a/Processing/foleys_ProcessorController.cpp +++ b/Processing/foleys_ProcessorController.cpp @@ -52,13 +52,24 @@ struct AudioProcessorAdapter : public ProcessorController::ProcessorAdapter public: PlayHead() = default; - bool getCurrentPosition (juce::AudioPlayHead::CurrentPositionInfo &result) override +#if JUCE_VERSION > 0x70000 + juce::Optional getPosition() const override + { + PositionInfo result; + result.setTimeInSamples(timeInSamples); + result.setTimeInSeconds(timeInSeconds); + result.setFrameRate(frameRate); + return juce::Optional(result); + } +#else + bool getCurrentPosition (juce::AudioPlayHead::CurrentPositionInfo &result) override { result.timeInSamples = timeInSamples; result.timeInSeconds = timeInSeconds; result.frameRate = frameRate; return true; } +#endif bool canControlTransport() override { diff --git a/ReadWrite/FFmpeg/foleys_FFmpegHelpers.h b/ReadWrite/FFmpeg/foleys_FFmpegHelpers.h index 58616865..4316af9b 100644 --- a/ReadWrite/FFmpeg/foleys_FFmpegHelpers.h +++ b/ReadWrite/FFmpeg/foleys_FFmpegHelpers.h @@ -29,10 +29,12 @@ #pragma clang diagnostic ignored "-Wfloat-conversion" #endif + #ifdef __cplusplus extern "C" { #endif +#include #include #include #include From b78bf26ebb452b32594745f1ebe9eeda12adad9b Mon Sep 17 00:00:00 2001 From: andorxornot Date: Fri, 19 May 2023 02:46:47 +0400 Subject: [PATCH 39/44] revert libs path --- foleys_video_engine.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/foleys_video_engine.h b/foleys_video_engine.h index b00fb2db..f5f466e1 100644 --- a/foleys_video_engine.h +++ b/foleys_video_engine.h @@ -27,6 +27,8 @@ mux audio into an existing video dependencies: juce_audio_basics juce_audio_devices juce_audio_formats juce_gui_basics juce_graphics juce_core juce_audio_utils juce_audio_processors minimumCppStandard: 17 + windowsLibs: avformat,avutil,avcodec,swscale,swresample + OSXLibs: avformat,avutil,avcodec,swscale,swresample,avresample website: https://foleysfinest.com/ END_JUCE_MODULE_DECLARATION From a2299b8bcfc7ad45286cfe3467682e7609d3d67f Mon Sep 17 00:00:00 2001 From: Dylan Marcus Date: Fri, 19 May 2023 18:18:57 -0400 Subject: [PATCH 40/44] fixed for linking with submodules --- foleys_video_engine.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/foleys_video_engine.h b/foleys_video_engine.h index f5f466e1..01b4c7b2 100644 --- a/foleys_video_engine.h +++ b/foleys_video_engine.h @@ -27,8 +27,9 @@ mux audio into an existing video dependencies: juce_audio_basics juce_audio_devices juce_audio_formats juce_gui_basics juce_graphics juce_core juce_audio_utils juce_audio_processors minimumCppStandard: 17 + searchpaths: ffmpeg/include windowsLibs: avformat,avutil,avcodec,swscale,swresample - OSXLibs: avformat,avutil,avcodec,swscale,swresample,avresample + OSXLibs: avformat,avutil,avcodec,swscale,swresample website: https://foleysfinest.com/ END_JUCE_MODULE_DECLARATION From 16e7f0d076bbf18b75494d9449e569f8f233ab1e Mon Sep 17 00:00:00 2001 From: Dylan Marcus Date: Thu, 25 May 2023 11:56:56 -0400 Subject: [PATCH 41/44] added a check for find_package --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f5771659..a4ddfea1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,9 @@ project (FoleysVideoEngine list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") -find_package (ffmpeg REQUIRED) +if(NOT ffmpeg_FOUND) + find_package (ffmpeg REQUIRED) +endif() if(PROJECT_IS_TOP_LEVEL) message(STATUS "No parent project found, requiring JUCE") From cd24a2d1ef3bdc555473d5f3d6643b7e671cb222 Mon Sep 17 00:00:00 2001 From: Dylan Marcus Date: Tue, 24 Oct 2023 15:03:07 -0400 Subject: [PATCH 42/44] added to ffmpeg cmake process to make it work crossplatform --- CMakeLists.txt | 37 ++++++++----- cmake/Findffmpeg.cmake | 122 +++++++++++++++++++++++++++++++++++++---- 2 files changed, 133 insertions(+), 26 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a4ddfea1..8877c34a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,18 @@ cmake_minimum_required (VERSION 3.15 FATAL_ERROR) -project (FoleysVideoEngine - VERSION 0.2.0 - LANGUAGES CXX OBJC C - DESCRIPTION "A video engine module for JUCE" - HOMEPAGE_URL "https://foleysfinest.com/foleys_video_engine/") +if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + project (FoleysVideoEngine + VERSION 0.2.0 + LANGUAGES CXX OBJC C + DESCRIPTION "A video engine module for JUCE" + HOMEPAGE_URL "https://foleysfinest.com/foleys_video_engine/") +else() + project (FoleysVideoEngine + VERSION 0.2.0 + LANGUAGES CXX C + DESCRIPTION "A video engine module for JUCE" + HOMEPAGE_URL "https://foleysfinest.com/foleys_video_engine/") +endif() list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") @@ -17,17 +25,16 @@ if(PROJECT_IS_TOP_LEVEL) find_package (JUCE 6 REQUIRED) endif() -juce_add_module ("${CMAKE_CURRENT_LIST_DIR}" - ALIAS_NAMESPACE Foleys) +juce_add_module ("${CMAKE_CURRENT_LIST_DIR}" ALIAS_NAMESPACE Foleys) target_compile_definitions (foleys_video_engine INTERFACE - JUCE_MODAL_LOOPS_PERMITTED=1 - JUCE_STRICT_REFCOUNTEDPOINTER=1 - JUCE_PLUGINHOST_AU=1 - JUCE_PLUGINHOST_VST3=1 - JUCE_PLUGINHOST_LADSPA=1) + JUCE_MODAL_LOOPS_PERMITTED=1 + JUCE_STRICT_REFCOUNTEDPOINTER=1 + JUCE_PLUGINHOST_AU=1 + JUCE_PLUGINHOST_VST3=1 + JUCE_PLUGINHOST_LADSPA=1) -target_link_libraries (foleys_video_engine INTERFACE ffmpeg::ffmpeg) +target_link_libraries (foleys_video_engine INTERFACE FFmpeg::FFmpeg) # @@ -48,8 +55,8 @@ install (DIRECTORY "${CMAKE_CURRENT_LIST_DIR}" include (CPackComponent) cpack_add_component (foleys_video_engine - GROUP Foleys - INSTALL_TYPES Developer) + GROUP Foleys + INSTALL_TYPES Developer) include (CMakePackageConfigHelpers) diff --git a/cmake/Findffmpeg.cmake b/cmake/Findffmpeg.cmake index 090ac3e1..a88e1a04 100644 --- a/cmake/Findffmpeg.cmake +++ b/cmake/Findffmpeg.cmake @@ -5,20 +5,120 @@ include_guard (GLOBAL) include (FetchContent) include (FeatureSummary) include (FindPackageMessage) +include(FindPackageHandleStandardArgs) -set_package_properties ("${CMAKE_FIND_PACKAGE_NAME}" - PROPERTIES - URL "https://www.ffmpeg.org/" - DESCRIPTION "Audio and video codecs") +if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + set_package_properties ("${CMAKE_FIND_PACKAGE_NAME}" + PROPERTIES + URL "https://www.ffmpeg.org/" + DESCRIPTION "Audio and video codecs") + FetchContent_Declare (ffmpeg + GIT_REPOSITORY "https://github.com/mach1studios/FFmpegBuild.git" + GIT_TAG origin/main) -FetchContent_Declare (ffmpeg - GIT_REPOSITORY "https://github.com/mach1studios/FFmpegBuild.git" - GIT_TAG origin/main) +elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Windows" AND ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64") + + set(BUILT_FFMPEG_RELEASE "ffmpeg-master-latest-win64-lgpl-shared.zip") + + if(NOT BUILT_FFMPEG_RELEASE) + message(FATAL_ERROR "Platform ${CMAKE_SYSTEM_PROCESSOR} on system ${CMAKE_SYSTEM_NAME} is not supported!") + endif() + + if (NOT "${PROJECT_BINARY_DIR}/.local" IN_LIST "${CMAKE_PREFIX_PATH}") + list(APPEND CMAKE_PREFIX_PATH "${PROJECT_BINARY_DIR}/.local") + endif() + + FetchContent_Declare(ffmpeg + URL "https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/${BUILT_FFMPEG_RELEASE}" + SOURCE_DIR "${PROJECT_BINARY_DIR}/.local" + ) + +elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + + if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "amd64") + set(BUILT_FFMPEG_RELEASE "ffmpeg-master-latest-linux64-lgpl-shared.tar.xz") + elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL aarch64) + set(BUILT_FFMPEG_RELEASE "ffmpeg-master-latest-linuxarm64-lgpl-shared.tar.xz") + endif() + + if(NOT BUILT_FFMPEG_RELEASE) + message(FATAL_ERROR "Platform ${CMAKE_SYSTEM_PROCESSOR} on system ${CMAKE_SYSTEM_NAME} is not supported!") + endif() + + if (NOT "${PROJECT_BINARY_DIR}/.local" IN_LIST "${CMAKE_PREFIX_PATH}") + list(APPEND CMAKE_PREFIX_PATH "${PROJECT_BINARY_DIR}/.local") + endif() + + FetchContent_Declare(ffmpeg + URL "https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/${BUILT_FFMPEG_RELEASE}" + SOURCE_DIR "${PROJECT_BINARY_DIR}/.local" + ) + +endif() FetchContent_MakeAvailable (ffmpeg) -find_package_message ("${CMAKE_FIND_PACKAGE_NAME}" - "ffmpeg package found -- Sources downloaded" - "ffmpeg (GitHub)") +if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + + find_package_message ("${CMAKE_FIND_PACKAGE_NAME}" + "ffmpeg package found -- Sources downloaded" + "ffmpeg (GitHub)") + + set (${CMAKE_FIND_PACKAGE_NAME}_FOUND TRUE) + +else() + +macro(find_component _component _header) + find_path(${_component}_INCLUDE_DIRS "${_header}" PATH_SUFFIXES ffmpeg) + find_library(${_component}_LIBRARY NAMES "${_component}" PATH_SUFFIXES ffmpeg) + + if (${_component}_LIBRARY AND ${_component}_INCLUDE_DIRS) + set(FFmpeg_${_component}_FOUND TRUE) + set(FFmpeg_LINK_LIBRARIES ${FFmpeg_LINK_LIBRARIES} ${${_component}_LIBRARY}) + list(APPEND FFmpeg_INCLUDE_DIRS ${${_component}_INCLUDE_DIRS}) + + if (NOT TARGET FFmpeg::${_component}) + add_library(FFmpeg_${_component} UNKNOWN IMPORTED) + set_target_properties(FFmpeg_${_component} PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${${_component}_INCLUDE_DIRS}" + IMPORTED_LOCATION "${${_component}_LIBRARY}" + ) + add_library(FFmpeg::${_component} ALIAS FFmpeg_${_component}) + endif () + endif () + + mark_as_advanced(${_component}_INCLUDE_DIRS) + mark_as_advanced(${_component}_LIBRARY) +endmacro() + +#------------------------------------------------------------------------------ + +# The default components +if (NOT FFmpeg_FIND_COMPONENTS) + set(FFmpeg_FIND_COMPONENTS avcodec avfilter avformat avdevice avutil swresample swscale) +endif () + +# Traverse the user-selected components of the package and find them +set(FFmpeg_INCLUDE_DIRS) +set(FFmpeg_LINK_LIBRARIES) +foreach(_component ${FFmpeg_FIND_COMPONENTS}) + find_component(${_component} lib${_component}/${_component}.h) +endforeach() +mark_as_advanced(FFmpeg_INCLUDE_DIRS) +mark_as_advanced(FFmpeg_LINK_LIBRARIES) + +# Handle findings +list(LENGTH FFmpeg_FIND_COMPONENTS FFmpeg_COMPONENTS_COUNT) +find_package_handle_standard_args(FFmpeg REQUIRED_VARS FFmpeg_COMPONENTS_COUNT HANDLE_COMPONENTS) + +# Publish targets if succeeded to find the FFmpeg package and the requested components +if (FFmpeg_FOUND AND NOT TARGET FFmpeg::FFmpeg) + add_library(FFmpeg INTERFACE) + set_target_properties(FFmpeg PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${FFmpeg_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${FFmpeg_LINK_LIBRARIES}" + ) + add_library(FFmpeg::FFmpeg ALIAS FFmpeg) +endif() -set (${CMAKE_FIND_PACKAGE_NAME}_FOUND TRUE) +endif() \ No newline at end of file From a0165de3fd8b7fc7f50602dc308c98fa96c422e5 Mon Sep 17 00:00:00 2001 From: Dylan Marcus Date: Thu, 26 Oct 2023 13:01:25 -0400 Subject: [PATCH 43/44] fixed windows compile issue with syntax --- Basics/foleys_VideoEngine.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Basics/foleys_VideoEngine.h b/Basics/foleys_VideoEngine.h index b8c9177f..597a39a5 100644 --- a/Basics/foleys_VideoEngine.h +++ b/Basics/foleys_VideoEngine.h @@ -133,7 +133,7 @@ class VideoEngine : private juce::Timer juce::OptionalScopedPointer undoManager { new juce::UndoManager(), true }; - juce::ThreadPool jobThreads { std::max (4, juce::SystemStats::getNumCpus()) }; + juce::ThreadPool jobThreads{ (std::max)(4, juce::SystemStats::getNumCpus()) }; std::vector> readingThreads; std::vector> releasePool; From 3f27ec806a28f21a87fa0d4719103989ac46b6bb Mon Sep 17 00:00:00 2001 From: Dylan Marcus Date: Thu, 26 Oct 2023 14:09:11 -0400 Subject: [PATCH 44/44] remove preset file --- CMakePresets.json | 97 ----------------------------------------------- 1 file changed, 97 deletions(-) delete mode 100644 CMakePresets.json diff --git a/CMakePresets.json b/CMakePresets.json deleted file mode 100644 index 4c3ea148..00000000 --- a/CMakePresets.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "buildPresets": [ - { - "cleanFirst": true, - "configuration": "Debug", - "configurePreset": "default", - "displayName": "The default build", - "jobs": 4, - "name": "default" - }, - { - "displayName": "Maintainer build", - "inherits": "default", - "name": "maintainer", - "verbose": true - } - ], - "cmakeMinimumRequired": { - "major": 3, - "minor": 15, - "patch": 0 - }, - "configurePresets": [ - { - "binaryDir": "${sourceDir}/Builds", - "displayName": "The default CMake configuration", - "name": "default", - "warnings": { - "unusedCli": false - } - }, - { - "displayName": "CMake configuration for development of foleys_video_engine", - "inherits": "default", - "name": "maintainer", - "warnings": { - "deprecated": true, - "dev": true, - "uninitialized": true - } - }, - { - "cacheVariables": { - "CMAKE_CXX_COMPILER": "g++-11", - "CMAKE_C_COMPILER": "gcc-11" - }, - "displayName": "Build with Ninja and GCC", - "generator": "Ninja Multi-Config", - "inherits": "maintainer", - "name": "ninja-gcc" - }, - { - "cacheVariables": { - "CMAKE_CXX_COMPILER": "clang++", - "CMAKE_C_COMPILER": "clang" - }, - "displayName": "Build with Ninja and Clang", - "generator": "Ninja Multi-Config", - "inherits": "maintainer", - "name": "ninja-clang" - }, - { - "cacheVariables": { - "CMAKE_SYSTEM_NAME": "iOS", - "CMAKE_XCODE_EFFECTIVE_PLATFORMS": "-iphoneos" - }, - "condition": { - "lhs": "${hostSystemName}", - "rhs": "Darwin", - "type": "equals" - }, - "displayName": "Configure cross-compiling for iOS", - "generator": "Xcode", - "inherits": "default", - "name": "iOS" - }, - { - "cacheVariables": { - "CMAKE_SYSTEM_NAME": "tvOS", - "CMAKE_XCODE_EFFECTIVE_PLATFORMS": "-appletvos" - }, - "displayName": "Configure cross-compiling for tvOS", - "inherits": "iOS", - "name": "tvOS" - }, - { - "cacheVariables": { - "CMAKE_SYSTEM_NAME": "watchOS", - "CMAKE_XCODE_EFFECTIVE_PLATFORMS": "-watchos" - }, - "displayName": "Configure cross-compiling for watchOS", - "inherits": "iOS", - "name": "watchOS" - } - ], - "version": 3 -} \ No newline at end of file