mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-24 23:49:18 -06:00
According to the documentation, tests can be discovered for a target multiple times by using a different prefix and/or suffix to ensure name uniqueness. However, while this worked for gtest_add_tests, it did not work with gtest_discover_tests because the generated file that sets up the tests was named based only on the target name, and so subsequent discovery from the same target would clobber earlier discovery. Fix this by introducing a counter that records how many times discovery has been used on a target, and use this to generate unique names of the generated test list files.
24 lines
399 B
CMake
24 lines
399 B
CMake
project(test_include_dirs)
|
|
include(CTest)
|
|
include(GoogleTest)
|
|
|
|
enable_testing()
|
|
|
|
add_executable(fake_gtest fake_gtest.cpp)
|
|
|
|
gtest_discover_tests(
|
|
fake_gtest
|
|
TEST_PREFIX TEST:
|
|
TEST_SUFFIX !1
|
|
EXTRA_ARGS how now "\"brown\" cow"
|
|
PROPERTIES LABELS TEST1
|
|
)
|
|
|
|
gtest_discover_tests(
|
|
fake_gtest
|
|
TEST_PREFIX TEST:
|
|
TEST_SUFFIX !2
|
|
EXTRA_ARGS how now "\"brown\" cow"
|
|
PROPERTIES LABELS TEST2
|
|
)
|