[Interest] CMake - List Sources: qt_add_executable vs qt_add_qml_module

Mike Trahearn mtrahearn at topcon.com
Tue Jan 30 12:24:30 CET 2024


If your sources are intended to be part of the QML module, that is, available to QML having imported Main_Module, then you should put your sources under the module. If the sources are just assistant to your main.cpp and have no need to be used in QML then they can go under the application.
Sources under the application cannot be published (easily) to QML.

Modularising your application into meaningful modules will help you identify what goes where.

You should also come up with a good module URI dot notation semantic for your modules which will help organise your QML imports statements and source folder structure.

Hope that helps.



________________________________
From: Interest <interest-bounces at qt-project.org> on behalf of ekke <ekke at ekkes-corner.org>
Sent: Tuesday, January 30, 2024 8:05:32 PM
To: interest at qt-project.org <interest at qt-project.org>
Subject: [Interest] CMake - List Sources: qt_add_executable vs qt_add_qml_module

... ported my apps from 5.15 to 6.6, now on my way from QMake to CMake

App is not modularized yet (ToDo for later ;-)
So I only have ONE QML Module directly loaded at start:

main.cpp:
engine.loadFromModule("Main_Module", "Main");

qt_add_executable(my_app
     main.cpp
)

include(my_qml_files.cmake)

qt_add_qml_module(my_app
     URI Main_Module
     QML_FILES ${myqmlfiles}
     ... RESOURCES, SOURCES...
)

I can list all my other cpp SOURCES in qt_add_executable or in
qt_add_qml_module,
what is recommended in this case ?

thx

ekke

_______________________________________________
Interest mailing list
Interest at qt-project.org
https://urldefense.com/v3/__https://lists.qt-project.org/listinfo/interest__;!!Nbma_1s!vTyCh7KPmEoSLiYsVtXS-u3dhKD92sH_Gdwnqwg72sjVpJiJlH4Ec110azEt73oZ8YA7VmofRhx9nsM0$
Confidentiality Notice: This message (including attachments) is a private communication solely for use of the intended recipient(s). If you are not the intended recipient(s) or believe you received this message in error, notify the sender immediately and then delete this message. Any other use, retention, dissemination or copying is prohibited and may be a violation of law, including the Electronic Communication Privacy Act of 1986.   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20240130/393b50d7/attachment.htm>


More information about the Interest mailing list