Skip to content

Commit

Permalink
chore: keep the option not to have QML and Qt 5
Browse files Browse the repository at this point in the history
  • Loading branch information
acolombier committed Oct 19, 2023
1 parent 8a284e8 commit 62ed3b1
Show file tree
Hide file tree
Showing 18 changed files with 296 additions and 175 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,28 @@ jobs:
artifacts_path: build/*.deb
artifacts_slug: ubuntu-jammy
qt_qpa_platform: offscreen
- name: Ubuntu 22.04 (QML)
os: ubuntu-22.04
cmake_args: >-
-DQT6=ON
-DQML=ON
-DBULK=ON
-DFFMPEG=ON
-DLOCALECOMPARE=ON
-DMAD=ON
-DMODPLUG=ON
-DWAVPACK=ON
-DINSTALL_USER_UDEV_RULES=OFF
ctest_args: []
compiler_cache: ccache
compiler_cache_path: ~/.ccache
cpack_generator: DEB
buildenv_basepath: /home/runner/buildenv
buildenv_script: tools/debian_buildenv.sh
artifacts_name: Ubuntu 22.04 Qt6 DEB
artifacts_path: build/*.deb
artifacts_slug: ubuntu-jammy
qt_qpa_platform: offscreen
- name: macOS 11 x64
os: macos-11
cmake_args: >-
Expand Down
194 changes: 109 additions & 85 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,21 @@ if(NOT CMAKE_CONFIGURATION_TYPES)
endif()
endif()

set(QT6 ON)
option(QT6 "Build with Qt6" ON)
option(QML "Build with QML" ON)
option(QOPENGL "Use QOpenGLWindow based widget instead of QGLWidget" ON)

if(NOT QT6)
message(FATAL_ERROR "Building requires QT6=ON")
if(QML AND NOT QT6)
message(FATAL_ERROR "Building with option QML=ON requires QT6=ON")
endif()

if(QOPENGL)
add_compile_definitions(MIXXX_USE_QOPENGL)
endif()

if(QML)
add_compile_definitions(MIXXX_USE_QML)
endif()

if(APPLE)
# Check if xcode-select is installed
Expand Down Expand Up @@ -1192,7 +1196,10 @@ add_library(mixxx-lib STATIC EXCLUDE_FROM_ALL
src/widget/wwidgetgroup.cpp
src/widget/wwidgetstack.cpp
)
set(MIXXX_PRECOMPILED_HEADER
set(MIXXX_COMMON_PRECOMPILED_HEADER
src/util/assert.h
)
target_precompile_headers(mixxx-lib PUBLIC
src/audio/frame.h
src/audio/signalinfo.h
src/audio/streaminfo.h
Expand Down Expand Up @@ -1234,7 +1241,6 @@ set(MIXXX_PRECOMPILED_HEADER
src/track/trackrecord.h
src/track/trackref.h
src/util/alphabetafilter.h
src/util/assert.h
src/util/battery/battery.h
src/util/cache.h
src/util/circularbuffer.h
Expand Down Expand Up @@ -1349,6 +1355,7 @@ set(MIXXX_PRECOMPILED_HEADER
src/util/workerthread.h
src/util/workerthreadscheduler.h
src/util/xml.h
${MIXXX_COMMON_PRECOMPILED_HEADER}
)
target_sources(mixxx-lib PRIVATE
src/mixxxmainwindow.cpp
Expand Down Expand Up @@ -1402,6 +1409,12 @@ target_sources(mixxx-lib PRIVATE
src/widget/wvumeterlegacy.cpp
src/widget/wwaveformviewer.cpp
)
if (NOT QML)
target_sources(mixxx-lib PRIVATE
src/control/controlmodel.cpp
src/control/controlsortfiltermodel.cpp
)
endif()
if(QOPENGL)
target_sources(mixxx-lib PRIVATE
src/shaders/endoftrackshader.cpp
Expand Down Expand Up @@ -2532,8 +2545,10 @@ if(QT6)
else()
find_package(QT 5.12 NAMES Qt5 COMPONENTS Core REQUIRED)
endif()
list(APPEND QT_EXTRA_COMPONENTS "Quick")
list(APPEND QT_EXTRA_COMPONENTS "QuickControls2")
if(QML)
list(APPEND QT_EXTRA_COMPONENTS "Quick")
list(APPEND QT_EXTRA_COMPONENTS "QuickControls2")
endif()
find_package(Qt${QT_VERSION_MAJOR}
COMPONENTS
${QT_COMPONENTS}
Expand All @@ -2542,89 +2557,94 @@ find_package(Qt${QT_VERSION_MAJOR}
)
# PUBLIC is required below to find included headers
foreach(COMPONENT ${QT_COMPONENTS})
target_link_libraries(mixxx-lib PUBLIC Qt6::${COMPONENT})
target_link_libraries(mixxx-lib PUBLIC Qt${QT_VERSION_MAJOR}::${COMPONENT})
endforeach()
if(QT_EXTRA_COMPONENTS)
foreach(COMPONENT ${QT_EXTRA_COMPONENTS})
target_link_libraries(mixxx-lib PUBLIC Qt6::${COMPONENT})
target_link_libraries(mixxx-lib PUBLIC Qt${QT_VERSION_MAJOR}::${COMPONENT})
endforeach()
endif()

set(QT_QML_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/qml)
qt_add_library(mixxx-qml-lib STATIC)
foreach(COMPONENT ${QT_COMPONENTS})
target_link_libraries(mixxx-qml-lib PUBLIC Qt6::${COMPONENT})
endforeach()
if(QT_EXTRA_COMPONENTS)
foreach(COMPONENT ${QT_EXTRA_COMPONENTS})
target_link_libraries(mixxx-qml-lib PUBLIC Qt6::${COMPONENT})
if(QML)
set(QT_QML_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/qml)
qt_add_library(mixxx-qml-lib STATIC)
foreach(COMPONENT ${QT_COMPONENTS})
target_link_libraries(mixxx-qml-lib PUBLIC Qt${QT_VERSION_MAJOR}::${COMPONENT})
endforeach()
endif()
set_target_properties(mixxx-qml-lib PROPERTIES AUTOMOC ON)
qt_add_qml_module(mixxx-qml-lib
URI Mixxx
VERSION 1.0
RESOURCE_PREFIX /mixxx.org/imports
IMPORTS QtQuick
QML_FILES
res/qml/Mixxx/MathUtils.mjs
res/qml/Mixxx/PlayerDropArea.qml
)
target_link_libraries(mixxx-lib PRIVATE mixxx-qml-lib)

# FIXME: Currently we need to add these include directories due to
# QTBUG-87221. We should figure out a better way to fix this.
# See: https://bugreports.qt.io/browse/QTBUG-87221
target_include_directories(mixxx-qml-lib PRIVATE src/control src/qml)
target_include_directories(mixxx-qml-lib PUBLIC src/ ${CMAKE_BINARY_DIR}/src)
target_include_directories(mixxx-qml-lib SYSTEM PUBLIC lib/rigtorp/SPSCQueue/include lib/portaudio)

target_link_libraries(mixxx-qml-lib PUBLIC mixxx-proto)
target_link_libraries(mixxx-qml-libplugin PUBLIC mixxx-proto)

target_precompile_headers(mixxx-qml-lib PUBLIC ${MIXXX_PRECOMPILED_HEADER})

target_link_libraries(mixxx-qml-lib PRIVATE mixxx-qml-libplugin)

qt_add_library(mixxx-qml-mixxxcontrols STATIC)
set_target_properties(mixxx-qml-mixxxcontrols PROPERTIES AUTOMOC ON)
qt_add_qml_module(mixxx-qml-mixxxcontrols
URI Mixxx.Controls
VERSION 1.0
RESOURCE_PREFIX /mixxx.org/imports
OPTIONAL_IMPORTS Mixxx
QML_FILES
res/qml/Mixxx/Controls/Knob.qml
res/qml/Mixxx/Controls/Slider.qml
res/qml/Mixxx/Controls/Spinny.qml
res/qml/Mixxx/Controls/WaveformOverviewHotcueMarker.qml
res/qml/Mixxx/Controls/WaveformOverviewMarker.qml
res/qml/Mixxx/Controls/WaveformOverview.qml
)
target_link_libraries(mixxx-qml-lib PRIVATE mixxx-qml-mixxxcontrolsplugin)

target_sources(mixxx-qml-lib PRIVATE
src/qml/asyncimageprovider.cpp
src/qml/qmlapplication.cpp
src/qml/qmlcontrolproxy.cpp
src/qml/qmlconfigproxy.cpp
src/qml/qmldlgpreferencesproxy.cpp
src/qml/qmleffectmanifestparametersmodel.cpp
src/qml/qmleffectsmanagerproxy.cpp
src/qml/qmleffectslotproxy.cpp
src/qml/qmllibraryproxy.cpp
src/qml/qmllibrarytracklistmodel.cpp
src/qml/qmlplayermanagerproxy.cpp
src/qml/qmlplayerproxy.cpp
src/qml/qmlvisibleeffectsmodel.cpp
src/qml/qmlwaveformoverview.cpp
src/control/controlmodel.cpp
src/control/controlsortfiltermodel.cpp
)
if(QT_EXTRA_COMPONENTS)
foreach(COMPONENT ${QT_EXTRA_COMPONENTS})
target_link_libraries(mixxx-qml-lib PUBLIC Qt${QT_VERSION_MAJOR}::${COMPONENT})
endforeach()
endif()
set_target_properties(mixxx-qml-lib PROPERTIES AUTOMOC ON)
qt_add_qml_module(mixxx-qml-lib
URI Mixxx
VERSION 1.0
RESOURCE_PREFIX /mixxx.org/imports
IMPORTS QtQuick
QML_FILES
res/qml/Mixxx/MathUtils.mjs
res/qml/Mixxx/PlayerDropArea.qml
)
target_link_libraries(mixxx-lib PRIVATE mixxx-qml-lib)

# FIXME: Currently we need to add these include directories due to
# QTBUG-87221. We should figure out a better way to fix this.
# See: https://bugreports.qt.io/browse/QTBUG-87221
target_include_directories(mixxx-qml-lib PRIVATE src/control src/qml)
target_include_directories(mixxx-qml-lib PUBLIC src/ ${CMAKE_BINARY_DIR}/src)
target_include_directories(mixxx-qml-lib SYSTEM PUBLIC lib/rigtorp/SPSCQueue/include lib/portaudio)

# qt_finalize_target takes care that the resources :/mixxx.org/imports/Mixxx/
# and :/mixxx.org/imports/Mixxx/Controls are placed into beginning of the binary
qt_finalize_target(mixxx)
target_link_libraries(mixxx-qml-lib PUBLIC mixxx-proto)
target_link_libraries(mixxx-qml-libplugin PUBLIC mixxx-proto)

target_precompile_headers(mixxx-qml-lib PUBLIC
${MIXXX_COMMON_PRECOMPILED_HEADER}
)

target_link_libraries(mixxx-qml-lib PRIVATE mixxx-qml-libplugin)

qt_add_library(mixxx-qml-mixxxcontrols STATIC)
set_target_properties(mixxx-qml-mixxxcontrols PROPERTIES AUTOMOC ON)
qt_add_qml_module(mixxx-qml-mixxxcontrols
URI Mixxx.Controls
VERSION 1.0
RESOURCE_PREFIX /mixxx.org/imports
OPTIONAL_IMPORTS Mixxx
QML_FILES
res/qml/Mixxx/Controls/Knob.qml
res/qml/Mixxx/Controls/Slider.qml
res/qml/Mixxx/Controls/Spinny.qml
res/qml/Mixxx/Controls/WaveformOverviewHotcueMarker.qml
res/qml/Mixxx/Controls/WaveformOverviewMarker.qml
res/qml/Mixxx/Controls/WaveformOverview.qml
)
target_link_libraries(mixxx-qml-lib PRIVATE mixxx-qml-mixxxcontrolsplugin)

target_sources(mixxx-qml-lib PRIVATE
src/qml/asyncimageprovider.cpp
src/qml/qmlapplication.cpp
src/qml/qmlcontrolproxy.cpp
src/qml/qmlconfigproxy.cpp
src/qml/qmldlgpreferencesproxy.cpp
src/qml/qmleffectmanifestparametersmodel.cpp
src/qml/qmleffectsmanagerproxy.cpp
src/qml/qmleffectslotproxy.cpp
src/qml/qmllibraryproxy.cpp
src/qml/qmllibrarytracklistmodel.cpp
src/qml/qmlplayermanagerproxy.cpp
src/qml/qmlplayerproxy.cpp
src/qml/qmlvisibleeffectsmodel.cpp
src/qml/qmlwaveformoverview.cpp
# The following source needs to be in this target to get QML_ELEMENT properly interpreted
src/control/controlmodel.cpp
src/control/controlsortfiltermodel.cpp
)

# qt_finalize_target takes care that the resources :/mixxx.org/imports/Mixxx/
# and :/mixxx.org/imports/Mixxx/Controls are placed into beginning of the binary
qt_finalize_target(mixxx)
endif()

target_compile_definitions(mixxx-lib PUBLIC QT_TABLET_SUPPORT QT_USE_QSTRINGBUILDER)
is_static_library(Qt_IS_STATIC Qt${QT_VERSION_MAJOR}::Core)
Expand Down Expand Up @@ -3207,7 +3227,9 @@ if(BROADCAST)
src/encoder/encoderbroadcastsettings.cpp
)
target_compile_definitions(mixxx-lib PUBLIC __BROADCAST__)
target_compile_definitions(mixxx-qml-lib PUBLIC __BROADCAST__)
if (QML)
target_compile_definitions(mixxx-qml-lib PUBLIC __BROADCAST__)
endif()
endif()

# Opus (RFC 6716)
Expand Down Expand Up @@ -3283,8 +3305,10 @@ endif()
find_package(Microsoft.GSL CONFIG)
if(Microsoft.GSL_FOUND)
target_link_libraries(mixxx-lib PRIVATE Microsoft.GSL::GSL)
target_link_libraries(mixxx-qml-lib PRIVATE Microsoft.GSL::GSL)
target_link_libraries(mixxx-qml-libplugin PRIVATE Microsoft.GSL::GSL)
if (QML)
target_link_libraries(mixxx-qml-lib PRIVATE Microsoft.GSL::GSL)
target_link_libraries(mixxx-qml-libplugin PRIVATE Microsoft.GSL::GSL)
endif()
else()
# check if the headers have been installed without cmake config (< 3.1.0)
check_include_file_cxx(gsl/gsl HAVE_GSL_GSL)
Expand Down
2 changes: 2 additions & 0 deletions src/control/controlmodel.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "control/controlmodel.h"

#include <QStringBuilder>

#include "moc_controlmodel.cpp"

ControlModel::ControlModel(QObject* pParent)
Expand Down
4 changes: 4 additions & 0 deletions src/control/controlsortfiltermodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

#include <QSortFilterProxyModel>
#include <QString>
#ifdef MIXXX_USE_QML
#include <QtQml>
#else
#define QML_ELEMENT
#endif

#include "control/controlmodel.h"

Expand Down
35 changes: 0 additions & 35 deletions src/coreservices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,6 @@
#ifdef __MODPLUG__
#include "preferences/dialog/dlgprefmodplug.h"
#endif
#include "qml/qmlconfigproxy.h"
#include "qml/qmlcontrolproxy.h"
#include "qml/qmldlgpreferencesproxy.h"
#include "qml/qmleffectslotproxy.h"
#include "qml/qmleffectsmanagerproxy.h"
#include "qml/qmllibraryproxy.h"
#include "qml/qmlplayermanagerproxy.h"
#include "qml/qmlplayerproxy.h"
#include "soundio/soundmanager.h"
#include "sources/soundsourceproxy.h"
#include "util/db/dbconnectionpooled.h"
Expand Down Expand Up @@ -453,26 +445,6 @@ void CoreServices::initialize(QApplication* pApp) {
}

m_isInitialized = true;
initializeQMLSignletons();
}

void CoreServices::initializeQMLSignletons() {
// Any uncreateable non-singleton types registered here require
// arguments that we don't want to expose to QML directly. Instead, they
// can be retrieved by member properties or methods from the singleton
// types.
//
// The alternative would be to register their *arguments* in the QML
// system, which would improve nothing, or we had to expose them as
// singletons to that they can be accessed by components instantiated by
// QML, which would also be suboptimal.
mixxx::qml::QmlEffectsManagerProxy::registerEffectsManager(getEffectsManager());
mixxx::qml::QmlPlayerManagerProxy::registerPlayerManager(getPlayerManager());
mixxx::qml::QmlConfigProxy::registerUserSettings(getSettings());
mixxx::qml::QmlLibraryProxy::registerLibrary(getLibrary());
// FIXME: DlgPreferences has some initialization logic that must be executed
// before the GUI is shown, at least for the effects system.
mixxx::qml::QmlDlgPreferencesProxy::registerDlgPreferences(makeDlgPreferences());
}

void CoreServices::initializeKeyboard() {
Expand Down Expand Up @@ -578,13 +550,6 @@ void CoreServices::finalize() {
Timer t("CoreServices::~CoreServices");
t.start();

// Delete all the QML singletons in order to prevent leak detection
mixxx::qml::QmlEffectsManagerProxy::registerEffectsManager(nullptr);
mixxx::qml::QmlPlayerManagerProxy::registerPlayerManager(nullptr);
mixxx::qml::QmlConfigProxy::registerUserSettings(nullptr);
mixxx::qml::QmlLibraryProxy::registerLibrary(nullptr);
mixxx::qml::QmlDlgPreferencesProxy::registerDlgPreferences(nullptr);

// Stop all pending library operations
qDebug() << t.elapsed(false).debugMillisWithUnit() << "stopping pending Library tasks";
m_pTrackCollectionManager->stopLibraryScan();
Expand Down
5 changes: 2 additions & 3 deletions src/coreservices.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ class CoreServices : public QObject {
return m_pScreensaverManager;
}

std::shared_ptr<QDialog> makeDlgPreferences() const;

signals:
void initializationProgressUpdate(int progress, const QString& serviceName);

Expand All @@ -117,9 +119,6 @@ class CoreServices : public QObject {
void initializeSettings();
void initializeScreensaverManager();
void initializeLogging();
void initializeQMLSignletons();

std::shared_ptr<QDialog> makeDlgPreferences() const;

/// Tear down CoreServices that were previously initialized by `initialize()`.
void finalize();
Expand Down
Loading

0 comments on commit 62ed3b1

Please sign in to comment.