Fixes for protobuf/absl C++17 requirement

This commit is contained in:
John Maguire 2023-07-10 22:58:20 +01:00
parent 126da35fef
commit b74564a06f
14 changed files with 88 additions and 28 deletions

View File

@ -175,7 +175,7 @@ if(BUNDLE_PROJECTM_PRESETS)
configure_file( configure_file(
"${preset}" "${preset}"
"${CMAKE_BINARY_DIR}/clementine.app/Contents/Resources/projectm-presets/${PRESET_NAME}" "${CMAKE_BINARY_DIR}/clementine.app/Contents/Resources/projectm-presets/${PRESET_NAME}"
COPY_ONLY COPYONLY
) )
endforeach (preset) endforeach (preset)
else (APPLE) else (APPLE)

View File

@ -17,8 +17,11 @@
#include "Waveform.hpp" #include "Waveform.hpp"
#include <algorithm> #include <algorithm>
#include <functional>
#include "BeatDetect.hpp" #include "BeatDetect.hpp"
using std::placeholders::_1;
typedef float floatPair[2]; typedef float floatPair[2];
typedef float floatTriple[3]; typedef float floatTriple[3];
typedef float floatQuad[4]; typedef float floatQuad[4];
@ -65,8 +68,8 @@ void Waveform::Draw(RenderContext &context)
float mult= scaling*( spectrum ? 0.015f :1.0f); float mult= scaling*( spectrum ? 0.015f :1.0f);
std::transform(&value1[0],&value1[samples],&value1[0],std::bind2nd(std::multiplies<float>(),mult)); std::transform(&value1[0],&value1[samples],&value1[0],std::bind(std::multiplies<float>(),_1, mult));
std::transform(&value2[0],&value2[samples],&value2[0],std::bind2nd(std::multiplies<float>(),mult)); std::transform(&value2[0],&value2[samples],&value2[0],std::bind(std::multiplies<float>(),_1,mult));
WaveformContext waveContext(samples, context.beatDetect); WaveformContext waveContext(samples, context.beatDetect);

View File

