diff options
author | Cristian Adam <cristian.adam@qt.io> | 2022-04-21 14:10:09 +0200 |
---|---|---|
committer | Cristian Adam <cristian.adam@qt.io> | 2022-04-29 07:16:53 +0000 |
commit | 88781a003ffd5f699f70b06d2d99325cf4e60c0f (patch) | |
tree | 2b4c888fbcdf57a870302d4d6e68cefef7e19a62 /src/plugins/qmldesigner | |
parent | 58b0a5056c3afe922a2fe8570735da03fb9c3db5 (diff) |
CMake: Qt Creator Static build support
This adds the build system feature that allows Qt Creator's libraries
and plugins to be compiled statically.
Fixes some symbol clashes when all plugins are linked into the same
executable.
Support for actually loading static plugins will be added in a separate
commit.
The feature is controlled by QTC_STATIC_BUILD which by default is OFF.
Change-Id: I1fab7953c43e42dc75619e35660029ee067106df
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/plugins/qmldesigner')
8 files changed, 46 insertions, 29 deletions
diff --git a/src/plugins/qmldesigner/CMakeLists.txt b/src/plugins/qmldesigner/CMakeLists.txt index 2a2c2314ba..e208c7a3d9 100644 --- a/src/plugins/qmldesigner/CMakeLists.txt +++ b/src/plugins/qmldesigner/CMakeLists.txt @@ -9,7 +9,6 @@ add_qtc_plugin(QmlDesigner QmlJS LanguageUtils QmlEditorWidgets AdvancedDockingSystem Qt5::QuickWidgets Qt5::CorePrivate Sqlite Qt5::Xml Qt5::Svg DEFINES - DESIGNER_CORE_LIBRARY IDE_LIBRARY_BASENAME=\"${IDE_LIBRARY_BASE_PATH}\" SHARE_QML_PATH="${CMAKE_CURRENT_SOURCE_DIR}/../../../share/qtcreator/qmldesigner" PUBLIC_INCLUDES @@ -59,7 +58,16 @@ add_qtc_plugin(QmlDesigner include(qmldesignercore.cmake) extend_with_qmldesigner_core(QmlDesigner) +if (QTC_STATIC_BUILD) + get_target_property(_designerType Qt5::Designer TYPE) + if (${_designerType} STREQUAL "STATIC_LIBRARY") + extend_qtc_target(QmlDesigner PUBLIC_DEFINES QT_DESIGNER_STATIC) + endif() + extend_qtc_target(QmlDesigner PUBLIC_DEPENDS TextEditor) +endif() + add_qtc_plugin(assetexporterplugin + PLUGIN_CLASS AssetExporterPlugin CONDITION TARGET QmlDesigner DEPENDS Core ProjectExplorer QmlDesigner Utils Qt5::Qml Qt5::QuickPrivate PUBLIC_INCLUDES assetexporterplugin @@ -81,6 +89,7 @@ add_qtc_plugin(assetexporterplugin ) add_qtc_plugin(componentsplugin + PLUGIN_CLASS ComponentsPlugin CONDITION TARGET QmlDesigner DEPENDS Core QmlDesigner Utils Qt5::Qml DEFINES COMPONENTS_LIBRARY @@ -96,6 +105,7 @@ add_qtc_plugin(componentsplugin ) add_qtc_plugin(qmlpreviewplugin + PLUGIN_CLASS QmlPreviewWidgetPlugin CONDITION TARGET QmlDesigner DEPENDS Core ProjectExplorer QmlDesigner Utils Qt5::Qml SOURCES @@ -106,6 +116,7 @@ add_qtc_plugin(qmlpreviewplugin ) add_qtc_plugin(qtquickplugin + PLUGIN_CLASS QtQuickPlugin CONDITION TARGET QmlDesigner DEPENDS Core QmlDesigner Utils Qt5::Qml DEFINES QTQUICK_LIBRARY diff --git a/src/plugins/qmldesigner/designercore/include/qmldesignercorelib_global.h b/src/plugins/qmldesigner/designercore/include/qmldesignercorelib_global.h index 552095a8d6..d46e099b98 100644 --- a/src/plugins/qmldesigner/designercore/include/qmldesignercorelib_global.h +++ b/src/plugins/qmldesigner/designercore/include/qmldesignercorelib_global.h @@ -30,9 +30,9 @@ // Unnecessary since core isn't a dll any more. -#if defined(DESIGNER_CORE_LIBRARY) +#if defined(QMLDESIGNER_LIBRARY) #define QMLDESIGNERCORE_EXPORT Q_DECL_EXPORT -#elif defined(DESIGNER_STATIC_CORE_LIBRARY) +#elif defined(QMLDESIGNER_STATIC_LIBRARY) #define QMLDESIGNERCORE_EXPORT #else #define QMLDESIGNERCORE_EXPORT Q_DECL_IMPORT diff --git a/src/plugins/qmldesigner/dynamiclicensecheck.h b/src/plugins/qmldesigner/dynamiclicensecheck.h index fb1e3661b8..f8362cec94 100644 --- a/src/plugins/qmldesigner/dynamiclicensecheck.h +++ b/src/plugins/qmldesigner/dynamiclicensecheck.h @@ -43,7 +43,7 @@ enum FoundLicense { }; namespace Internal { -ExtensionSystem::IPlugin *licenseCheckerPlugin() +inline ExtensionSystem::IPlugin *licenseCheckerPlugin() { const ExtensionSystem::PluginSpec *pluginSpec = Utils::findOrDefault( ExtensionSystem::PluginManager::plugins(), @@ -55,8 +55,7 @@ ExtensionSystem::IPlugin *licenseCheckerPlugin() } } // namespace Internal - -FoundLicense checkLicense() +inline FoundLicense checkLicense() { if (auto plugin = Internal::licenseCheckerPlugin()) { bool retVal = false; @@ -72,7 +71,7 @@ FoundLicense checkLicense() return community; } -QString licensee() +inline QString licensee() { if (auto plugin = Internal::licenseCheckerPlugin()) { QString retVal; diff --git a/src/plugins/qmldesigner/qmldesignercore.cmake b/src/plugins/qmldesigner/qmldesignercore.cmake index 83870a36fe..b904057da2 100644 --- a/src/plugins/qmldesigner/qmldesignercore.cmake +++ b/src/plugins/qmldesigner/qmldesignercore.cmake @@ -28,7 +28,6 @@ function(extend_with_qmldesigner_core target_name) QtSupport TextEditor DEFINES - DESIGNER_CORE_LIBRARY TEST_EXPORTS INCLUDES ${CMAKE_CURRENT_FUNCTION_LIST_DIR} @@ -420,4 +419,11 @@ function(extend_with_qmldesigner_core target_name) SOURCES_PREFIX ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../../share/qtcreator/qml/qmlpuppet/container SOURCES sharedmemory_qt.cpp ) + + set(export_symbol_declaration DEFINES QMLDESIGNER_LIBRARY) + if (QTC_STATIC_BUILD) + set(export_symbol_declaration PUBLIC_DEFINES QMLDESIGNER_STATIC_LIBRARY) + endif() + extend_qtc_target(${target_name} ${export_symbol_declaration}) + endfunction() diff --git a/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewactions.cpp b/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewactions.cpp index 09375ba69f..8d33feaf5c 100644 --- a/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewactions.cpp +++ b/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewactions.cpp @@ -73,7 +73,7 @@ static void handleAction(const SelectionContext &context) } ProjectExplorerPlugin::runStartupProject(Constants::QML_PREVIEW_RUN_MODE, skipDeploy); } else { - QmlPreviewPlugin::stopAllRunControls(); + QmlPreviewWidgetPlugin::stopAllRunControls(); } } } @@ -81,14 +81,14 @@ static void handleAction(const SelectionContext &context) QmlPreviewAction::QmlPreviewAction() : ModelNodeAction(livePreviewId, "Live Preview", previewIcon.icon(), - QmlPreviewPlugin::tr("Show Live Preview"), + QmlPreviewWidgetPlugin::tr("Show Live Preview"), ComponentCoreConstants::qmlPreviewCategory, QKeySequence("Alt+p"), 20, &handleAction, &SelectionContextFunctors::always) { - if (!QmlPreviewPlugin::getPreviewPlugin()) + if (!QmlPreviewWidgetPlugin::getPreviewPlugin()) defaultAction()->setVisible(false); defaultAction()->setCheckable(true); @@ -97,7 +97,7 @@ QmlPreviewAction::QmlPreviewAction() : ModelNodeAction(livePreviewId, void QmlPreviewAction::updateContext() { if (selectionContext().view()->isAttached()) - QmlPreviewPlugin::setQmlFile(); + QmlPreviewWidgetPlugin::setQmlFile(); defaultAction()->setSelectionContext(selectionContext()); } @@ -111,9 +111,9 @@ ZoomPreviewAction::ZoomPreviewAction() : m_zoomAction(new ZoomAction(nullptr)) { QObject::connect(m_zoomAction.get(), &ZoomAction::zoomLevelChanged, [=](float d) { - QmlPreviewPlugin::setZoomFactor(d); + QmlPreviewWidgetPlugin::setZoomFactor(d); }); - if (!QmlPreviewPlugin::getPreviewPlugin()) + if (!QmlPreviewWidgetPlugin::getPreviewPlugin()) m_zoomAction->setVisible(false); } @@ -281,7 +281,7 @@ SwitchLanguageAction::SwitchLanguageAction() : m_switchLanguageAction(new SwitchLanguageComboboxAction(nullptr)) { QObject::connect(m_switchLanguageAction.get(), &SwitchLanguageComboboxAction::currentLocaleChanged, - &QmlPreviewPlugin::setLanguageLocale); + &QmlPreviewWidgetPlugin::setLanguageLocale); } QAction *SwitchLanguageAction::action() const diff --git a/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewplugin.cpp b/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewplugin.cpp index 0975acfde3..701ed34903 100644 --- a/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewplugin.cpp +++ b/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewplugin.cpp @@ -53,7 +53,7 @@ Q_DECLARE_METATYPE(QmlPreview::QmlPreviewRunControlList) namespace QmlDesigner { static QObject *s_previewPlugin = nullptr; -QmlPreviewPlugin::QmlPreviewPlugin() +QmlPreviewWidgetPlugin::QmlPreviewWidgetPlugin() { DesignerActionManager &designerActionManager = QmlDesignerPlugin::instance()->designerActionManager(); @@ -92,12 +92,12 @@ QmlPreviewPlugin::QmlPreviewPlugin() } } -QString QmlPreviewPlugin::pluginName() const +QString QmlPreviewWidgetPlugin::pluginName() const { return QLatin1String("QmlPreviewPlugin"); } -void QmlPreviewPlugin::stopAllRunControls() +void QmlPreviewWidgetPlugin::stopAllRunControls() { QTC_ASSERT(s_previewPlugin, return); @@ -109,7 +109,7 @@ void QmlPreviewPlugin::stopAllRunControls() } -void QmlPreviewPlugin::handleRunningPreviews() +void QmlPreviewWidgetPlugin::handleRunningPreviews() { QTC_ASSERT(s_previewPlugin, return); @@ -124,12 +124,12 @@ void QmlPreviewPlugin::handleRunningPreviews() } } -QString QmlPreviewPlugin::metaInfo() const +QString QmlPreviewWidgetPlugin::metaInfo() const { return QLatin1String(":/qmlpreviewplugin/qmlpreview.metainfo"); } -void QmlPreviewPlugin::setQmlFile() +void QmlPreviewWidgetPlugin::setQmlFile() { if (s_previewPlugin) { const Utils::FilePath qmlFileName = @@ -140,7 +140,7 @@ void QmlPreviewPlugin::setQmlFile() } } -float QmlPreviewPlugin::zoomFactor() +float QmlPreviewWidgetPlugin::zoomFactor() { QVariant zoomFactorVariant = 1.0; if (s_previewPlugin && !s_previewPlugin->property("zoomFactor").isNull()) @@ -148,7 +148,7 @@ float QmlPreviewPlugin::zoomFactor() return zoomFactorVariant.toFloat(); } -void QmlPreviewPlugin::setZoomFactor(float zoomFactor) +void QmlPreviewWidgetPlugin::setZoomFactor(float zoomFactor) { if (auto s_previewPlugin = getPreviewPlugin()) { bool hasZoomFactor = s_previewPlugin->setProperty("zoomFactor", zoomFactor); @@ -156,7 +156,7 @@ void QmlPreviewPlugin::setZoomFactor(float zoomFactor) } } -void QmlPreviewPlugin::setLanguageLocale(const QString &locale) +void QmlPreviewWidgetPlugin::setLanguageLocale(const QString &locale) { if (auto s_previewPlugin = getPreviewPlugin()) { bool hasLocaleIsoCode = s_previewPlugin->setProperty("localeIsoCode", locale); @@ -164,7 +164,7 @@ void QmlPreviewPlugin::setLanguageLocale(const QString &locale) } } -QObject *QmlPreviewPlugin::getPreviewPlugin() +QObject *QmlPreviewWidgetPlugin::getPreviewPlugin() { const QVector<ExtensionSystem::PluginSpec *> &specs = ExtensionSystem::PluginManager::plugins(); const auto pluginIt = std::find_if(specs.cbegin(), specs.cend(), diff --git a/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewplugin.h b/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewplugin.h index 7f50d76696..858bce6afb 100644 --- a/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewplugin.h +++ b/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewplugin.h @@ -33,18 +33,18 @@ QT_FORWARD_DECLARE_CLASS(QAction) namespace QmlDesigner { -class QmlPreviewPlugin : public QObject, QmlDesigner::IWidgetPlugin +class QmlPreviewWidgetPlugin : public QObject, QmlDesigner::IWidgetPlugin { Q_OBJECT Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QmlDesignerPlugin" FILE "qmlpreviewplugin.json") - Q_DISABLE_COPY(QmlPreviewPlugin) + Q_DISABLE_COPY(QmlPreviewWidgetPlugin) Q_INTERFACES(QmlDesigner::IWidgetPlugin) public: - QmlPreviewPlugin(); - ~QmlPreviewPlugin() override = default; + QmlPreviewWidgetPlugin(); + ~QmlPreviewWidgetPlugin() override = default; QString metaInfo() const override; QString pluginName() const override; diff --git a/src/plugins/qmldesigner/studioplugin/CMakeLists.txt b/src/plugins/qmldesigner/studioplugin/CMakeLists.txt index be48a6eab5..3c04dfd624 100644 --- a/src/plugins/qmldesigner/studioplugin/CMakeLists.txt +++ b/src/plugins/qmldesigner/studioplugin/CMakeLists.txt @@ -1,4 +1,5 @@ add_qtc_plugin(StudioPlugin + PLUGIN_CLASS StudioPlugin CONDITION TARGET QmlDesigner DEPENDS Core QmlDesigner Utils ProjectExplorer SOURCES |