No tests found when using gtest with cmake/ctest

后端 未结 2 656
南笙
南笙 2020-12-16 16:57

I have a project with the following structure:

linalg
├── build
├── CMakeLists.txt
├── docs
│   └── Doxyfile
├── include
│   └── linalg
│       └── vector3.h         


        
相关标签:
2条回答
  • 2020-12-16 17:02

    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

    0 讨论(0)
  • 2020-12-16 17:24

    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.

    0 讨论(0)
提交回复
热议问题