@ -15,6 +15,7 @@
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include <random>
namespace omptl namespace omptl
{ {
@ -463,14 +464,15 @@ template <class RandomAccessIterator>
void random_shuffle(RandomAccessIterator first, RandomAccessIterator last, void random_shuffle(RandomAccessIterator first, RandomAccessIterator last,
const unsigned P) const unsigned P)
{ {
return ::std::random_shuffle(first, last); std::random_device rd;
return ::std::shuffle(first, last, std::mt19937(rd()));
} }
template <class RandomAccessIterator, class RandomNumberGenerator> template <class RandomAccessIterator, class RandomNumberGenerator>
void random_shuffle(RandomAccessIterator first, RandomAccessIterator last, void random_shuffle(RandomAccessIterator first, RandomAccessIterator last,
RandomNumberGenerator &rgen, const unsigned P) RandomNumberGenerator &rgen, const unsigned P)
{ {
return ::std::random_shuffle(first, last, rgen); return ::std::shuffle(first, last, rgen);
} }
template <class ForwardIterator, class T> template <class ForwardIterator, class T>

View File

@ -46,7 +46,7 @@ endif(OPENGL_FOUND)
find_package(Boost REQUIRED) find_package(Boost REQUIRED)
find_package(Gettext REQUIRED) find_package(Gettext REQUIRED)
find_package(PkgConfig REQUIRED) find_package(PkgConfig REQUIRED)
find_package(Protobuf REQUIRED) find_package(protobuf REQUIRED CONFIG)
find_package(FFTW3) find_package(FFTW3)
find_package(ALSA) find_package(ALSA)
if (NOT APPLE) if (NOT APPLE)

14
dist/macdeploy.py vendored
View File

@ -35,11 +35,11 @@ STRIP_PREFIX = [
'@@HOMEBREW_CELLAR@@/qt5/5.8.0_1/lib/', '@@HOMEBREW_CELLAR@@/qt5/5.8.0_1/lib/',
] ]
LIBRARY_SEARCH_PATH = ['/target', '/target/lib', '/usr/local/lib', '/sw/lib'] LIBRARY_SEARCH_PATH = ['/opt/homebrew/lib', '/target', '/target/lib', '/usr/local/lib', '/sw/lib']
GSTREAMER_PLUGINS = [ GSTREAMER_PLUGINS = [
# Core plugins # Core plugins
'libgstapp.dylib', 'libgstapp-1.0.dylib',
'libgstaudioconvert.dylib', 'libgstaudioconvert.dylib',
'libgstaudiofx.dylib', 'libgstaudiofx.dylib',
'libgstaudiotestsrc.dylib', 'libgstaudiotestsrc.dylib',
@ -88,10 +88,12 @@ GSTREAMER_PLUGINS = [
] ]
GSTREAMER_SEARCH_PATH = [ GSTREAMER_SEARCH_PATH = [
'/opt/homebrew/lib',
'/usr/local/lib/gstreamer-1.0', '/usr/local/lib/gstreamer-1.0',
'/target/lib/gstreamer-1.0', '/target/lib/gstreamer-1.0',
'/target/libexec/gstreamer-1.0', '/target/libexec/gstreamer-1.0',
'/usr/local/opt/gstreamer/libexec/gstreamer-1.0', '/usr/local/opt/gstreamer/libexec/gstreamer-1.0',
'/opt/homebrew/Cellar/gstreamer/1.22.4/libexec/gstreamer-1.0',
] ]
QT_PLUGINS = [ QT_PLUGINS = [
@ -110,6 +112,7 @@ QT_PLUGINS = [
'styles/libqmacstyle.dylib', 'styles/libqmacstyle.dylib',
] ]
QT_PLUGINS_SEARCH_PATH = [ QT_PLUGINS_SEARCH_PATH = [
'/opt/homebrew/Cellar/qt@5/5.15.10/plugins',
'/usr/local/opt/qt5/plugins', '/usr/local/opt/qt5/plugins',
'/target/plugins', '/target/plugins',
'/usr/local/Trolltech/Qt-4.7.0/plugins', '/usr/local/Trolltech/Qt-4.7.0/plugins',
@ -117,6 +120,7 @@ QT_PLUGINS_SEARCH_PATH = [
] ]
GIO_MODULES_SEARCH_PATH = [ GIO_MODULES_SEARCH_PATH = [
'/opt/homebrew/lib/gio/modules',
'/usr/local/lib/gio/modules', '/usr/local/lib/gio/modules',
'/target/lib/gio/modules', '/target/lib/gio/modules',
] ]
@ -204,6 +208,12 @@ def GetBrokenLibraries(binary):
*os.path.split(line)[1:], *os.path.split(line)[1:],
) )
broken_libs['libs'].append(abs_path) broken_libs['libs'].append(abs_path)
elif re.match(r'^\s*@rpath', line):
abs_path = os.path.join(
os.path.dirname(binary),
*os.path.split(line)[1:],
)
broken_libs['libs'].append(abs_path)
elif re.match(r'^\s*@executable_path', line): elif re.match(r'^\s*@executable_path', line):
# Potentially already fixed library # Potentially already fixed library
relative_path = os.path.join(*line.split('/')[3:]) relative_path = os.path.join(*line.split('/')[3:])

View File

@ -32,6 +32,11 @@ target_link_libraries(clementine-tagreader
z z
) )
set_property(
TARGET clementine-tagreader
PROPERTY CXX_STANDARD 17
)
if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
target_link_libraries(clementine-tagreader target_link_libraries(clementine-tagreader
execinfo execinfo

View File

@ -33,6 +33,11 @@ add_library(libclementine-common STATIC
${MOC} ${MOC}
) )
set_property(
TARGET libclementine-common
PROPERTY CXX_STANDARD 17
)
target_link_libraries(libclementine-common target_link_libraries(libclementine-common
Qt5::Core Qt5::Core
Qt5::Network Qt5::Network

View File

@ -6,14 +6,27 @@ set(MESSAGES
remotecontrolmessages.proto remotecontrolmessages.proto
) )
protobuf_generate_cpp(PROTO_SOURCES PROTO_HEADERS ${MESSAGES}) add_library(libclementine-remote STATIC)
add_library(libclementine-remote STATIC protobuf_generate(
${PROTO_SOURCES} LANGUAGE cpp
TARGET libclementine-remote
PROTOS ${MESSAGES}
) )
set_property(
TARGET libclementine-remote
PROPERTY CXX_STANDARD 17
)
get_cmake_property(_variableNames VARIABLES)
list (SORT _variableNames)
foreach (_variableName ${_variableNames})
message(STATUS "${_variableName}=${${_variableName}}")
endforeach()
target_link_libraries(libclementine-remote target_link_libraries(libclementine-remote
${PROTOBUF_LIBRARY} protobuf::libprotobuf
libclementine-common libclementine-common
) )

View File

@ -28,16 +28,24 @@ optional_source(HAVE_GOOGLE_DRIVE
qt5_wrap_cpp(MOC ${HEADERS}) qt5_wrap_cpp(MOC ${HEADERS})
protobuf_generate_cpp(PROTO_SOURCES PROTO_HEADERS ${MESSAGES})
add_library(libclementine-tagreader STATIC add_library(libclementine-tagreader STATIC
${PROTO_SOURCES}
${SOURCES} ${SOURCES}
${MOC} ${MOC}
) )
protobuf_generate(
LANGUAGE cpp
TARGET libclementine-tagreader
PROTOS ${MESSAGES}
)
set_property(
TARGET libclementine-tagreader
PROPERTY CXX_STANDARD 17
)
target_link_libraries(libclementine-tagreader target_link_libraries(libclementine-tagreader
${PROTOBUF_LIBRARY} protobuf::libprotobuf
libclementine-common libclementine-common
) )

View File

@ -1244,6 +1244,11 @@ add_library(clementine_lib STATIC
${OTHER_UIC_SOURCES} ${OTHER_UIC_SOURCES}
) )
set_property(
TARGET clementine_lib
PROPERTY CXX_STANDARD 17
)
target_link_libraries(clementine_lib target_link_libraries(clementine_lib
libclementine-common libclementine-common
libclementine-tagreader libclementine-tagreader

View File

@ -27,7 +27,7 @@
#include "core/song.h" #include "core/song.h"
class TranscoderPreset; struct TranscoderPreset;
class OrganiseFormat { class OrganiseFormat {
public: public:

View File

@ -26,7 +26,7 @@
#include "core/closure.h" #include "core/closure.h"
#include "core/network.h" #include "core/network.h"
using std::mem_fun; using std::mem_fn;
namespace { namespace {
@ -89,7 +89,7 @@ void MusicbrainzCoverProvider::ReleaseSearchFinished(QNetworkReply* reply,
void MusicbrainzCoverProvider::ImageCheckFinished(int id) { void MusicbrainzCoverProvider::ImageCheckFinished(int id) {
QList<QNetworkReply*> replies = image_checks_.values(id); QList<QNetworkReply*> replies = image_checks_.values(id);
int finished_count = std::count_if(replies.constBegin(), replies.constEnd(), int finished_count = std::count_if(replies.constBegin(), replies.constEnd(),
mem_fun(&QNetworkReply::isFinished)); mem_fn(&QNetworkReply::isFinished));
if (finished_count == replies.size()) { if (finished_count == replies.size()) {
QString cover_name = cover_names_.take(id); QString cover_name = cover_names_.take(id);
QList<CoverSearchResult> results; QList<CoverSearchResult> results;

View File

@ -17,11 +17,13 @@
#include "globalsearch.h" #include "globalsearch.h"
#include <algorithm>
#include <random>
#include <QSettings> #include <QSettings>
#include <QStringBuilder> #include <QStringBuilder>
#include <QTimerEvent> #include <QTimerEvent>
#include <QUrl> #include <QUrl>
#include <algorithm>
#include "core/application.h" #include "core/application.h"
#include "core/logging.h" #include "core/logging.h"
@ -371,7 +373,9 @@ QStringList GlobalSearch::GetSuggestions(int count) {
} }
// Randomize the suggestions // Randomize the suggestions
std::random_shuffle(ret.begin(), ret.end()); std::random_device rd;
std::mt19937 g(rd());
std::shuffle(ret.begin(), ret.end(), g);
// Only return the first count // Only return the first count
while (ret.length() > count) { while (ret.length() > count) {

View File

@ -17,6 +17,12 @@
#include "playlist.h" #include "playlist.h"
#include <algorithm>
#include <functional>
#include <memory>
#include <random>
#include <unordered_map>
#include <QApplication> #include <QApplication>
#include <QBuffer> #include <QBuffer>
#include <QCoreApplication> #include <QCoreApplication>
@ -29,10 +35,6 @@
#include <QUndoStack> #include <QUndoStack>
#include <QtConcurrentRun> #include <QtConcurrentRun>
#include <QtDebug> #include <QtDebug>
#include <algorithm>
#include <functional>
#include <memory>
#include <unordered_map>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
#include <QRandomGenerator> #include <QRandomGenerator>
@ -2079,6 +2081,8 @@ void Playlist::ReshuffleIndices() {
if (current_virtual_index_ != -1) if (current_virtual_index_ != -1)
std::advance(begin, current_virtual_index_ + 1); std::advance(begin, current_virtual_index_ + 1);
std::random_device rd;
switch (playlist_sequence_->shuffle_mode()) { switch (playlist_sequence_->shuffle_mode()) {
case PlaylistSequence::Shuffle_Off: case PlaylistSequence::Shuffle_Off:
// Handled above. // Handled above.
@ -2086,7 +2090,7 @@ void Playlist::ReshuffleIndices() {
case PlaylistSequence::Shuffle_All: case PlaylistSequence::Shuffle_All:
case PlaylistSequence::Shuffle_InsideAlbum: case PlaylistSequence::Shuffle_InsideAlbum:
std::random_shuffle(begin, end); std::shuffle(begin, end, std::mt19937(rd()));
break; break;
case PlaylistSequence::Shuffle_Albums: { case PlaylistSequence::Shuffle_Albums: {
@ -2103,8 +2107,9 @@ void Playlist::ReshuffleIndices() {
// Shuffle them // Shuffle them
QStringList shuffled_album_keys = album_key_set.values(); QStringList shuffled_album_keys = album_key_set.values();
std::random_shuffle(shuffled_album_keys.begin(), std::shuffle(shuffled_album_keys.begin(),
shuffled_album_keys.end()); shuffled_album_keys.end(),
std::mt19937(rd()));
// If the user is currently playing a song, force its album to be first // If the user is currently playing a song, force its album to be first
// Or if the song was not playing but it was selected, force its album // Or if the song was not playing but it was selected, force its album