Skip to content

Commit

Permalink
Support unity builds
Browse files Browse the repository at this point in the history
Some fixes for errors that occur when trying to do a unity build using
cmake -DCMAKE_UNITY_BUILD=ON

- Add several missing include guards
- Turn off unity build for cmt which breaks otherwise
- Move embed.h includes to cpp files because it's using PLUGIN_NAME and
  therefore is different for each plugin
- For the same reason, move Monstro's UI macros to from Monstro.h to
  Monstro.cpp. I couldn't test whether not doing this actually breaks
  anything, but it's more at home there anyway if you ask me
  • Loading branch information
lukas-w committed Nov 5, 2023
1 parent 3342e17 commit f57646b
Show file tree
Hide file tree
Showing 28 changed files with 82 additions and 40 deletions.
19 changes: 8 additions & 11 deletions include/ComboBoxModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,28 @@
#include <vector>

#include "AutomatableModel.h"
#include "embed.h"

namespace lmms
{

class PixmapLoader;

class LMMS_EXPORT ComboBoxModel : public IntModel
{
Q_OBJECT
MODEL_IS_VISITABLE
public:
ComboBoxModel( Model* parent = nullptr,
const QString& displayName = QString(),
bool isDefaultConstructed = false ) :
IntModel( 0, 0, 0, parent, displayName, isDefaultConstructed )
{
}
bool isDefaultConstructed = false );

~ComboBoxModel() override
{
clear();
}
~ComboBoxModel() override;

void addItem( QString item, std::unique_ptr<PixmapLoader> loader = nullptr );
void addItem( QString item );
void addItem( QString item, std::unique_ptr<PixmapLoader> loader );

void replaceItem(std::size_t index, QString item, std::unique_ptr<PixmapLoader> loader = nullptr);
void replaceItem(std::size_t index, QString item);
void replaceItem(std::size_t index, QString item, std::unique_ptr<PixmapLoader> loader );

void clear();

Expand Down
1 change: 0 additions & 1 deletion include/MixerView.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include "Engine.h"
#include "Fader.h"
#include "PixmapButton.h"
#include "embed.h"
#include "EffectRackView.h"

class QButtonGroup;
Expand Down
1 change: 1 addition & 0 deletions plugins/DualFilter/DualFilterControlDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*/


#include "embed.h"
#include "DualFilterControlDialog.h"
#include "DualFilterControls.h"
#include "Knob.h"
Expand Down
1 change: 1 addition & 0 deletions plugins/LadspaEffect/cmt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ ADD_LIBRARY(cmt MODULE ${SOURCES})
INSTALL(TARGETS cmt LIBRARY DESTINATION "${PLUGIN_DIR}/ladspa")

SET_TARGET_PROPERTIES(cmt PROPERTIES PREFIX "")
SET_TARGET_PROPERTIES(cmt PROPERTIES UNITY_BUILD OFF)
target_compile_options(cmt PRIVATE -Wall -O3 -fno-strict-aliasing)

if(LMMS_BUILD_WIN32)
Expand Down
2 changes: 2 additions & 0 deletions plugins/MidiExport/MidiExport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

#include "MidiExport.h"

#include <QDataStream>

#include "TrackContainer.h"
#include "DataFile.h"
#include "InstrumentTrack.h"
Expand Down
1 change: 1 addition & 0 deletions plugins/MidiImport/portsmf/algrd_internal.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* algread_internal.h -- interface between allegro.cpp and allegrord.cpp */
#pragma once

#include "allegro.h"

Expand Down
1 change: 1 addition & 0 deletions plugins/MidiImport/portsmf/algsmfrd_internal.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* algsmfrd_internal.h -- interface from allegrosmfrd.cpp to allegro.cpp */
#pragma once

#include "allegro.h"

Expand Down
1 change: 1 addition & 0 deletions plugins/MidiImport/portsmf/mfmidi.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pragma once
#include <cstddef>

#define NOTEOFF 0x80
Expand Down
1 change: 1 addition & 0 deletions plugins/MidiImport/portsmf/strparse.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// strparse.h -- header for String_parse class
#pragma once

class String_parse {
public:
Expand Down
1 change: 1 addition & 0 deletions plugins/MidiImport/portsmf/trace.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#pragma once
void trace(char *format, ...);

26 changes: 26 additions & 0 deletions plugins/Monstro/Monstro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,32 @@ Plugin::Descriptor PLUGIN_EXPORT monstro_plugin_descriptor =
}


//
// UI Macros
//

#define makeknob( name, x, y, hint, unit, oname ) \
name = new Knob( KnobType::Styled, view ); \
name ->move( x, y ); \
name ->setHintText( hint, unit ); \
name ->setObjectName( oname ); \
name ->setFixedSize( 20, 20 );

#define maketsknob( name, x, y, hint, unit, oname ) \
name = new TempoSyncKnob( KnobType::Styled, view ); \
name ->move( x, y ); \
name ->setHintText( hint, unit ); \
name ->setObjectName( oname ); \
name ->setFixedSize( 20, 20 );

#define maketinyled( name, x, y, ttip ) \
name = new PixmapButton( view, nullptr ); \
name -> setCheckable( true ); \
name -> move( x, y ); \
name -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "tinyled_on" ) ); \
name -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "tinyled_off" ) ); \
name->setToolTip(ttip);



MonstroSynth::MonstroSynth( MonstroInstrument * _i, NotePlayHandle * _nph ) :
Expand Down
26 changes: 0 additions & 26 deletions plugins/Monstro/Monstro.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,32 +38,6 @@
#include "lmms_math.h"
#include "BandLimitedWave.h"

//
// UI Macros
//

