I have a project with the following structure:
linalg
├── build
├── CMakeLists.txt
├── docs
│ └── Doxyfile
├── include
│ └── linalg
│ └── vector3.h
Just to update this.
cmake in version 3.9 added support for GoogleTest integration with CTest.
So you can now get CTest to scrape all of the test macros in your test executable, not just the whole executable.
Example here: https://gist.github.com/johnb003/65982fdc7a1274fdb023b0c68664ebe4
The crux of the problem is that enable_testing
should be called from your top-level CMakeLists.txt in this case. Adding include(CTest) to your top-level CMakeLists.txt should fix this for you.
This would allow you to remove the enable_testing
call in test/CMakeLists.txt, since the CTest submodule calls enable_testing
internally.