diff options
author | Maximilian Goldstein <max.goldstein@qt.io> | 2020-12-17 16:23:53 +0100 |
---|---|---|
committer | Maximilian Goldstein <max.goldstein@qt.io> | 2021-01-04 13:08:12 +0100 |
commit | d94921d4165b7225918c401041dd58ce2794a35d (patch) | |
tree | 2b4260f3fa6f98f1cbe01e80c81ed12e50b5df7f | |
parent | 5d85844f7bb7a5dbf50afd5355e508b4db3e18cd (diff) |
Implement command for running qmllint on target
Adds qt6_target_enable_qmllint which automatically picks up all QML files
marked for processing by qmlcachegen which then can be checked using a
${TARGETNAME}_qmllint target.
Change-Id: I1d228d3435e6ad2389e9885f55952231c69d38ec
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r-- | src/qml/Qt6QmlMacros.cmake | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/qml/Qt6QmlMacros.cmake b/src/qml/Qt6QmlMacros.cmake index f3fada0d02..d59f1a6a8f 100644 --- a/src/qml/Qt6QmlMacros.cmake +++ b/src/qml/Qt6QmlMacros.cmake @@ -615,7 +615,7 @@ function(qt6_target_qml_files target) endif() endif() - _qt_add_qmllint_command(${target} ${arg_FILES}) + qt6_target_enable_qmllint(${target}) set(file_contents "") foreach(qml_file IN LISTS arg_FILES) @@ -936,6 +936,18 @@ function(_qt_internal_quick_compiler_process_resources target resource_name) endif() list(APPEND resource_files ${file}) endforeach() + + # Create a list of QML files for use with qmllint + if(qml_files) + get_target_property(qml_files_list ${target} QML_FILES) + if(NOT qml_files_list) + set(qml_files_list) + endif() + + list(APPEND qml_files_list ${qml_files}) + set_target_properties(${target} PROPERTIES QML_FILES "${qml_files_list}") + endif() + if (NOT TARGET ${QT_CMAKE_EXPORT_NAMESPACE}::qmlcachegen AND qml_files) message(WARNING "QT6_PROCESS_RESOURCE: Qml files were detected but the qmlcachgen target is not defined. Consider adding QmlTools to your find_package command.") endif() @@ -1217,9 +1229,11 @@ function(_qt_internal_qmldir_defer_file command filepath content) endif() endfunction() -function(_qt_add_qmllint_command target files) +# Adds a target called TARGET_qmllint that runs on all qml files compiled ahead-of-time. +function(qt6_target_enable_qmllint target) get_target_property(target_source ${target} SOURCE_DIR) get_target_property(includes ${target} QML2_IMPORT_PATH) + get_target_property(files ${target} QML_FILES) if(includes) foreach(dir in LISTS includes) |