Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Add a kind of files in CMakeLists.txt
Forum Updated to NodeBB v4.3 + New Features

Add a kind of files in CMakeLists.txt

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 65 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.
  • R Offline
    R Offline
    realroot
    wrote last edited by
    #1

    To add all the image files I am trying to use GLOB in CMakeLists.txt:

    file(GLOB IMAGE_FILES "src/resources/images/*.svg")
    
    qt_add_resources(app "images"
        PREFIX "/"
        FILES ${IMAGE_FILES}
    )
    

    It does not compile:

    CMake Error at /usr/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:1886 (message):
    The source file
    '/path/app/src/resources/images/file1.svg' was specified
    with an absolute path and is used in a Qt resource.  Please set the
    QT_RESOURCE_ALIAS property on that source file to a relative path to make
    the file properly accessible via the resource system.
    

    I looked the QT_RESOURCE_ALIAS documentation but I am not sure to how use it.
    Is it normal that I have to or am I doing something wrong?

    Thus at the moment I am specifying all manually:

    FILES
      file1.svg
      file2.svg ...
    
    1 Reply Last reply
    0
    • GrecKoG Offline
      GrecKoG Offline
      GrecKo
      Qt Champions 2018
      wrote last edited by
      #2

      You should use relative paths with qt_add_resources
      This can be done with the RELATIVE option in file(GLOB ...).

      1 Reply Last reply
      2
      • R realroot has marked this topic as solved
      • R Offline
        R Offline
        realroot
        wrote last edited by realroot
        #3

        Now it compiles but it cannot find any files.

        file(GLOB RELATIVE IMAGES_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/resources/images/*.svg")
        
        message(STATUS "Files found: ${IMAGES_FILES}")
        message(STATUS "Current source dir: ${CMAKE_CURRENT_SOURCE_DIR}")
        
        -- Files found: 
        -- Current source dir: /path/app
        

        I made a new topic for this.

        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