[solved] copying/renaming a project
-
wrote on 10 Nov 2011, 22:15 last edited by
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.
-
wrote on 10 Nov 2011, 22:39 last edited by
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
-
wrote on 10 Nov 2011, 22:43 last edited by
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?
-
wrote on 10 Nov 2011, 23:03 last edited by
Can you elaborate on your specific use case?
Why is it you don't like to use the pro file for that? -
wrote on 10 Nov 2011, 23:08 last edited by
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.
-
wrote on 10 Nov 2011, 23:39 last edited by
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.
-
wrote on 10 Nov 2011, 23:42 last edited by
Thanks, Volker. So...if I rename the .pro file, and change the entry for the build directory, am I covered?
-
wrote on 10 Nov 2011, 23:44 last edited by
That should basically work, yes.
-
wrote on 11 Nov 2011, 00:10 last edited by
OK, thanks, guys.
-
wrote on 11 Nov 2011, 00:22 last edited by
Actually, two follow-up questions:
- am I correct in assuming I should rename the .pro.user file, too?
- 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.
-
wrote on 11 Nov 2011, 00:31 last edited by
-
I recommend deleting the .pro.user file - it contains absolute paths that may clutter with the original paths of your copy.
-
If you import a project, select "shadow build" in the wizard that pops up. Creator and/or qmake will create any missing build directories.
-
-
wrote on 11 Nov 2011, 00:38 last edited by
Regarding #2...I just copied the entire project file structure. Should I not have done that? I can't import that way.
-
wrote on 11 Nov 2011, 00:44 last edited by
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).
-
wrote on 11 Nov 2011, 00:49 last edited by
OK, so maybe a recommended procedure (if it's not documented elsewhere, this might help someone later) is:
- copy the directory structure.
- delete the .pro.user file
- change the build directory in Projects->Build
- modify the name of the .pro file if desired (or edit the TARGET tag in the .pro file)
- run qmake
Did I leave anything out?
-
wrote on 11 Nov 2011, 00:50 last edited by
Sounds good to me.
-
wrote on 11 Nov 2011, 00:53 last edited by
Excellent...thanks again.
-
wrote on 11 Nov 2011, 06:48 last edited by
[quote author="mzimmers" date="1320972557"]OK, so maybe a recommended procedure (if it's not documented elsewhere, this might help someone later) is:
- copy the directory structure.
- delete the .pro.user file
- change the build directory in Projects->Build
- modify the name of the .pro file if desired (or edit the TARGET tag in the .pro file)
- run qmake
[/quote]
You could make a doc note / wiki page for that and it will be documented...
-
wrote on 13 Jan 2013, 17:54 last edited by
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"@