Hi all!

Im working on a project with some sort of TDD approach, so im relaying a lot on unittesting. I have decided to have several folders (subprojects) for each module, and a subproject that has subprojects inside, for each unittest.
It looks something like:

trunk/
module1/
unittest/ --> here's the class with the testcases. its make sense to have all code related with the module in one place
module2/
unittest/
tests/
module1/
module2/


On each module folder, i have the classes and a folder where i store the unittest cases. Then there's the tests folder that performs the actual compilation and linking of each unittest. This is all bascially to have compilation of modules separated from unittests. Each module compiles as a static library which is then linked in each unittest.

The .pro of each unittest in the tests/ folder, looks like:

Qt Code:
  1. QT += testlib
  2. QT -= gui
  3.  
  4. TARGET = Module1Test
  5. TEMPLATE = app
  6.  
  7. CONFIG += console
  8. CONFIG -= app_bundle
  9.  
  10. MOC_DIR = ./
  11. OBJECTS_DIR = ./
  12. DESTDIR = ./
  13.  
  14. INCLUDEPATH += . ../../module1/unittest
  15.  
  16. SOURCES = \
  17. ../../module1/unittest/someTest.cpp
  18.  
  19. LIBS += -lmodule1
To copy to clipboard, switch view to plain text mode 

Everything is working fine, but i need to manually compile the module first and then compile and run the unittest, so it links to the updated module library. I find this very annyoing and i'd like a way to launch compilation of any module, and once done, automatically launches compilation of the unittests and runs them.
Another approach would be that when i launch compilation of a particular unittest, it would first compile the module and then the unittest test (because we need to have the static library updated before compiling the unittest).

I could have the unittest use the module's files and compile them everytime, but i dont like the idea of having to maintain the list of files on both de module.pro and the unittest.pro. Thats way i choose to link the unittest to the module's static library.

I've doing some googling, checking on QMake docs, but i cant find a solution to my problem. I saw the PRE_TARGETDEPS qmake var, but it doesnt seem to work, because if i modify the module, the static library doesnt get compiled again. I've also seen the QMAKE_POST_LINK, but that only solves the issue of launching the unittest when the compilation is done.

I hope someone can help with this.

Thanks!