I've a project with following files
TestProject/api/apiheader1.h
TestProject/api/apiheader2.h
TestProject/src/apiimplementaton.cpp
TestProject/inc/apiimplementation.h
TestProject/TestProject.pro
When the project TestProject.pro is built headers apiheader1.h, apiheader2.h needs to be copied to /usr/include/TestLib/. Is it possible to do this by specifying it in project file TestProject.pro.?
Any pointers / links will be helpful.
You can add this to the pro file... in qmake you can add extra targets...The copyheaders will get run once the target is built..
QMAKE_EXTRA_TARGETS += copyheaders
POST_TARGETDEPS += copyheaders
copyheaders.commands += mkdir -p /usr/include/TestlLib
copyheaders.commands += cp -f PATH_TO_HEADERS/apiheader1.h /usr/include/TestLib
copyheaders.commands += cp -f PATH_TO_HEADERS/apiheader2.h /usr/include/TestLib
Are you sure that you want to move the files? Moving source files around feels wrong.
As for doing it using qmake, you can use the system() function to simply cp the files in question. http://pepper.troll.no/s60prereleases/doc/qmake-function-reference.html#system-command
Related
Suppose I have a test.pro file with content as followings
unix {
inspro.path = /tmp
inspro.files += test.pro
}
!isEmpty(inspro.path) INSTALLS += inspro
unix {
insdoc.path = /tmp
insdoc.files += test.txt
}
!isEmpty(insdoc.path) INSTALLS += insdoc
Running qmake test.pro results in a Makefile. The file, test.pro, exists already, and the created Makefile contains install_inspro and uninstall_inspro for the file test.pro:
install_inspro: first FORCE
#test -d $(INSTALL_ROOT)/tmp || mkdir -p $(INSTALL_ROOT)/tmp
$(QINSTALL) /home/jianz/test/pro/test.pro $(INSTALL_ROOT)/tmp/test.pro
uninstall_inspro: FORCE
-$(DEL_FILE) -r $(INSTALL_ROOT)/tmp/test.pro
-$(DEL_DIR) $(INSTALL_ROOT)/tmp/
However, corresponding install_insdoc and install_insdoc are created if and only if the file test.txt exists.
In the case that the file test.txt is created as part of QMAKE_POST_LINK, is there a way to force qmake to create install_insdoc and uninstall_insdoc?
I think there's a custom install target CONFIG directive to help with this. Add:
insdoc.CONFIG += no_check_exist
Documented at https://doc.qt.io/qt-5/qmake-variable-reference.html#installs
More details and caveats at https://wiki.qt.io/Undocumented_QMake#Custom_install_config
Related Q/A: qmake copy files created while building
In my pro file I do somthing like:
QMAKE_POST_LINK += $$QMAKE_COPY $$quote($$PWD/*.xml) $$quote($$OUT_PWD) $$escape_expand(\\n\\t)
To copy files into the target area ready for deployment. This could be a default config file or some other resource.
When I build the code this works fine, the file is copied. However if I then modify the the config file (lets just call is config.xml) and re-build then since no source files are changed, the build returns "nothing to do ..." and therefore there is no post-linker stage and my updated config.xml file is not copied to the target area.
So to test my changes I have to modify a source file and then re-build... its a bit annoying and when I forget it often causes a few minutes of wasted time...
I'm not sure if I understood well what you want to achieve, but is it something like this (from my personal project)?
unix:!macx {
LIBS += -ltag -L$$OUT_PWD/../Core/ -lmiam-core
target.path = /usr/bin
desktop.path = /usr/share/applications
desktop.files = $$PWD/../../debian/usr/share/applications/miam-player.desktop
icon64.path = /usr/share/icons/hicolor/64x64/apps
icon64.files = $$PWD/../../debian/usr/share/icons/hicolor/64x64 /apps/application-x-miamplayer.png
appdata.path = /usr/share/appdata
appdata.files = $$PWD/../../fedora/miam-player.appdata.xml
INSTALLS += desktop \
target \
icon64 \
appdata
}
So when you do:
qmake
make
make install
The install target will execute the 4 parts in INSTALL.
Edit: you can also add extra build steps in QtCreator:
I'm using Qt 5.1.1 and running qmake on windows.
I run qmake with the following command:
qmake.exe -spec win32-msvc2012 -tp vc project.pro
Somehow in my makefile it generates some weird relative paths:
INCPATH = -I"..\..\..\qt\qwt-6.1.0\src"
for example.
My includepaths in the .pro file are the following:
INCLUDEPATH += \
$$PWD \
$$QWTDIR \
what did I do wrong? (The compiler searches for ......\ which it isn't allowed to access for sure)
qwtdir is defined as:
QWTDIR = C:/qt/qwt-6.1.0/src
I resolved the error. Someone committed corrupted .pri file which didn't contain a proper line break after an include i.e.:
HEADERS += \
$$PWD/file1.h \ $$PWD/file2.h
Adding a proper line break solved the issue.
INCLUDEPATH += $$PWD is most likely unnecessary.
Your $$QWTDIR is relative, most likely - you'd need to relent and show it to us. Use $$absolute_path($${QWTDIR}).
You could also probably put the include paths all on one line. The trailing line continuation in the last line of INCLUDEPATH is wrong, you must remove it:
INCLUDEPATH += \
$$PWD \
$$QWTDIR
You are trying to build against the source tree of Qwt ( probably copying the project files of the Qwt examples ) instead of installing Qwt properly and building against the installed version using:
CONFIG += qwt
See http://qwt.sourceforge.net/qwtinstall.html
Is there a way to use the .pro file in Qt to call another Makefile? For example, in a makefile, you could use:
make -f /other/path/Makefile
Is there anything like using the pro file for Qt?
Something like this should work:
QMAKE_EXTRA_TARGETS += other
PRE_TARGETDEPS += other
other.commands = make -f /other/path/Makefile
this will cause make -f /other/path/Makefile to be called as part of the make process, and will also give you the ability to type make other to just run that command.
I have a building environment where I add some prepending and appending lines to each Makefile generated.
It would be nice if I could put this lines into the qmake generated file via my project file (.pro).
Of cause I can do this via some easy shell scripting but it would be much nicer to do it from inside of the project file. Is there any qmake command to use?
Does anyone have any idea how to do this?
Example:
include $(ROOT)/prepend.mk
$(LIB):$(OBJ)
#echo ...
include $(ROOT)/append.mk
Customizing Makefile Output
.pro file:
QMAKE_EXTRA_TARGETS += extra_target
extra_target.commands = #echo Hello, World
Run qmake.
Run make extra_target:
Hello, World
See the documentation for additional options.