diff options
-rw-r--r-- | src/qml/CMakeLists.txt | 27 | ||||
-rw-r--r-- | src/qml/Qt6QmlProperties.cmake | 26 |
2 files changed, 52 insertions, 1 deletions
diff --git a/src/qml/CMakeLists.txt b/src/qml/CMakeLists.txt index 2d327caf77..1063b42e96 100644 --- a/src/qml/CMakeLists.txt +++ b/src/qml/CMakeLists.txt @@ -2,7 +2,7 @@ # SPDX-License-Identifier: BSD-3-Clause include(Qt6QmlBuildInternals.cmake) - +include(Qt6QmlProperties.cmake) ##################################################################### ## Qml Module: ##################################################################### @@ -438,10 +438,12 @@ qt_internal_add_qml_module(Qml "${CMAKE_CURRENT_LIST_DIR}/${INSTALL_CMAKE_NAMESPACE}QmltcFileMappingTemplate.qrc.in" "${CMAKE_CURRENT_LIST_DIR}/${INSTALL_CMAKE_NAMESPACE}QmlPublicCMakeHelpers.cmake" "${CMAKE_CURRENT_LIST_DIR}/${INSTALL_CMAKE_NAMESPACE}UpdateQmllsIni.cmake" + "${CMAKE_CURRENT_LIST_DIR}/${INSTALL_CMAKE_NAMESPACE}QmlProperties.cmake" ${extra_cmake_files} EXTRA_CMAKE_INCLUDES "${INSTALL_CMAKE_NAMESPACE}QmlFindQmlscInternal.cmake" "${INSTALL_CMAKE_NAMESPACE}QmlPublicCMakeHelpers.cmake" + "${INSTALL_CMAKE_NAMESPACE}QmlProperties.cmake" ${extra_cmake_includes} POLICIES QTP0001 @@ -623,6 +625,25 @@ qt_internal_extend_target(Qml CONDITION GCC AND QT_COMPILER_VERSION_MAJOR STREQU -fno-strict-aliasing ) +if(ANDROID) + string(JOIN "" application_type_condition + "$<STREQUAL:$<TARGET_PROPERTY:_qt_android_target_type>,APPLICATION>" + ) +else() + string(JOIN "" application_type_condition + "$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>" + ) +endif() + +string(JOIN "" qt_qml_debug_definition + "$<$<AND:" + "${application_type_condition}," + "$<BOOL:$<TARGET_PROPERTY:QT_ENABLE_QML_DEBUG>>" + ">:" + "QT_QML_DEBUG" + ">" +) + qt_internal_extend_target(Qml CONDITION QT_FEATURE_qml_debug SOURCES debugger/qqmlabstractprofileradapter.cpp debugger/qqmlabstractprofileradapter_p.h @@ -641,6 +662,10 @@ qt_internal_extend_target(Qml CONDITION QT_FEATURE_qml_debug jsruntime/qv4profiling.cpp ) +if(QT_FEATURE_qml_debug) + target_compile_definitions(Qml INTERFACE "${qt_qml_debug_definition}") +endif() + qt_internal_extend_target(Qml CONDITION UNIX SOURCES jsruntime/qv4compilationunitmapper_unix.cpp diff --git a/src/qml/Qt6QmlProperties.cmake b/src/qml/Qt6QmlProperties.cmake new file mode 100644 index 0000000000..4758d59cb4 --- /dev/null +++ b/src/qml/Qt6QmlProperties.cmake @@ -0,0 +1,26 @@ +# Copyright (C) 2025 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.23") + set(_qt_qml_debug_extra_args + INITIALIZE_FROM_VARIABLE + QT_ENABLE_QML_DEBUG + ) +elseif(DEFINED QT_ENABLE_QML_DEBUG) + message(WARNING "QT_ENABLE_QML_DEBUG is set to ${QT_ENABLE_QML_DEBUG}," + " but the variable is not supported by this CMake version. Please set the" + " QT_ENABLE_QML_DEBUG target property where is required.") +endif() + +define_property(TARGET + PROPERTY + QT_ENABLE_QML_DEBUG + BRIEF_DOCS + "Enables QML debugging for the specific target" + FULL_DOCS + "The property controls the QT_ENABLE_QML_DEBUG definition for the respective QML module. + The property is only applicable for Qt QML module applications." + ${_qt_qml_debug_extra_args} +) + +unset(_qt_qml_debug_extra_args) |