Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to C++20 #7554

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
7 changes: 7 additions & 0 deletions cmake/modules/ErrorFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
"-Werror" # Treat warnings as errors
)
endif()

set(SILENCE_DEPRECATION_DEFS "")
set(THIRD_PARTY_SILENCE_DEPRECATION_DEFS "")
elseif(MSVC)
set(COMPILE_ERROR_FLAGS
"/W2" # Enable some warnings by default
Expand All @@ -65,8 +68,12 @@ elseif(MSVC)
"/WX" # Treat warnings as errors
)
endif()

set(SILENCE_DEPRECATION_DEFS "_SILENCE_CXX20_OLD_SHARED_PTR_ATOMIC_SUPPORT_DEPRECATION_WARNING")
set(THIRD_PARTY_SILENCE_DEPRECATION_DEFS "")
messmerd marked this conversation as resolved.
Show resolved Hide resolved
endif()

# Add the flags to the whole directory tree. We use the third-party flags for
# targets whose SYSTEM property is true, and the normal flags otherwise.
add_compile_options("$<IF:$<BOOL:$<TARGET_PROPERTY:SYSTEM>>,${THIRD_PARTY_COMPILE_ERROR_FLAGS},${COMPILE_ERROR_FLAGS}>")
add_compile_definitions("$<IF:$<BOOL:$<TARGET_PROPERTY:SYSTEM>>,${THIRD_PARTY_SILENCE_DEPRECATION_DEFS},${SILENCE_DEPRECATION_DEFS}>")
messmerd marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 2 additions & 2 deletions plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
SET(CMAKE_DEBUG_POSTFIX "")

# Enable C++17
SET(CMAKE_CXX_STANDARD 17)
# Enable C++20
SET(CMAKE_CXX_STANDARD 20)

IF(LMMS_BUILD_APPLE AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
Expand Down
1 change: 0 additions & 1 deletion plugins/SpectrumAnalyzer/SaControlsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,6 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor)
m_waterfall = new SaWaterfallView(controls, processor, this);
display_splitter->addWidget(m_waterfall);
m_waterfall->setVisible(m_controls->m_waterfallModel.value());
connect(&controls->m_waterfallModel, &BoolModel::dataChanged, [=] {m_waterfall->updateVisibility();});
}


