Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Qt Creator: how to copy files after building?



  • Hello all!

    I am developing static lib and I need to copy files (lib and headers) copy to the defined directory. How to make it?

    I found this https://forum.qt.io/topic/92537/how-can-i-call-shell-script-while-clicking-of-run-button-of-qt/2 and https://stackoverflow.com/questions/6300148/get-qmake-to-execute-shell-script-after-build-finished-on-mac but the problem is how to automate it in case of different builds for different platforms and architectures.

    This code in *.pro file is working perfectly:

    QMAKE_POST_LINK += yes | cp /libSomething.a /path/where/to/copy/
    

    Is there any way to automate it without using *.pro file?



  • @bogong

    You can set directory names through variables. E.g.

    CONFIG(release, debug|release) {
        PACKSOURCE = $$DESTDIR/$$TARGET".*"
        PACKINDIR  = $$PACKBASE/packages/$$MODULNAME
        PACKUPDIR  = $$PACKBASE/packages_update/$$MODULNAME
    
        win32:{
            exists($$system_path($$MyPackageLocation/package.xml)) {
                QMAKE_POST_LINK += && xcopy /I /Y /R $$system_path($$MyPackageLocation/package.xml) $$system_path($$PACKINDIR/meta/)
            }
            QMAKE_POST_LINK += && xcopy /I /Y /R $$system_path($$PACKSOURCE) $$system_path($$PACKINDIR/data/)
            QMAKE_POST_LINK += && dir $$system_path($$PACKINDIR/data/)
            QMAKE_POST_LINK += && del $$system_path($$PACKINDIR/data/*.txt.sik)
    
            exists($$system_path($$MyPackageLocation/package.xml)) {
                QMAKE_POST_LINK += && xcopy /I /Y /R $$system_path($$MyPackageLocation/package.xml) $$system_path($$PACKUPDIR/meta/)
            }
            QMAKE_POST_LINK += && xcopy /I /Y /R $$system_path($$PACKSOURCE) $$system_path($$PACKUPDIR/data/)
            QMAKE_POST_LINK += && dir $$system_path($$PACKUPDIR/data/)
            QMAKE_POST_LINK += && del $$system_path($$PACKUPDIR/data/*.txt.sik)
        }
        linux:{
    # not set yet
        }
    }
    

    That is basically a .pri file I am including in several .pro . The result files are distributed intop a package folder for using installer framework.



  • @koahnig I know it perfectly. The question in my message about "Is there any way to automate it without using *.pro file?"
    Is your way without using *.pro file???


  • Lifetime Qt Champion

    @bogong If you really want to do it without .pro file:

    You can add custom build steps in Creators Projects View: Projects (Ctrl+5) > Build Settings > Build Steps > Add build step.

    Note that this is only for your personal working directory and not meant to be shared.

    Regards



  • @bogong

    Certainly you can type something similar in bat-file.
    Probably also in the cmake file.

    In Qt creator probably you could add a special command for keystrokes, but that would not be automatic.
    I am using still qmake and the .pro file for compilation with Qt creator. Therefore, this is the only way I can think of.



  • I've been seeking kind of plugin for Qt Creator, not writing anything in any files. It seems nothing appeared yet. I am starting new project right now, and there are tradition - at the start line of every new project checking abilities and solutions that will make life easy. For this matter seems nothing new.


  • Lifetime Qt Champion

    @bogong
    Since you ask about something not for qmake.
    What tool do you then use?
    It should offer the same features as qmake.


Log in to reply