QtCreator. Pro file. Target file path relative to the *.pro file path.
-
Can I set in the *.pro file the specific target file path relative to the *.pro file path and independent of the build directory? And Can I get in this target directory only executable file and no any *.ilk, *.pdb and other intermediate files?
There is some "DESTDIR ":http://qt-project.org/doc/qt-5/qmake-variable-reference.html#destdir parameter:
"Specifies where to put the target file."So I've created file "myProject/myProject.pro" which includes "DESTDIR = bin", opened "myProject.pro" in the QtCreator, set "build directories" as "myProject/Debug" and "myProject/Release", build project....
And I expected that myProject.exe (target file, one file, not files) was created as myProject/bin/myProject.exe.
But QtCreator has build exe file as myProject/Debug/bin/myProject.exe (it relatives to the build directory) and put to this dest directory a lot of intermediate files (*.ilk, *.pdb and etc.)
myProject/myProject.pro:
@
QT += core guigreaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = myProject
DESTDIR = bin
TEMPLATE = appSOURCES += main.cpp
mainwindow.cppHEADERS += mainwindow.h
FORMS += mainwindow.ui
@And I
-
Turn off shadow building in Qt Creator, or run qmake from the command line.
-
[quote author="sierdzio" date="1395836448"]Turn off shadow building in Qt Creator, or run qmake from the command line.[/quote]
It looks good! The executable file is placed in the needed directory.
But what is about intermediate files (*.ilk, *.pdb, *.manifest, *.rc and etc.)? Can I replaced them to build directory? -
Of course!
See how I usually do it ("source":https://github.com/sierdzio/spdr/blob/master/definitions.pri):
@
BUILDDIR = $$PWD/buildOBJECTS_DIR = $${BUILDDIR}
MOC_DIR = $${BUILDDIR}
RCC_DIR = $${BUILDDIR}
UI_DIR = $${BUILDDIR}
@This will put pretty much everything in build directory.
Things that will still be put elsewhere:
- Makefile generated by qmake (can be changed by specifying the Makefile path by hand, IIRC the variable was QMAKE_MAKEFILE)
- some Android-specific files (if you are building for android)
-
An one more question - how to turn off shadow building in the *.pro file?
-
[quote author="_Dima" date="1395837256"]An one more question - how to turn off shadow building in the *.pro file?[/quote]
Sadly, I have no answer here... I would love to be able to do it myself, but I don't know how.
I think I saw somebody mention that you can achieve this by using a .pro.share file, but I have not tried this.
What you can do is to turn off shadow building globally in Qt Creator: go to settings, Build & Run and set this as the Default build directory: . (just a dot :)).
-
[quote author="sierdzio" date="1395837432"][quote author="_Dima" date="1395837256"]An one more question - how to turn off shadow building in the *.pro file?[/quote]
Sadly, I have no answer here... I would love to be able to do it myself, but I don't know how.
I think I saw somebody mention that you can achieve this by using a .pro.share file, but I have not tried this.
What you can do is to turn off shadow building globally in Qt Creator: go to settings, Build & Run and set this as the Default build directory: . (just a dot :)).[/quote]
Thank for your help!
I have to keep all project settings only in the pro file (or in the some additional config files). This file (pro) is placed in the source control system and many programmers use it. I cannot force them to set any project settings (specific build directory, shadow build and etc.) in the QtCreator.
Good solution is setting of all parameters in the *.pro file.
-
Sorry I cannot get PWD to work...
Could you please advise how to copy only target file (myProject.exe) from the build directory to the specific directory after linking?
For example using of the QMAKE_POST_LINK.
I means something like this:
@
BUILDDIR = $${DESTDIR}
QMAKE_POST_LINK +=$$quote(cmd /c copy /y $${BUILDDIR}$${FILE} ../$${FILE})
@