6

What may be the reason that CMake target RUN_TESTS was not generated in Visual Studio 2015? I can't include the complete CMakeLists.txt as it is huge and consists of many subprojects with own CMakeLists.txt, but it contains enable_testing() command executed, tests are added and built, there is simply no predefined target. Other predefined targets like: ZERO_CHECK, INSTALL, ALL_BUILD are there. My cmake execution is:

cmake -C conaninitialcache.cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=Debug <source_path>

Could it be the Conan's fault?

Piotr G
  • 959
  • 1
  • 7
  • 25
  • Does your CMakeLists.txt contains a `enable_testing()` command? Otherwise no target `RUN_TESTS` is created in the Visual Studio solution. – vre May 25 '20 at 10:49
  • Where is the `enable_testing()` command located within your CMake project? – Kevin May 25 '20 at 14:35

1 Answers1

6

It turns out, that when having a project with subprojects, enable_testing() must be located in the root CMakeLists.txt, not in the subprojects, since as the documentation says:

This command should be in the source directory root because ctest expects to find a test file in the build directory root.

https://cmake.org/cmake/help/latest/command/enable_testing.html

Piotr G
  • 959
  • 1
  • 7
  • 25