adding a build step for CxxTest [SOLVED]



  • I am new to qmake and am starting to set up a large project (~400 sub-projects). We use CxxTest as a unit test framework.

    Our convention is that there is a unit_test.h file for any unit test program to be built, that may include other unit_test*.h files. A main program, test_gen.cpp, is generated from the unit_test.h with a script cxxtestgen.pl.

    I've read the documentation, but I'm not sure I understand how to define the build step for generating the main program, and I don't understand how to make sure the main program object is dependent on all the unit_test*.h test files.

    Here's as much as I understand how to set up the build step (I'm making the main program be unit_test.cpp, same base name as the header file):

    cxxtest.output = ${QMAKE_FILE_BASE}.cpp
    cxxtest.commands = cxxtestgen.pl -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_NAME}
    cxxtest = CXXTEST_HEADERS
    QMAKE_EXTRA_COMPILERS += cxxtest
    

    I was thinking of making this definition a cxxtest qmake feature. Can anyone tell me if I am close with the setup?

    I don't understand what to do to make sure the generated cpp is dependent on all the unit_test*.h files. Can anyone lend advice?



  • I had problems with adding an extra compile step. It was easier to use an extra make target. What I came up with was a .pro file like the following:

    ### BEGIN setup for CxxTest test program
    TEMPLATE = app
    
    TARGET = test_runner
    
    cxxtest.target = test_runner.cpp
    cxxtest.commands = $$PWD/../../../third_party/cxxtest/cxxtestgen.pl \
      --error-printer --have-eh --have-std --abort-on-fail \
      -o test_runner.cpp $$PWD/unit_test.h
    cxxtest.depends = $$PWD/unit_test.h
    
    QMAKE_EXTRA_TARGETS += cxxtest
    
    HEADERS += unit_test*.h
    
    SOURCES += $$OUT_PWD/test_runner.cpp
    
    INCLUDEPATH += $$PWD/../../../third_party/cxxtest
    DEPENDPATH += $$PWD/../../../third_party/cxxtest
    ### END setup for CxxTest test program
    
    ### library dependencies, including for code under test, go here
    


Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.