2

I've got cmake working with a test file similar to " How to start working with GTest and CMake " but the problem is that gtest and the test binary gets built each time I make rather than just when I run make test. And when running make test, only the ctest summary output is shown, not the actual gtest output. How can I change this behaviour so that the tests and gtest library is only built when I run make test, and running make test actually shows the proper output?

Community
  • 1
  • 1
Adam M-W
  • 3,509
  • 9
  • 49
  • 69
  • My bad, should have done more searching... Solution at http://stackoverflow.com/questions/5609692/building-tests-with-cmake-while-not-using-ctest?rq=1 – Adam M-W Sep 12 '12 at 12:22
  • Did you find out how to show the output from gtest instead of or as well as the output from ctest? – rozzy Nov 26 '12 at 12:29
  • 1
    There's two ways of doing it, first is simply not to use test and have a different target like `check` instead that will compile and run the gtest main program, the other is to use a script that will compile each test separately and for ctest to then run each gtest individually, so that `make test` will also work (but will produce CTest-style output rather than `check` which is directly from GTest). To see how I did it, look at https://github.com/adammw/hit3172/blob/case_study/swin-adventure/test/CMakeLists.txt – Adam M-W Nov 26 '12 at 23:08
  • 1
    With Add_executable you can generate .exe(test.exe) file for the gtest test cases . And run the [test.exe --gtest_output=xml:"%CD%\test.xml"] command from command line will generate the gtest output in the xml file. – 123r789 Jan 28 '14 at 11:58

0 Answers0