Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Using generated QRC file with cmake
Forum Updated to NodeBB v4.3 + New Features

Using generated QRC file with cmake

Scheduled Pinned Locked Moved Solved Installation and Deployment
3 Posts 2 Posters 1.3k 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.
  • A Offline
    A Offline
    alex-zrythm
    wrote on last edited by
    #1

    Hi,

    I'm using Qt6 via cmake and I generate my QRC file using a python script, like below:

    set(out_file "${CMAKE_CURRENT_BINARY_DIR}/resources.qrc")
    add_custom_command(
      OUTPUT ${out_file}
      COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/gen-qt-resources-xml.py
        ${CMAKE_CURRENT_SOURCE_DIR}
        ${CMAKE_CURRENT_SOURCE_DIR}
        ${APPDATA_FILE}
        ${out_file}
      DEPENDS ${ui_files} appdata-xml-merged
      COMMENT "Generating resources.qrc"
    )
    

    Then I do

    qt_add_resources(zrythm "resources"
      FILES ${out_file})
    

    But this doesn't work (I get the error below), and I have no way to tell QT that there is a dependency on the generated file.

    [cmake] CMake Error at /home/alex/opt/Qt6.7.2/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:1758 (message):
    [cmake]   The source file
    [cmake]   '/home/alex/Documents/git/zrythm/builddir_cmake/resources/resources.qrc'
    [cmake]   was specified with an absolute path and is used in a Qt resource.  Please
    [cmake]   set the QT_RESOURCE_ALIAS property on that source file to a relative path
    [cmake]   to make the file properly accessible via the resource system.
    [cmake] Call Stack (most recent call first):
    [cmake]   /home/alex/opt/Qt6.7.2/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:2231 (__qt_get_relative_resource_path_for_file)
    [cmake]   /home/alex/opt/Qt6.7.2/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:337 (_qt_internal_process_resource)
    [cmake]   /home/alex/opt/Qt6.7.2/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:389 (qt6_add_resources)
    [cmake]   resources/CMakeLists.txt:90 (qt_add_resources)
    [cmake] 
    [cmake] 
    [cmake] -- Configuring incomplete, errors occurred!
    

    Is this possible to do at all?

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Why do you want to add a resource file to a Qt resource? Because this is what you're doing - see the documentation.

      You either want qt_add_resources(SOURCES example.qrc) or simply add the generated resource file to your target sources and make sure CMAKE_AUTORCC is on (which should be by default for qt projects iirc).

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      1
      • A Offline
        A Offline
        alex-zrythm
        wrote on last edited by
        #3

        I was indeed using the wrong variant. I'm not sure if that variant works with a generated .qrc file either, but I ended up just globbing the actual files and adding them to the FILES option, since that's what I was basically doing in my python script (I was globbing the files and outputing them in .qrc format). Thanks anyway

        1 Reply Last reply
        0
        • A alex-zrythm has marked this topic as solved on

        • Login

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