Skip to content

Commit 6c2b689

Browse files
committed
fix: resolve duplicate compilation issue by removing redundant install
1. Remove CHAMELEON_PATH definition and usage from CMakeLists.txt 2. Replace compile-time CHAMELEON_PATH with runtime path calculation using QGuiApplication::applicationDirPath() 3. Change install directive from copying entire plugin directory to only installing qmldir file 4. This prevents duplicate files during installation and resolves recompilation issues The changes address a problem where redundant installation content was causing repeatable compilation problems. By removing the compile- time path definition and dynamically calculating the path at runtime, we eliminate dependency on build-time paths. Additionally, installing only the qmldir file instead of the entire plugin directory prevents duplicate file conflicts during installation. Influence: 1. Verify that examples can still find and load Chameleon plugins at runtime 2. Test that QML import paths are correctly set in both exhibition and qml-inspect examples 3. Confirm that plugin installation only includes necessary qmldir file 4. Check that style settings work correctly across different Qt versions 5. Validate that no duplicate files are created during build/install process fix: 解决重复编译问题,移除冗余安装内容 1. 从 CMakeLists.txt 中移除 CHAMELEON_PATH 定义和使用 2. 使用 QGuiApplication::applicationDirPath() 运行时路径计算替换编译 时 CHAMELEON_PATH 3. 将安装指令从复制整个插件目录改为仅安装 qmldir 文件 4. 这防止了安装过程中的重复文件问题并解决了重新编译问题 这些更改解决了冗余安装内容导致可重复编译的问题。通过移除编译时路径定义并 在运行时动态计算路径,我们消除了对构建时路径的依赖。此外,仅安装 qmldir 文件而不是整个插件目录可以防止安装过程中的重复文件冲突。 Influence: 1. 验证示例程序在运行时仍能找到并加载 Chameleon 插件 2. 测试 exhibition 和 qml-inspect 示例中的 QML 导入路径是否正确设置 3. 确认插件安装仅包含必要的 qmldir 文件 4. 检查样式设置在不同 Qt 版本中是否正常工作 5. 验证构建/安装过程中不会创建重复文件
1 parent c37db5d commit 6c2b689

4 files changed

Lines changed: 9 additions & 9 deletions

File tree

examples/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
set(CHAMELEON_PATH "${PROJECT_BINARY_DIR}/plugins")
21
add_definitions(
3-
-DCHAMELEON_PATH="${CHAMELEON_PATH}"
42
-DQT_DEPRECATED_WARNINGS
53
)
64
add_subdirectory(exhibition)

examples/exhibition/main.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,17 @@ int main(int argc, char **argv)
7171

7272
QQmlApplicationEngine engine;
7373

74-
engine.addImportPath(CHAMELEON_PATH);
74+
const QString chameleonPath = QStringLiteral("%1/../../../plugins").arg(QGuiApplication::applicationDirPath());
75+
engine.addImportPath(chameleonPath);
7576
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
76-
QQuickStyle::addStylePath(CHAMELEON_PATH);
77+
QQuickStyle::addStylePath(chameleonPath);
7778
// QQuickWindow::setSceneGraphBackend(QSGRendererInterface::Software);
7879
#else
7980
// QQuickWindow::setGraphicsApi(QSGRendererInterface::Software);
8081
#endif
8182

8283
#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) && defined(QT_NO_DEBUG)
83-
QQuickStyle::setStyle(CHAMELEON_PATH"/Chameleon");
84+
QQuickStyle::setStyle(chameleonPath"/Chameleon");
8485
#else
8586
QQuickStyle::setStyle("Chameleon");
8687
#endif

examples/qml-inspect/main.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,17 @@ int main(int argc, char *argv[])
2020

2121
QQmlApplicationEngine engine;
2222

23-
engine.addImportPath(CHAMELEON_PATH);
23+
const QString chameleonPath = QStringLiteral("%1/../../../plugins").arg(QGuiApplication::applicationDirPath());
24+
engine.addImportPath(chameleonPath);
2425
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
25-
QQuickStyle::addStylePath(CHAMELEON_PATH);
26+
QQuickStyle::addStylePath(chameleonPath);
2627
// QQuickWindow::setSceneGraphBackend(QSGRendererInterface::Software);
2728
#else
2829
// QQuickWindow::setGraphicsApi(QSGRendererInterface::Software);
2930
#endif
3031

3132
#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) && defined(QT_NO_DEBUG)
32-
QQuickStyle::setStyle(CHAMELEON_PATH"/Chameleon");
33+
QQuickStyle::setStyle(chameleonPath"/Chameleon");
3334
#else
3435
QQuickStyle::setStyle("Chameleon");
3536
#endif

qt6/src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,4 @@ install(EXPORT Dtk${DTK_VERSION_MAJOR}DeclarativeTargets NAMESPACE Dtk${DTK_VERS
8787
install(FILES ${QM_FILES} DESTINATION "${TRANSLATIONS_INSTALL_PATH}")
8888
# Install plugin
8989
install(TARGETS ${PLUGIN_NAME} DESTINATION "${QML_INSTALL_DIR}/${URI_PATH}")
90-
install(DIRECTORY "${PLUGIN_OUTPUT_DIR}/${URI_PATH}/" DESTINATION "${QML_INSTALL_DIR}/${URI_PATH}")
90+
install(FILES "${PLUGIN_OUTPUT_DIR}/${URI_PATH}/qmldir" DESTINATION "${QML_INSTALL_DIR}/${URI_PATH}")

0 commit comments

Comments
 (0)