Copy a file to build directory after compiling project with Qt

后端 未结 6 1794
孤街浪徒
孤街浪徒 2020-12-13 06:36

I have seen several suggestions, but nothing really worked for me as I want. I just need to copy a file to the desired destination directory.

Say, for example from t

6条回答
  •  无人及你
    2020-12-13 07:12

    The selected answer is correct but it requires to call make install, which in my opinion is annoying or error prone. Instead, to copy files to the build directory use:

    copydata.commands = $(COPY_DIR) $$PWD/required_files $$OUT_PWD
    first.depends = $(first) copydata
    export(first.depends)
    export(copydata.commands)
    QMAKE_EXTRA_TARGETS += first copydata
    

    Where required_files must be replaced with your correct path. $$PWD is the path of current .pro file, you might not require this.

    Note: I found this solution here. I recommend to read the whole article as it explains how it works.

提交回复
热议问题