Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Learning
  3. Qt in Education
  4. Request professionals to review my CMake configuration (Qt 6.8 QML modular build)
Forum Updated to NodeBB v4.3 + New Features

Request professionals to review my CMake configuration (Qt 6.8 QML modular build)

Scheduled Pinned Locked Moved Unsolved Qt in Education
1 Posts 1 Posters 95 Views
  • 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.
  • L Offline
    L Offline
    Lopher
    wrote last edited by
    #1

    Hello! I have recently systematically studied the content related to QML modular development using CMake under Qt 6.8, and tried to write a set of configurations. To ensure that the project structure is clear, complies with modern CMake specifications, and avoids potential hidden dangers in subsequent maintenance, I hope to invite experienced friends to help review my configuration ideas and implementation details to see if there are any non-standard, optimizable, or missing parts.

    Project structure:

    D:\PROJECT\QT\MODERNTEST
    |   CMakeLists.txt
    |
    \---src
            CMakeLists.txt
            Images.qrc
            main.cpp
            Test.qml
    

    Global CMakeLists.txt:

    cmake_minimum_required(VERSION 3.16)
    
    project(ModernTest VERSION 0.1 LANGUAGES CXX)
    
    set(CMAKE_CXX_STANDARD 17)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    
    set(CMAKE_AUTORCC ON)
    
    find_package(Qt6 6.8 REQUIRED COMPONENTS Quick)
    
    qt_standard_project_setup(REQUIRES 6.8)
    
    add_subdirectory(src)
    
    

    Sub CMakeLists.txt:

    add_executable(${PROJECT_NAME}
        main.cpp
    )
    
    qt_add_qml_module(${PROJECT_NAME}
        URI QMLApp
        VERSION 0.1
        QML_FILES
            Test.qml
        RESOURCES
            Images.qrc
    )
    
    set_target_properties(${PROJECT_NAME} PROPERTIES
        MACOSX_BUNDLE TRUE
        WIN32_EXECUTABLE TRUE
    )
    
    target_link_libraries(${PROJECT_NAME}
        PRIVATE Qt6::Quick
    )
    
    install(TARGETS ${PROJECT_NAME}
        BUNDLE DESTINATION .
        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
        RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
    )
    
    

    main.cpp

    #include <QGuiApplication>
    #include <QQmlApplicationEngine>
    
    int main(int argc, char* argv[]){
        QGuiApplication a(argc,argv);
    
        QQmlApplicationEngine engine;
        engine.loadFromModule("QMLTest","Test");
        return a.exec();
    }
    
    

    The above is the configuration I organized based on what I learned in class and the official manual. To ensure compliance with modern CMake specifications and avoid potential issues, I sincerely ask all experts to kindly offer their advice and check if there are any omissions or "modern" techniques that can be optimized.

    1 Reply Last reply
    0

    • Login

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