Skip to content

Commit a6a3027

Browse files
committed
Make MCP server build optional when qthttpserver is unavailable
Use qtHaveModule(httpserver) to conditionally enable MCP support, guarded by HAVE_MCP preprocessor define throughout the codebase. This fixes CI builds on platforms without the Qt HttpServer module.
1 parent 5dc9640 commit a6a3027

7 files changed

Lines changed: 40 additions & 5 deletions

File tree

src/app/main.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,12 @@ int main(int argc, char *argv[])
105105
"Use OSC port number <osc-port>.", "osc-port", "");
106106
parser.addOption(oscPortOption);
107107

108+
#ifdef HAVE_MCP
108109
// --mcp-port option
109110
QCommandLineOption mcpPortOption(QStringList() << "m" << "mcp-port",
110111
"Use MCP server port number <mcp-port> (0 to disable).", "mcp-port", "");
111112
parser.addOption(mcpPortOption);
113+
#endif
112114

113115
// --lang option
114116
QCommandLineOption localeOption(QStringList() << "l" << "lang",
@@ -218,9 +220,11 @@ int main(int argc, char *argv[])
218220
if (parser.isSet(verboseOption))
219221
win->setVerbose(true);
220222

223+
#ifdef HAVE_MCP
221224
QString mcpPortValue = parser.value("mcp-port");
222225
if (mcpPortValue != "")
223226
win->setMcpPort(mcpPortValue);
227+
#endif
224228

225229
bool optionOk;
226230
qreal fps = parser.value("frame-rate").toDouble(&optionOk);

src/control/control.pri

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
include(../src.pri)
22

33
HEADERS += $$PWD/ConcurrentQueue.h \
4-
$$PWD/OscInterface.h \
5-
$$PWD/McpServer.h
4+
$$PWD/OscInterface.h
65

7-
SOURCES += $$PWD/OscInterface.cpp \
8-
$$PWD/McpServer.cpp
6+
SOURCES += $$PWD/OscInterface.cpp
7+
8+
contains(DEFINES, HAVE_MCP) {
9+
HEADERS += $$PWD/McpServer.h
10+
SOURCES += $$PWD/McpServer.cpp
11+
}
912

1013
# OSC support:
1114
INCLUDEPATH += $$PWD/qosc

src/gui/MainWindow.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,10 @@ MainWindow::MainWindow()
8989
// Start osc.
9090
startOscReceiver();
9191

92+
#ifdef HAVE_MCP
9293
// Start MCP server.
9394
startMcpServer();
95+
#endif
9496

9597
// Defaults.
9698
setWindowIcon(QIcon(":/mapmap-logo"));
@@ -2530,7 +2532,9 @@ void MainWindow::readSettings()
25302532
displayControlsAction->setChecked(settings.value("displayControls", MM::DISPLAY_CONTROLS).toBool());
25312533
outputWindow->setCanvasDisplayCrosshair(settings.value("displayControls", MM::DISPLAY_CONTROLS).toBool());
25322534
oscListeningPort = settings.value("oscListeningPort", MM::DEFAULT_OSC_PORT).toInt();
2535+
#ifdef HAVE_MCP
25332536
mcpListeningPort = settings.value("mcpListeningPort", MM::DEFAULT_MCP_PORT).toInt();
2537+
#endif
25342538

25352539
// Update Recent files and video
25362540
updateRecentFileActions();
@@ -3741,6 +3745,7 @@ bool MainWindow::setOscPort(QString portNumber)
37413745
return true;
37423746
}
37433747

3748+
#ifdef HAVE_MCP
37443749
void MainWindow::startMcpServer()
37453750
{
37463751
if (mcp_server.isNull())
@@ -3791,6 +3796,7 @@ bool MainWindow::setMcpPort(QString portNumber)
37913796
return false;
37923797
}
37933798
}
3799+
#endif // HAVE_MCP
37943800

37953801
void MainWindow::pollOscInterface()
37963802
{

src/gui/MainWindow.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@
3737
#include "MapperGLCanvas.h"
3838
#include "MapperGLCanvasToolbar.h"
3939
#include "OscInterface.h"
40+
#ifdef HAVE_MCP
4041
#include "McpServer.h"
42+
#endif
4143

4244
#include "OutputGLWindow.h"
4345
#include "ConsoleWindow.h"
@@ -303,8 +305,10 @@ public slots:
303305
// OSC.
304306
void startOscReceiver();
305307

308+
#ifdef HAVE_MCP
306309
// MCP server.
307310
void startMcpServer();
311+
#endif
308312

309313
// Actions-related.
310314
bool okToContinue();
@@ -522,9 +526,11 @@ public slots:
522526
int oscListeningPort;
523527
QTimer *osc_timer;
524528

529+
#ifdef HAVE_MCP
525530
// MCP server.
526531
QScopedPointer<McpServer> mcp_server;
527532
int mcpListeningPort;
533+
#endif
528534

529535
// View.
530536

@@ -632,9 +638,11 @@ public slots:
632638
bool setOscPort(int portNumber);
633639
int getOscPort() const;
634640
void setVerbose(bool verbose);
641+
#ifdef HAVE_MCP
635642
bool setMcpPort(QString portNumber);
636643
bool setMcpPort(int portNumber);
637644
int getMcpPort() const;
645+
#endif
638646
void setOutputWindowFullScreen(bool enable);
639647

640648
public:

src/gui/PreferenceDialog.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,10 @@ bool PreferenceDialog::loadSettings()
122122

123123
// Allow OSC message with same media source
124124
_oscSameMediaSourceBox->setChecked(settings.value("oscSameMediaSource", MM::OSC_SAME_MEDIA_SOURCE).toBool());
125+
#ifdef HAVE_MCP
125126
// MCP port
126127
_mcpPortNumber->setValue(settings.value("mcpListeningPort", MM::DEFAULT_MCP_PORT).toInt());
128+
#endif
127129
// Play in loop
128130
_playInLoopBox->setChecked(settings.value("playInLoop", MM::PLAY_IN_LOOP).toBool());
129131

@@ -158,9 +160,11 @@ void PreferenceDialog::applySettings()
158160
settings.setValue("language", _languageBox->currentData());
159161
// Allow OSC message with same media source
160162
settings.setValue("oscSameMediaSource", _oscSameMediaSourceBox->isChecked());
163+
#ifdef HAVE_MCP
161164
// MCP port
162165
settings.setValue("mcpListeningPort", _mcpPortNumber->value());
163166
mainWindow->setMcpPort(_mcpPortNumber->value());
167+
#endif
164168
// Play in loop
165169
settings.setValue("playInLoop", _playInLoopBox->isChecked());
166170
}
@@ -378,6 +382,7 @@ void PreferenceDialog::createControlsPage()
378382

379383
_controlsPage->addTab(_oscWidget, tr("OSC Setup"));
380384

385+
#ifdef HAVE_MCP
381386
// MCP Tab
382387
_mcpWidget = new QWidget;
383388

@@ -397,6 +402,7 @@ void PreferenceDialog::createControlsPage()
397402
_mcpWidget->setLayout(mcpLayout);
398403

399404
_controlsPage->addTab(_mcpWidget, tr("MCP Setup"));
405+
#endif
400406

401407
refreshCurrentIP();
402408
}

src/gui/PreferenceDialog.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,11 @@ private slots:
109109
QSpinBox *_listenPortNumber;
110110
QPushButton *_ipRefreshButton;
111111
QCheckBox *_oscSameMediaSourceBox;
112+
#ifdef HAVE_MCP
112113
// MCP
113114
QWidget *_mcpWidget;
114115
QSpinBox *_mcpPortNumber;
116+
#endif
115117

116118
// Advanced widgets
117119
// Playback

src/src.pri

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ QT += network
66
QT += multimedia
77
QT += multimediawidgets
88
QT += widgets
9-
QT += httpserver
9+
qtHaveModule(httpserver) {
10+
QT += httpserver
11+
DEFINES += HAVE_MCP
12+
message("Qt HttpServer module found — MCP server enabled")
13+
} else {
14+
message("Qt HttpServer module not found — MCP server disabled")
15+
}
1016

1117
#Includes common configuration for all subdirectory .pro files.
1218
INCLUDEPATH += $$PWD/core \

0 commit comments

Comments
 (0)