#define makeknob( name, x, y, hint, unit, oname ) \
name = new Knob( KnobType::Styled, view ); \
name ->move( x, y ); \
name ->setHintText( hint, unit ); \
name ->setObjectName( oname ); \
name ->setFixedSize( 20, 20 );

#define maketsknob( name, x, y, hint, unit, oname ) \
name = new TempoSyncKnob( KnobType::Styled, view ); \
name ->move( x, y ); \
name ->setHintText( hint, unit ); \
name ->setObjectName( oname ); \
name ->setFixedSize( 20, 20 );

#define maketinyled( name, x, y, ttip ) \
name = new PixmapButton( view, nullptr ); \
name -> setCheckable( true ); \
name -> move( x, y ); \
name -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "tinyled_on" ) ); \
name -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "tinyled_off" ) ); \
name->setToolTip(ttip);

namespace lmms
{

Expand Down
1 change: 1 addition & 0 deletions plugins/ReverbSC/base.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pragma once
#include <stdint.h>
#include <stdio.h>

Expand Down
1 change: 1 addition & 0 deletions plugins/ReverbSC/dcblock.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pragma once
typedef struct {
SPFLOAT gg;
SPFLOAT outputs;
Expand Down
1 change: 1 addition & 0 deletions plugins/ReverbSC/revsc.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pragma once
typedef struct {
int writePos;
int bufferSize;
Expand Down
2 changes: 2 additions & 0 deletions plugins/SpectrumAnalyzer/SaControls.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#ifndef SACONTROLS_H
#define SACONTROLS_H

#include <QColor>

#include "ComboBoxModel.h"
#include "EffectControls.h"

Expand Down
1 change: 1 addition & 0 deletions plugins/SpectrumAnalyzer/SaControlsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <QSplitter>
#include <QWidget>

#include "embed.h"
#include "ComboBox.h"
#include "ComboBoxModel.h"
#include "Knob.h"
Expand Down
3 changes: 1 addition & 2 deletions plugins/ZynAddSubFx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ if(NOT MSVC AND (LMMS_HOST_X86 OR LMMS_HOST_X86_64))
ADD_DEFINITIONS(-DASM_F2I_YES)
endif()

# build ZynAddSubFX with full optimizations
if(NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -Wno-write-strings -Wno-deprecated-declarations -fpermissive")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-write-strings -Wno-deprecated-declarations -fpermissive")
endif()

IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND NOT "${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "6.0.0")
Expand Down
23 changes: 23 additions & 0 deletions src/core/ComboBoxModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,41 @@

#include <cassert>

#include "embed.h"

namespace lmms
{

using std::unique_ptr;
using std::move;

ComboBoxModel::ComboBoxModel(Model* parent, const QString& displayName, bool isDefaultConstructed)
:
IntModel( 0, 0, 0, parent, displayName, isDefaultConstructed )
{
}

ComboBoxModel::~ComboBoxModel()
{
clear();
}

void ComboBoxModel::addItem(QString item)
{
addItem( item, nullptr );
}

void ComboBoxModel::addItem( QString item, unique_ptr<PixmapLoader> loader )
{
m_items.emplace_back( move(item), move(loader) );
setRange( 0, m_items.size() - 1 );
}

void ComboBoxModel::replaceItem(std::size_t index, QString item)
{
replaceItem(index, item, nullptr);
}


void ComboBoxModel::replaceItem(std::size_t index, QString item, unique_ptr<PixmapLoader> loader)
{
Expand Down
1 change: 1 addition & 0 deletions src/gui/GuiApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include "lmmsversion.h"

#include "embed.h"
#include "LmmsStyle.h"
#include "LmmsPalette.h"

Expand Down
1 change: 1 addition & 0 deletions src/gui/LinkedModelGroupViews.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "LinkedModelGroupViews.h"

#include <QPushButton>
#include "embed.h"
#include "Controls.h"
#include "ControlLayout.h"
#include "LinkedModelGroups.h"
Expand Down
1 change: 1 addition & 0 deletions src/gui/MixerView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

#include "lmms_math.h"

#include "embed.h"
#include "MixerView.h"
#include "Knob.h"
#include "MixerLine.h"
Expand Down
1 change: 1 addition & 0 deletions src/gui/clips/MidiClipView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <QMenu>
#include <QPainter>

#include "embed.h"
#include "ConfigManager.h"
#include "DeprecationHelper.h"
#include "GuiApplication.h"
Expand Down
1 change: 1 addition & 0 deletions src/gui/clips/PatternClipView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <QMenu>
#include <QPainter>

#include "embed.h"
#include "Engine.h"
#include "GuiApplication.h"
#include "MainWindow.h"
Expand Down
1 change: 1 addition & 0 deletions src/gui/instrument/InstrumentTuningView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <QPixmap>
#include <QVBoxLayout>

#include "embed.h"
#include "ComboBox.h"
#include "GroupBox.h"
#include "GuiApplication.h"
Expand Down
1 change: 1 addition & 0 deletions src/gui/tracks/InstrumentTrackView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <QMdiSubWindow>
#include <QMenu>

#include "embed.h"
#include "AudioEngine.h"
#include "ConfigManager.h"
#include "Engine.h"
Expand Down
1 change: 1 addition & 0 deletions src/gui/tracks/PatternTrackView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include "PatternTrackView.h"

#include "embed.h"
#include "Engine.h"
#include "GuiApplication.h"
#include "PatternEditor.h"
Expand Down
1 change: 1 addition & 0 deletions src/gui/tracks/TrackContentWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <QMenu>
#include <QPainter>

#include "embed.h"
#include "AutomationClip.h"
#include "Clipboard.h"
#include "DataFile.h"
Expand Down

0 comments on commit f57646b

Please sign in to comment.