Expand Down
1 change: 1 addition & 0 deletions plugins/SpectrumAnalyzer/SaWaterfallView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ SaWaterfallView::SaWaterfallView(SaControls *controls, SaProcessor *processor, Q
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

connect(getGUI()->mainWindow(), SIGNAL(periodicUpdate()), this, SLOT(periodicUpdate()));
connect(&controls->m_waterfallModel, &BoolModel::dataChanged, this, &SaWaterfallView::updateVisibility);

m_displayTop = 1;
m_displayBottom = height() -2;
Expand Down
2 changes: 1 addition & 1 deletion plugins/Vibed/NineButtonSelector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ NineButtonSelector::NineButtonSelector(std::array<QPixmap, 18> onOffIcons, int d
m_buttons[i]->setActiveGraphic(onOffIcons[i * 2]);
m_buttons[i]->setInactiveGraphic(onOffIcons[(i * 2) + 1]);
m_buttons[i]->setChecked(false);
connect(m_buttons[i].get(), &PixmapButton::clicked, this, [=](){ this->buttonClicked(i); });
connect(m_buttons[i].get(), &PixmapButton::clicked, this, [=, this](){ buttonClicked(i); });
}

m_lastBtn = m_buttons[defaultButton].get();
Expand Down
4 changes: 2 additions & 2 deletions plugins/VstBase/RemoteVstPlugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ endif()

project(RemoteVstPlugin
LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)

include(CheckCXXPreprocessor)
include(CheckCXXSourceCompiles)
Expand Down Expand Up @@ -73,7 +73,7 @@ if(MSVC)
endif()

if(IS_MINGW)
SET(CMAKE_REQUIRED_FLAGS "-std=c++17")
SET(CMAKE_REQUIRED_FLAGS "-std=c++20")
endif()

if(LMMS_BUILD_WIN32)
Expand Down
2 changes: 1 addition & 1 deletion src/3rdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ADD_SUBDIRECTORY(weakjack)
add_library(ringbuffer OBJECT
ringbuffer/src/lib/ringbuffer.cpp
)
target_compile_features(ringbuffer PUBLIC cxx_std_17)
target_compile_features(ringbuffer PUBLIC cxx_std_20)
target_include_directories(ringbuffer PUBLIC
ringbuffer/include
"${CMAKE_CURRENT_BINARY_DIR}"
Expand Down
2 changes: 1 addition & 1 deletion src/3rdparty/hiir/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
add_library(hiir INTERFACE)
target_include_directories(hiir INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
target_compile_features(hiir INTERFACE cxx_std_17)
target_compile_features(hiir INTERFACE cxx_std_20)
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ SET(CMAKE_AUTOMOC ON)
SET(CMAKE_AUTOUIC ON)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})

# Enable C++17
SET(CMAKE_CXX_STANDARD 17)
# Enable C++20
SET(CMAKE_CXX_STANDARD 20)

IF(LMMS_BUILD_APPLE AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
Expand Down
8 changes: 4 additions & 4 deletions src/gui/FileBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -635,15 +635,15 @@ void FileBrowserTreeWidget::contextMenuEvent(QContextMenuEvent * e )

contextMenu.addAction(
tr( "Send to active instrument-track" ),
[=]{ sendToActiveInstrumentTrack(file); }
[=, this]{ sendToActiveInstrumentTrack(file); }
);

contextMenu.addSeparator();

contextMenu.addAction(
QIcon(embed::getIconPixmap("folder")),
tr("Open containing folder"),
[=]{ openContainingFolder(file); }
[=, this]{ openContainingFolder(file); }
);

auto songEditorHeader = new QAction(tr("Song Editor"), nullptr);
Expand Down Expand Up @@ -676,14 +676,14 @@ QList<QAction*> FileBrowserTreeWidget::getContextActions(FileItem* file, bool so

auto toInstrument = new QAction(instrumentAction + tr(" (%2Enter)").arg(shortcutMod), nullptr);
connect(toInstrument, &QAction::triggered,
[=]{ openInNewInstrumentTrack(file, songEditor); });
[=, this]{ openInNewInstrumentTrack(file, songEditor); });
result.append(toInstrument);

if (songEditor && fileIsSample)
{
auto toSampleTrack = new QAction(tr("Send to new sample track (Shift + Enter)"), nullptr);
connect(toSampleTrack, &QAction::triggered,
[=]{ openInNewSampleTrack(file); });
[=, this]{ openInNewSampleTrack(file); });
result.append(toSampleTrack);
}

Expand Down
20 changes: 10 additions & 10 deletions src/gui/MicrotunerConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ MicrotunerConfig::MicrotunerConfig() :
auto scaleCombo = new ComboBox();
scaleCombo->setModel(&m_scaleComboModel);
microtunerLayout->addWidget(scaleCombo, 1, 0, 1, 2);
connect(&m_scaleComboModel, &ComboBoxModel::dataChanged, [=] {updateScaleForm();});
connect(&m_scaleComboModel, &ComboBoxModel::dataChanged, this, &MicrotunerConfig::updateScaleForm);

m_scaleNameEdit = new QLineEdit("12-TET");
m_scaleNameEdit->setToolTip(tr("Scale description. Cannot start with \"!\" and cannot contain a newline character."));
Expand All @@ -106,8 +106,8 @@ MicrotunerConfig::MicrotunerConfig() :
saveScaleButton->setToolTip(tr("Save scale definition to a file."));
microtunerLayout->addWidget(loadScaleButton, 3, 0, 1, 1);
microtunerLayout->addWidget(saveScaleButton, 3, 1, 1, 1);
connect(loadScaleButton, &QPushButton::clicked, [=] {loadScaleFromFile();});
connect(saveScaleButton, &QPushButton::clicked, [=] {saveScaleToFile();});
connect(loadScaleButton, &QPushButton::clicked, this, &MicrotunerConfig::loadScaleFromFile);
connect(saveScaleButton, &QPushButton::clicked, this, &MicrotunerConfig::saveScaleToFile);

m_scaleTextEdit = new QPlainTextEdit();
m_scaleTextEdit->setPlainText("100.0\n200.0\n300.0\n400.0\n500.0\n600.0\n700.0\n800.0\n900.0\n1000.0\n1100.0\n1200.0");
Expand All @@ -117,7 +117,7 @@ MicrotunerConfig::MicrotunerConfig() :
auto applyScaleButton = new QPushButton(tr("Apply scale changes"));
applyScaleButton->setToolTip(tr("Verify and apply changes made to the selected scale. To use the scale, select it in the settings of a supported instrument."));
microtunerLayout->addWidget(applyScaleButton, 6, 0, 1, 2);
connect(applyScaleButton, &QPushButton::clicked, [=] {applyScale();});
connect(applyScaleButton, &QPushButton::clicked, this, &MicrotunerConfig::applyScale);

// ----------------------------------
// Mapping sub-column
Expand All @@ -132,7 +132,7 @@ MicrotunerConfig::MicrotunerConfig() :
auto keymapCombo = new ComboBox();
keymapCombo->setModel(&m_keymapComboModel);
microtunerLayout->addWidget(keymapCombo, 1, 2, 1, 2);
connect(&m_keymapComboModel, &ComboBoxModel::dataChanged, [=] {updateKeymapForm();});
connect(&m_keymapComboModel, &ComboBoxModel::dataChanged, this, &MicrotunerConfig::updateKeymapForm);

m_keymapNameEdit = new QLineEdit("default");
m_keymapNameEdit->setToolTip(tr("Keymap description. Cannot start with \"!\" and cannot contain a newline character."));
Expand All @@ -144,8 +144,8 @@ MicrotunerConfig::MicrotunerConfig() :
saveKeymapButton->setToolTip(tr("Save key mapping definition to a file."));
microtunerLayout->addWidget(loadKeymapButton, 3, 2, 1, 1);
microtunerLayout->addWidget(saveKeymapButton, 3, 3, 1, 1);
connect(loadKeymapButton, &QPushButton::clicked, [=] {loadKeymapFromFile();});
connect(saveKeymapButton, &QPushButton::clicked, [=] {saveKeymapToFile();});
connect(loadKeymapButton, &QPushButton::clicked, this, &MicrotunerConfig::loadKeymapFromFile);
connect(saveKeymapButton, &QPushButton::clicked, this, &MicrotunerConfig::saveKeymapToFile);

m_keymapTextEdit = new QPlainTextEdit();
m_keymapTextEdit->setPlainText("0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11");
Expand Down Expand Up @@ -189,7 +189,7 @@ MicrotunerConfig::MicrotunerConfig() :
auto applyKeymapButton = new QPushButton(tr("Apply keymap changes"));
applyKeymapButton->setToolTip(tr("Verify and apply changes made to the selected key mapping. To use the mapping, select it in the settings of a supported instrument."));
microtunerLayout->addWidget(applyKeymapButton, 6, 2, 1, 2);
connect(applyKeymapButton, &QPushButton::clicked, [=] {applyKeymap();});
connect(applyKeymapButton, &QPushButton::clicked, this, &MicrotunerConfig::applyKeymap);

updateScaleForm();
updateKeymapForm();
Expand Down Expand Up @@ -325,7 +325,7 @@ void MicrotunerConfig::updateKeymapForm()
*/
bool MicrotunerConfig::validateScaleForm()
{
auto fail = [=](QString message) {QMessageBox::critical(this, tr("Scale parsing error"), message);};
auto fail = [this](const QString& message){ QMessageBox::critical(this, tr("Scale parsing error"), message); };

// check name
QString name = m_scaleNameEdit->text();
Expand Down Expand Up @@ -373,7 +373,7 @@ bool MicrotunerConfig::validateScaleForm()
*/
bool MicrotunerConfig::validateKeymapForm()
{
auto fail = [=](QString message) {QMessageBox::critical(this, tr("Keymap parsing error"), message);};
auto fail = [this](const QString& message){ QMessageBox::critical(this, tr("Keymap parsing error"), message); };

// check name
QString name = m_keymapNameEdit->text();
Expand Down
2 changes: 1 addition & 1 deletion src/gui/PluginBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ void PluginDescWidget::contextMenuEvent(QContextMenuEvent* e)
QMenu contextMenu(this);
contextMenu.addAction(
tr("Send to new instrument track"),
[=]{ openInNewInstrumentTrack(m_pluginKey.desc->name); }
[=, this]{ openInNewInstrumentTrack(m_pluginKey.desc->name); }
);
contextMenu.exec(e->globalPos());
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/SideBarWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ SideBarWidget::SideBarWidget( const QString & _title, const QPixmap & _icon,
m_closeBtn->resize(m_buttonSize);
m_closeBtn->setToolTip(tr("Close"));
connect(m_closeBtn, &QPushButton::clicked,
[=]() { this->closeButtonClicked(); });
[this]() { this->closeButtonClicked(); });
}


Expand Down
2 changes: 1 addition & 1 deletion src/gui/editors/PianoRoll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3098,7 +3098,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
// allow quantization grid up to 1/32 for normal notes
else if (q < 6) { q = 6; }
}
auto xCoordOfTick = [=](int tick) {
auto xCoordOfTick = [this](int tick) {
return m_whiteKeyWidth + (
(tick - m_currentPosition) * m_ppb / TimePos::ticksPerBar()
);
Expand Down
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ foreach(LMMS_TEST_SRC IN LISTS LMMS_TESTS)
${QT_QTTEST_LIBRARY}
)

target_compile_features(${LMMS_TEST_NAME} PRIVATE cxx_std_17)
target_compile_features(${LMMS_TEST_NAME} PRIVATE cxx_std_20)
endforeach()
Loading