<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[CMake and importing QML files]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">I'm trying to figure out a way to have importing work in a more dynamic way than throwing every single .qml file and folder into CMakeLists.txt.</p>
<p dir="auto">Example project structure:</p>
<pre><code>project/
├── src/
│   └── main.cpp
└── ui/
    ├── panels/
    │   └── RoundedPanel.qml
    ├── buttons/
    │   ├── Button.qml
    │   └── RoundedButton.qml
    └── root.qml
</code></pre>
<p dir="auto">Results in:</p>
<pre><code>import ui.panels
RounedPanel {  }

import ui.buttons
Button { }
RoundedButton { }
</code></pre>
<p dir="auto">The catch here is that if at any point I would create new directory in ui and add new .qml there, it should automatically work (even if after build/reconfiguring CMake).</p>
<p dir="auto">So far I only came across <code>qmldir</code> (which didn't even work for me) and <code>qt_add_qml_module</code> but that requires manually adding new qml files.</p>
<p dir="auto">Any suggestions?</p>
]]></description><link>https://forum.qt.io/topic/164453/cmake-and-importing-qml-files</link><generator>RSS for Node</generator><lastBuildDate>Sun, 26 Apr 2026 08:25:49 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/164453.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 19 Mar 2026 07:41:33 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to CMake and importing QML files on Thu, 19 Mar 2026 14:25:21 GMT]]></title><description><![CDATA[<p dir="auto">I believe globbing is supported by CMake but that it is generally recommended not to use it. As a CMake newbie myself I have followed what seemed to be the prevailing wisdom and stuck to hard coded lists.</p>
<p dir="auto">One compromise that I did come across was to read the file list from an external file, e.g., <code>file(STRINGS "sources_list.txt" MYSRCS)</code> and then use the <code>MYSRCS</code> variable as your file list in CMake commands (e.g., <code>add_executable(my_app ${MYSRCS})</code>). This would mean maintaining the "sources_list.txt" file externally but that would be easy to automate. I haven't actually tried this though so take all this with a pinch of salt.</p>
]]></description><link>https://forum.qt.io/post/837186</link><guid isPermaLink="true">https://forum.qt.io/post/837186</guid><dc:creator><![CDATA[Bob64]]></dc:creator><pubDate>Thu, 19 Mar 2026 14:25:21 GMT</pubDate></item></channel></rss>