gtest_add_tests fails if any source is empty
include(GoogleTest)
file(GLOB_RECURSE myprojectest_SRC
"${PROJECT_SOURCE_DIR}/src/*_test.cpp"
)
add_executable(myprojecttest ${myprojecttest_SRC})
gtest_add_tests(TARGET myprojectest)
Add some files with tests in src directory: works fine.
Add an empty file. Now cmake failes with obscure errors:
CMake Error at /usr/share/cmake-3.12/Modules/GoogleTest.cmake:311 (string):
string sub-command REGEX, mode MATCHALL needs at least 5 arguments total to
command.
Call Stack (most recent call first):
CMakeLists.txt:125 (gtest_add_tests)
If a source file is empty or doesn't have any test, it shouldn't fail.
Sometimes I (and I guess other developers) add some "placeholder" empty file where future tests have to be created.