0

I am working with unit-test and I managed to create two projects in Qt-Creator: a unit-test project and Application project. Compiling both of them separately, I am very happy with both projects.

Then, I managed to link the two projects together, i.e.: testing a class (myClass.cpp) from my Application project using the unit-test project. the link was done by adding:

#INCLUDEPATH myApplicationProjectPath 
#SOURCES myApplicationProjectPath/myClass.cpp

to the .pro file of the unit-test project and everything is working fine and my unit test is functioning. (I am now building a lib instead of adding paths and classes).

In the meanwhile, in the .pro file of the Application project, I am having something like:

#CONFIG(debug, debug|release){
message(Debug bulid)
}

which is a conditional statement to whether compile the code in a Debug or debug|Relase modes.

taking into account that (qmake processes a pro file up to three times depending on what the configuration is set to. Usually it will do it three times. Once for debug, once for release and one final one for debug_and_release.), what if I tried to use #CONFIG in my .pro file of the Application project to add a Test mode. so, when I try to build my project I will have the option to select whether to build in Test, debug or release mode.

doing so will allow me to avoid building separate project for unit-test and just add the classes I need to test within the #SOURCES section within the Test mode option.

so, is it possible to have four ways of building a code (debug, release, debug|release and Test) ?

4

1 回答 1

2

任何属于 的部分CONFIG都可以作为条件的范围进行测试(请参阅:QMake 配置和范围)。这意味着您可以为“测试”添加自己的含义。

例如

以下将在“unittest”添加到 CONFIG 时添加源,使用CONFIG += unittest

unittest {
    SOURCES += my_unittests.cc
}
于 2013-06-05T16:32:26.153 回答