[solved] copying/renaming a project



  • Hi -

    Before I go off and clobber anything, I thought I'd ask here: is there a guide (or cheat sheet or anything) to renaming projects and/or copying them? I want to use one project as the basis for another. This will entail modifying pathnames, names of of the finished program and so on.

    I already know that I'll need to change the build directory in Projects->Build. How do I go about renaming the executable...is that done by renaming the .pro file?

    Thanks.



  • bq. How do I go about renaming the executable…is that done by renaming the .pro file?

    Have a look at "target":http://doc.qt.nokia.com/4.7/qmake-variable-reference.html#target



  • The "target" entry in my profile is blank. So, I guess it picked it up from the directory name, huh?

    Assuming I'm right, can I change it without putting an entry in the .pro file?



  • Can you elaborate on your specific use case?
    Why is it you don't like to use the pro file for that?



  • Oh, I don't necessarily mind using the .pro file. It's just that since it was apparently built without an entry there, I was wondering whether I could preserve the way that the executable was named. Mostly for academic curiosity.

    Anyway, if I go ahead and change the .pro file, and the build directory, is that it? Or is there more that I'll need to do? There are no absolute pathnames in any of my code.



  • In case the TARGET variable is empty, the name of the executable is the name of your .pro file without the .pro extension (and maybe appended with .app on the mac).

    If you set the TARGET variable, that will be the name of the executable.



  • Thanks, Volker. So...if I rename the .pro file, and change the entry for the build directory, am I covered?



  • That should basically work, yes.



  • OK, thanks, guys.



  • Actually, two follow-up questions:

    1. am I correct in assuming I should rename the .pro.user file, too?
    2. what's the best way to get Creator to make me a build directory? Or will this happen for me automatically, like when I create a new project?

    Thanks.



    1. I recommend deleting the .pro.user file - it contains absolute paths that may clutter with the original paths of your copy.

    2. If you import a project, select "shadow build" in the wizard that pops up. Creator and/or qmake will create any missing build directories.



  • Regarding #2...I just copied the entire project file structure. Should I not have done that? I can't import that way.



  • Oh, no problem with that. I do that regularly :-) Just make sure to not re-use the .pro.user file. If you open the .pro files in Creator the project wizards start over. This ensures that your paths are not messed up with the old project (original copy).



  • OK, so maybe a recommended procedure (if it's not documented elsewhere, this might help someone later) is:

    1. copy the directory structure.
    2. delete the .pro.user file
    3. change the build directory in Projects->Build
    4. modify the name of the .pro file if desired (or edit the TARGET tag in the .pro file)
    5. run qmake

    Did I leave anything out?



  • Sounds good to me.



  • Excellent...thanks again.



  • [quote author="mzimmers" date="1320972557"]OK, so maybe a recommended procedure (if it's not documented elsewhere, this might help someone later) is:

    1. copy the directory structure.
    2. delete the .pro.user file
    3. change the build directory in Projects->Build
    4. modify the name of the .pro file if desired (or edit the TARGET tag in the .pro file)
    5. run qmake

    [/quote]

    You could make a doc note / wiki page for that and it will be documented...



  • Run this script in the folder where your project is located. It will fix rename the files and change their contents accordingly.

    @#!/bin/bash
    echo "old: $1", "new: $2"

    rename "s/$1/$2/" *
    cd $2
    rename "s/$1/$2/" *
    find $NEW -type f -exec sed -i "s/$1/$2/g" {} ;

    echo "Done"@


Log in to reply