Reputation: 2764
I am building an application with CMake, which produces libraries and executables, in text mode and GUI mode (Qt5), and out course unit testing. I have the experience, that if I modify any but the test sources, and want to run, CMake builds first new executable(s). If I modify any of the test sources, CMakes runs the old executable immediately, so I need to compile explicitly the new tester before running it. The tests are in a separate subdirectory, the structure is similar to that of the other components, the sources are defined by a
set(MY_SRCS list of individual sources)
Any idea, what could cause that difference? (although it is a nuance).
Upvotes: 0
Views: 43
Reputation: 126
The make test
target generated by CTest only executes the tests you added using add_test()
, it does not build them. As it does not build them, it also does not check for changes in source files.
You can solve this issue by adding a custom target (e.g. make check
) that first builds your tests and then executes them: CMake & CTest : make test doesn't build tests.
Not sure if this answers the question, since you do not specify how you create and execute your unit tests.
Upvotes: 2