Add a kind of files in CMakeLists.txt
-
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 ... -
You should use relative paths with qt_add_resources
This can be done with theRELATIVEoption infile(GLOB ...). -
R realroot has marked this topic as solved
-
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/appI made a new topic for this.