Skip to content

Commit

Permalink
CMake: Place *_qmllint* targets into a separate FOLDER
Browse files Browse the repository at this point in the history
Set the FOLDER property to *_qmllint* targets to the value of the newly
introduced global property QT_QMLLINTER_TARGETS_FOLDER.  The default
folder name is "QmlLinter".

This only has an effect if USE_FOLDERS is ON and the CMake generator
supports folders.

The all_qmllint is not moved into the QmlLinter folder, because users
might want to trigger it manually.

[ChangeLog][CMake] Introduced the QT_QMLLINTER_TARGETS_FOLDER global
property to specify the name of the FOLDER for qmllint-related targets.

Task-number: QTBUG-99808
Change-Id: I2b89afdeab386507f7c2db17aa011a3b0535f2b4
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
  • Loading branch information
jobor committed Aug 29, 2022
1 parent abfd75e commit 88aef52
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/qml/Qt6QmlMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,15 @@ function(_qt_internal_extend_qml_import_paths import_paths_var)
set(${import_paths_var} ${local_var} PARENT_SCOPE)
endfunction()

function(_qt_internal_assign_to_qmllint_targets_folder target)
get_property(folder_name GLOBAL PROPERTY QT_QMLLINTER_TARGETS_FOLDER)
if("${folder_name}" STREQUAL "")
set(folder_name QmlLinter)
set_property(GLOBAL PROPERTY QT_QMLLINTER_TARGETS_FOLDER ${folder_name})
endif()
set_property(TARGET ${target} PROPERTY FOLDER "${folder_name}")
endfunction()

function(_qt_internal_target_enable_qmllint target)
set(lint_target ${target}_qmllint)
set(lint_target_json ${target}_qmllint_json)
Expand Down Expand Up @@ -808,6 +817,7 @@ function(_qt_internal_target_enable_qmllint target)
$<TARGET_NAME_IF_EXISTS:all_qmltyperegistrations>
WORKING_DIRECTORY "$<TARGET_PROPERTY:${target},SOURCE_DIR>"
)
_qt_internal_assign_to_qmllint_targets_folder(${lint_target})

add_custom_target(${lint_target_json}
COMMAND "$<${have_qmllint_files}:${cmd}>" --json ${CMAKE_BINARY_DIR}/${lint_target}.json
Expand All @@ -818,6 +828,7 @@ function(_qt_internal_target_enable_qmllint target)
$<TARGET_NAME_IF_EXISTS:all_qmltyperegistrations>
WORKING_DIRECTORY "$<TARGET_PROPERTY:${target},SOURCE_DIR>"
)
_qt_internal_assign_to_qmllint_targets_folder(${lint_target_json})

set_target_properties(${lint_target_json} PROPERTIES EXCLUDE_FROM_ALL TRUE)

Expand All @@ -832,7 +843,7 @@ function(_qt_internal_target_enable_qmllint target)
$<TARGET_NAME_IF_EXISTS:all_qmltyperegistrations>
WORKING_DIRECTORY "$<TARGET_PROPERTY:${target},SOURCE_DIR>"
)

_qt_internal_assign_to_qmllint_targets_folder(${lint_target_module})

# Make the global linting target depend on the one we add here.
# Note that the caller is free to change the value of QT_QMLLINT_ALL_TARGET
Expand All @@ -851,6 +862,7 @@ function(_qt_internal_target_enable_qmllint target)
endif()
if(NOT TARGET ${QT_QMLLINT_JSON_ALL_TARGET})
add_custom_target(${QT_QMLLINT_JSON_ALL_TARGET})
_qt_internal_assign_to_qmllint_targets_folder(${QT_QMLLINT_JSON_ALL_TARGET})
endif()
add_dependencies(${QT_QMLLINT_JSON_ALL_TARGET} ${lint_target_json})

Expand All @@ -859,6 +871,7 @@ function(_qt_internal_target_enable_qmllint target)
endif()
if(NOT TARGET ${QT_QMLLINT_MODULE_ALL_TARGET})
add_custom_target(${QT_QMLLINT_MODULE_ALL_TARGET})
_qt_internal_assign_to_qmllint_targets_folder(${QT_QMLLINT_MODULE_ALL_TARGET})
endif()
add_dependencies(${QT_QMLLINT_MODULE_ALL_TARGET} ${lint_target_module})

Expand Down
35 changes: 35 additions & 0 deletions src/qml/doc/src/cmake/cmake-properties.qdoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,41 @@
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only

/*!
\group cmake-global-properties-qtqml
\title CMake Global Properties in Qt6 Qml

\l{CMake Command Reference#Qt6::Qml}{CMake Commands} know about the following
global CMake properties:

\sa{CMake Property Reference}
*/


/*!
\page cmake-global-property-QT_QMLLINTER_TARGETS_FOLDER.html
1\ingroup cmake-properties-qtqml
\ingroup cmake-global-properties-qtqml

\title QT_QMLLLINTER_TARGETS_FOLDER
\target cmake-global-property-QT_QMLLINTER_TARGETS_FOLDER

\brief Sets the FOLDER property for targets that belong to the QML linter.

\cmakepropertysince 6.5
\preliminarycmakeproperty

Name of the \l FOLDER for targets that are related to the QML linter.

By default, this property is set to \c{QmlLinter}.

This property only has an effect if CMake's \l USE_FOLDERS property is \c{ON}.

You can enable folder support by calling
\l{qt6_standard_project_setup}{qt_standard_project_setup}.
*/


/*!
\group cmake-source-file-properties-qtqml
\title CMake Source File Properties in Qt6 Qml
Expand Down

0 comments on commit 88aef52

Please sign in to comment.