# qt\_add\_resources error

**URL:** https://discourse.cmake.org/t/qt-add-resources-error/7782
**Category:** Usage
**Created:** [March 27, 2023, 11:56pm UTC](https://discourse.cmake.org/t/qt-add-resources-error/7782 "2023-03-27T23:56:10Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![abdelmaged](https://discourse.cmake.org/user_avatar/discourse.cmake.org/abdelmaged/32/3176_2.png) [@abdelmaged](https://discourse.cmake.org/u/abdelmaged)
#### Post date: [March 27, 2023, 11:56pm UTC](https://discourse.cmake.org/t/qt-add-resources-error/7782/1 "2023-03-27T23:56:10Z")

</div>

I’m trying to use CMake macro qt\_add\_resources, and add qrc file that has comments, and it seems this generates rules including the comments as dependencies.

Example:  
resources.qrc

```auto
<!-- WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
     +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     my quoted comment is here "<file>"s after quoted comment
     +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-->
<RCC>
    <qresource prefix="/guiResources">
       <file>fnGettingStarted.txt</file>
<!-- EXAMPLE OF USING FILE ALIAS
       <file alias="bang.svg">images/bangCircleYellow.svg</file>
-->
    </qresource>
</RCC>

```

CMakeLists.txt

```auto
cmake_minimum_required(VERSION 3.18)
project(hello_qrc VERSION 1.0)

find_package(Qt5 REQUIRED COMPONENTS Core Gui)

qt_add_resources(SOURCES resources.qrc)

add_library(lib ${SOURCES})

```

This is the error during cmake --build build -t lib

```auto
ninja: error: '/home/abdelmak/sandbox/cmake/rcc/"s after quoted comment +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->/home/abdelmak/sandbox/cmake/rcc/fnGettingStarted.txt', needed by '/home/abdelmak/sandbox/cmake/rcc/build/qrc_resources.cpp', missing and no known rule to make it

```

If I remove the upper comment and keep the comment at the end, it errors also with

```auto
ninja: error: '/home/abdelmak/sandbox/cmake/rcc/images/bangCircleYellow.svg', needed by '/home/abdelmak/sandbox/cmake/rcc/build/qrc_resources.cpp', missing and no known rule to make it

```

Is this issue in the Qt macro, CMake, or in my input file ?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [April 3, 2023, 11:32am UTC](https://discourse.cmake.org/t/qt-add-resources-error/7782/2 "2023-04-03T11:32:18Z")

</div>

It would seem that `AUTORCC` needs to learn a bit more accurate parsing here indeed… Can you [file an issue](https://gitlab.kitware.com/cmake/cmake/-/issues) please?

---

<div class="post-metadata">

### Author: ![abdelmaged](https://discourse.cmake.org/user_avatar/discourse.cmake.org/abdelmaged/32/3176_2.png) [@abdelmaged](https://discourse.cmake.org/u/abdelmaged)
#### Post date: [April 3, 2023, 11:58pm UTC](https://discourse.cmake.org/t/qt-add-resources-error/7782/3 "2023-04-03T23:58:28Z")

</div>

It seems AUTORCC from CMake works fine.  
I filed this issue [[QTBUG-112496] CMake macro qt\_add\_resource does not handle \<file\> tokens in comments - Qt Bug Tracker](https://bugreports.qt.io/browse/QTBUG-112496).  
It seems the issue in a regexp in qt\_add\_resource macro provided by Qt [Qt6CoreMacros.cmake#L234](https://github.com/qt/qtbase/blob/e7b8b7bfbe6fbcf2ecaccc4c47c09bd34ee26d8c/src/corelib/Qt6CoreMacros.cmake#L234)
