Search code examples
c++qtdeploymentassetspackaging

How to package large data in a Qt Project?


I'm working on a Qt Project that includes a large data set (70Mb+).

The data will be used by a library that accesses them using the data's path.

I know that I can use resources normally, but since they are in memory objects, I can't use them with the library.

So my question is, how can I package a file or a folder so that it is available at installation/runtime for anyone to access?


Solution

  • So after spending more time with Qt and C++ development in general is that you don't need Qt at all for this functionality.

    What you need is to modify your building process to ship the files you need with the binaries once the building is finished.

    The great news is that this is super simple with cmake.

    Just copy whatever files you want to have available at runtime to the output directory after building the cmake code that does that:

     add_custom_command(TARGET ${PROJECT} POST_BUILD
                       COMMAND ${CMAKE_COMMAND} -E copy_directory
                           ${RES_DIR} $<TARGET_FILE_DIR:${PROJECT}>/RES/)
    

    where PROJECT is the name of the target.

    RES_DIR: full path to resources directory.