QMAKE_POST_LINK runs before linking is complete
-
Within the context of a large SUBDIRS project, I have lots of library projects.
After each library has been built, it needs to be copied to a central libs folder, to be used later by app type projects.The only way I found so far that automatically does something after a project has linked is by using the QMAKE_POST_LINK command. I have seen posts using INSTALL, but that requires someone to manually run 'make install', which I don't know how to do within the context of a SUBDIRS project.
The issue with QMAKE_POST_LINK is that it's command runs before the library is linked. The copy command thus promptly fails, and the build fails. If I remove the QMAKE_POST_LINK, the library links correctly, but of course isn't copied.
Is there a way I can make QMAKE_POST_LINK work?
Alternatively, is there a totally different way that will copy my libraries as each sub-project is built? -
There are several possible ways out of this:
- "DLLDESTDIR":http://qt-project.org/doc/qt-4.8/qmake-variable-reference.html#dlldestdir
- "PRE_TARGETDEPS":http://qt-project.org/doc/qt-4.8/qmake-variable-reference.html#pre-targetdeps
- "SUBDIRS .depends modifier":http://qt-project.org/doc/qt-4.8/qmake-variable-reference.html#subdirs
-
Thanks for your input!
I am already using PRE_TARGETDEPS, but that doesn't change the fact that the libraries are in the wrong folder.
Same goes for the SUBDIRS .depends modifier.
Does DLLDESTDIR also work for static libs (.a-files)?
-
I don't know.
-
No, it doesn't. :-(
Solution:
The command
@QMAKE_POST_LINK += $$QMAKE_COPY $$quote(../bin/$$(HMK_SUPERMODULE_NAME)/$$(HMK_FULLPLATFORM)/) $$quote(../../public/lib/$$(HMK_SUPERMODULE_NAME)/$$(HMK_FULLPLATFORM)/)@seems to work, whereas manually calling the 'cp -r' command doesn't work, even on linux.
-
Hi,
If the libraries don't have anything depending on it, why not just set DESTDIR to point to the common folder ?
-
Because the modules need to compile on their own as well. The modules are compiled and packaged in different ways on different platforms for different purposes. The basic premise is that each module compiles on it's own and creates a static library. Since it cannot depend on any environment, the output must be within the module path.
Only when multiple modules are combined (e.g. using the master project) does it make sense to copy the output to a central path.
This is something I cannot change because it's a team-wide decision. I can only add things that won't break things for anyone else.
-
I supposed it was something like that but it doesn't hurt to ask :)
But then, shouldn't the copy be done a "level upper" so that you don't break the independency of the modules ?
-
The permanent solution for the compile server will use scripts for that. However, for test purposes, it's convenient to have a working subdirs project locally, with all the needed projects in it. And I don't know how to tell qmake or Creator to "execute a script right after the last 'lib' has been built, but before any 'app' is being buiilt".
EDIT:
It only looked like it was solved.
It seems that make creates the static library in a different folder, and only moves it to the DESTDIR in a separate step.
Whether my copy command or the make's move command comes first seems to be a matter of luck. Therefore, in some cases, my copy command cannot copy the actual static lib, because it's not there yet.EDIT2:
The resulting makefile shows this section:
@ @$(CHK_DIR_EXISTS) ../bin/_touchpanel/lux_x86-32_gcc463_d/ || $(MKDIR) ../bin/_touchpanel/lux_x86-32_gcc463_d/
-$(DEL_FILE) $(TARGET)
$(AR) $(TARGET) $(OBJECTS)
cp -f /home/hipase-dev/projects/HIPASE/Baseline/sourcen/turm/bin/_touchpanel/lux_x86-32_gcc463_d/libturm_tp.* ../../public/lib/_touchpanel/lux_x86-32_gcc463_d
-$(DEL_FILE) ../bin/_touchpanel/lux_x86-32_gcc463_d/$(TARGET)
-$(MOVE) $(TARGET) ../bin/_touchpanel/lux_x86-32_gcc463_d/@My 'cp' command is right in the middle, but it should be the last command in this section.