Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Issue with Qt6 QML Module Target Path and CMake Warning

Issue with Qt6 QML Module Target Path and CMake Warning

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 4 Posters 758 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    Yaldiz
    wrote on last edited by
    #1

    I'm working on a Qt6 project where I'm trying to add multiple QML modules. I am encountering a warning when using the qt_add_qml_module macro for the TelemetorQmlControlsModule target. Here's the warning I'm receiving:

    CMake Warning at /home/hyaldiz/Qt/6.4.2/gcc_64/lib/cmake/Qt6Qml/Qt6QmlMacros.cmake:770 (message):
    The TelemetorQmlControlsModule target is a QML module with target path
    Telemetor/Controls. It uses an OUTPUT_DIRECTORY of
    /home/hyaldiz/Desktop/Personal/Telemetor/build/Desktop_6_4_2-Debug/src/QmlControls,
    which should end in the same target path, but doesn't. Tooling such as
    cmake qmllint may not work correctly.

    Project Setup:
    QmlControls Cmake:
    target_sources(${CMAKE_PROJECT_NAME}
    PRIVATE
    TPalette.hpp
    TPalette.cpp
    QmlGlobal.hpp
    QmlGlobal.cpp
    )

    target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

    qt_add_library(TelemetorQmlControlsModule STATIC)

    set_source_files_properties(ScreenTools.qml
    PROPERTIES
    QT_QML_SINGLETON_TYPE TRUE
    )

    qt_add_qml_module(TelemetorQmlControlsModule
    URI Telemetor.Controls
    VERSION 1.0
    RESOURCE_PREFIX /qml
    QML_FILES
    TMenuBar.qml
    TMenu.qml
    TLabel.qml
    ScreenTools.qml
    NO_PLUGIN
    )

    UI Cmake:
    qt_add_library(MainWindowModule STATIC)

    qt_add_qml_module(MainWindowModule
    URI Telemetor.MainWindow
    VERSION 1.0
    RESOURCE_PREFIX /qml
    QML_FILES
    MainWindow.qml
    NO_PLUGIN
    )

    Src CMake:
    qt_add_library(TelemetorModule STATIC)

    qt_add_qml_module(TelemetorModule
    URI Telemetor
    VERSION 1.0
    RESOURCE_PREFIX /qml
    IMPORTS
    TM
    NO_PLUGIN
    )

    add_subdirectory(UI)
    add_subdirectory(API)
    add_subdirectory(QmlControls)

    target_sources(${CMAKE_PROJECT_NAME}
    PRIVATE
    main.cpp
    Application.hpp
    Application_p.hpp
    Application.cpp
    AppMessages.hpp
    AppMessages.cpp
    )

    target_include_directories(${CMAKE_PROJECT_NAME}
    PRIVATE
    ${CMAKE_CURRENT_SOURCE_DIR})

    target_link_libraries(${CMAKE_PROJECT_NAME}
    PRIVATE
    Qt6::Core
    Qt6::Widgets
    Qt6::Gui
    Qt6::Concurrent
    Qt6::Qml
    Qt6::QmlIntegration
    Qt6::QuickControls2
    Qt6::QuickWidgets
    Qt6::Quick
    MainWindowModule
    TelemetorModule
    TelemetorQmlControlsModule
    #ScreenToolsModule
    )

    set_target_properties(${CMAKE_PROJECT_NAME}
    PROPERTIES
    QT_RESOURCE_PREFIX "/qml"
    OUTPUT_NAME ${CMAKE_PROJECT_NAME}
    )

    Root Cmake:
    cmake_minimum_required(VERSION 3.25)

    list(APPEND CMAKE_MODULE_PATH
    ${CMAKE_SOURCE_DIR}/cmake
    ${CMAKE_SOURCE_DIR}/cmake/modules
    )

    include(Toolchain)
    include(CustomOptions)
    include(Git)

    project(${APP_NAME}
    VERSION ${APP_VERSION}
    DESCRIPTION ${APP_DESCRIPTION}
    LANGUAGES C CXX
    )

    find_package(Qt6
    REQUIRED
    COMPONENTS
    Core
    Gui
    Widgets
    Concurrent
    Qml
    QmlIntegration
    QuickControls2
    QuickWidgets
    Quick
    )

    qt_add_executable(${CMAKE_PROJECT_NAME}
    #RESOURCES
    )

    qt_add_qml_module(${CMAKE_PROJECT_NAME}
    URI TM
    VERSION 1.0
    RESOURCE_PREFIX /qml
    IMPORTS
    QtQuick
    QtQuick.Controls
    QtQuick.Dialogs
    QtQuick.Layouts
    QtQuick.Window
    )

    add_subdirectory(src)

    The Issue:

    • The warning suggests that the OUTPUT_DIRECTORY (/home/hyaldiz/Desktop/Personal/Telemetor/build/Desktop_6_4_2-Debug/src/QmlControls) doesn't match the target path (Telemetor/Controls), which might cause issues with tools like qmllint.

    • Additionally, even though the import statement in MainWindow.qml like import Telemetor.Controls doesn't seem to be recognized by Qt Creator, the code works as expected.

    Question:

    • How can I resolve this warning and make sure the OUTPUT_DIRECTORY ends in the same path as the QML target path?

    • Why is import Telemetor.Controls not being recognized by Qt Creator, even though the code works fine at runtime?
      Any advice on how to fix this issue would be appreciated!

    JKSHJ 1 Reply Last reply
    0
    • Q Offline
      Q Offline
      QtTester
      wrote on last edited by
      #2

      I also want to know, how?

      1 Reply Last reply
      0
      • R Offline
        R Offline
        Redman
        wrote on last edited by
        #3
        CMake Warning at /home/hyaldiz/Qt/6.4.2/gcc_64/lib/cmake/Qt6Qml/Qt6QmlMacros.cmake:770 (message):
        The TelemetorQmlControlsModule target is a QML module with target path
        Telemetor/Controls. It uses an OUTPUT_DIRECTORY of
        /home/hyaldiz/Desktop/Personal/Telemetor/build/Desktop_6_4_2-Debug/src/QmlControls,
        

        The path in which your plugin is located inside your project structure ends with QmlControls.
        You must adjust it to be Telemetor/Controls.

        1 Reply Last reply
        1
        • Y Yaldiz

          I'm working on a Qt6 project where I'm trying to add multiple QML modules. I am encountering a warning when using the qt_add_qml_module macro for the TelemetorQmlControlsModule target. Here's the warning I'm receiving:

          CMake Warning at /home/hyaldiz/Qt/6.4.2/gcc_64/lib/cmake/Qt6Qml/Qt6QmlMacros.cmake:770 (message):
          The TelemetorQmlControlsModule target is a QML module with target path
          Telemetor/Controls. It uses an OUTPUT_DIRECTORY of
          /home/hyaldiz/Desktop/Personal/Telemetor/build/Desktop_6_4_2-Debug/src/QmlControls,
          which should end in the same target path, but doesn't. Tooling such as
          cmake qmllint may not work correctly.

          Project Setup:
          QmlControls Cmake:
          target_sources(${CMAKE_PROJECT_NAME}
          PRIVATE
          TPalette.hpp
          TPalette.cpp
          QmlGlobal.hpp
          QmlGlobal.cpp
          )

          target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

          qt_add_library(TelemetorQmlControlsModule STATIC)

          set_source_files_properties(ScreenTools.qml
          PROPERTIES
          QT_QML_SINGLETON_TYPE TRUE
          )

          qt_add_qml_module(TelemetorQmlControlsModule
          URI Telemetor.Controls
          VERSION 1.0
          RESOURCE_PREFIX /qml
          QML_FILES
          TMenuBar.qml
          TMenu.qml
          TLabel.qml
          ScreenTools.qml
          NO_PLUGIN
          )

          UI Cmake:
          qt_add_library(MainWindowModule STATIC)

          qt_add_qml_module(MainWindowModule
          URI Telemetor.MainWindow
          VERSION 1.0
          RESOURCE_PREFIX /qml
          QML_FILES
          MainWindow.qml
          NO_PLUGIN
          )

          Src CMake:
          qt_add_library(TelemetorModule STATIC)

          qt_add_qml_module(TelemetorModule
          URI Telemetor
          VERSION 1.0
          RESOURCE_PREFIX /qml
          IMPORTS
          TM
          NO_PLUGIN
          )

          add_subdirectory(UI)
          add_subdirectory(API)
          add_subdirectory(QmlControls)

          target_sources(${CMAKE_PROJECT_NAME}
          PRIVATE
          main.cpp
          Application.hpp
          Application_p.hpp
          Application.cpp
          AppMessages.hpp
          AppMessages.cpp
          )

          target_include_directories(${CMAKE_PROJECT_NAME}
          PRIVATE
          ${CMAKE_CURRENT_SOURCE_DIR})

          target_link_libraries(${CMAKE_PROJECT_NAME}
          PRIVATE
          Qt6::Core
          Qt6::Widgets
          Qt6::Gui
          Qt6::Concurrent
          Qt6::Qml
          Qt6::QmlIntegration
          Qt6::QuickControls2
          Qt6::QuickWidgets
          Qt6::Quick
          MainWindowModule
          TelemetorModule
          TelemetorQmlControlsModule
          #ScreenToolsModule
          )

          set_target_properties(${CMAKE_PROJECT_NAME}
          PROPERTIES
          QT_RESOURCE_PREFIX "/qml"
          OUTPUT_NAME ${CMAKE_PROJECT_NAME}
          )

          Root Cmake:
          cmake_minimum_required(VERSION 3.25)

          list(APPEND CMAKE_MODULE_PATH
          ${CMAKE_SOURCE_DIR}/cmake
          ${CMAKE_SOURCE_DIR}/cmake/modules
          )

          include(Toolchain)
          include(CustomOptions)
          include(Git)

          project(${APP_NAME}
          VERSION ${APP_VERSION}
          DESCRIPTION ${APP_DESCRIPTION}
          LANGUAGES C CXX
          )

          find_package(Qt6
          REQUIRED
          COMPONENTS
          Core
          Gui
          Widgets
          Concurrent
          Qml
          QmlIntegration
          QuickControls2
          QuickWidgets
          Quick
          )

          qt_add_executable(${CMAKE_PROJECT_NAME}
          #RESOURCES
          )

          qt_add_qml_module(${CMAKE_PROJECT_NAME}
          URI TM
          VERSION 1.0
          RESOURCE_PREFIX /qml
          IMPORTS
          QtQuick
          QtQuick.Controls
          QtQuick.Dialogs
          QtQuick.Layouts
          QtQuick.Window
          )

          add_subdirectory(src)

          The Issue:

          • The warning suggests that the OUTPUT_DIRECTORY (/home/hyaldiz/Desktop/Personal/Telemetor/build/Desktop_6_4_2-Debug/src/QmlControls) doesn't match the target path (Telemetor/Controls), which might cause issues with tools like qmllint.

          • Additionally, even though the import statement in MainWindow.qml like import Telemetor.Controls doesn't seem to be recognized by Qt Creator, the code works as expected.

          Question:

          • How can I resolve this warning and make sure the OUTPUT_DIRECTORY ends in the same path as the QML target path?

          • Why is import Telemetor.Controls not being recognized by Qt Creator, even though the code works fine at runtime?
            Any advice on how to fix this issue would be appreciated!

          JKSHJ Offline
          JKSHJ Offline
          JKSH
          Moderators
          wrote on last edited by
          #4

          @Yaldiz said in Issue with Qt6 QML Module Target Path and CMake Warning:

          How can I resolve this warning and make sure the OUTPUT_DIRECTORY ends in the same path as the QML target path?

          By ensuring that your source files' path matches the URI. For example, if the URI is Telemetor.Controls then the source path should be like ${CMAKE_SOURCE_DIR}/Telemotor/Controls/TMenuBar.qml

          Why is import Telemetor.Controls not being recognized by Qt Creator, even though the code works fine at runtime?

          Because the runtime engine loads the modules from the resource files that are embedded inside your executable -- these have the correct paths. However, Qt Creator cannot see the files that are embedded inside your executable, so it must load them from disk.

          So if you get the warning that OUTPUT_DIRECTORY doesn't match the target path, that means Qt Creator won't be able to find the files at the expected paths on disk.

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved