0

I've added googletest project to build config(.pro file):

INCLUDEPATH += googletest-dir/googletest
INCLUDEPATH += googletest-dir/googlemock
INCLUDEPATH += googletest-dir/googletest/include
INCLUDEPATH += googletest-dir/googlemock/include

LIBS += -lgtest -Lgoogletest-dir/build/googlemock/gtest
LIBS += -lgmock -Lgoogletest-dir/build/googlemock

SOURCES +=\
...
src/EntryPoint.cpp \
test/unit/UnitTest1.cpp

where both cpp files contains main functions: one for code and other for tests:

EntryPoint.cpp

int main(int argc, char **argv) {
    int returnValue = ERROR_CODE_OK;
...
    pGui->init(argc, argv);
    return returnValue;
}

UnitTest1.cpp

int main(int argc, char** argv) {
  ::testing::InitGoogleMock(&argc, argv);
  //::testing::InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();
}

How to tell project(how to configure qtcreator .pro file) that when i'm making release(make Makefile.release release) i don't need to use 2 main files in build but only EntryPoint.cpp one? And I still need second main for testing purpose in IDE.

Mike Kinghan
  • 55,740
  • 12
  • 153
  • 182
Vyacheslav
  • 3,134
  • 8
  • 28
  • 42
  • This is not how you use goggletest. See http://stackoverflow.com/q/31324930/1362568 and answer. – Mike Kinghan Jun 11 '16 at 16:50
  • I think this is a good decision but it creates another problem for me about configuration of qtcreator .pro file. I accept the solution. I'll ask another question. – Vyacheslav Jun 12 '16 at 15:12

0 Answers0