Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
    • Help
    • Support
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
CMake
CMake
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
    • Cycle Analytics
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
  • Issues 2,684
    • Issues 2,684
    • List
    • Boards
    • Labels
    • Milestones
  • Merge Requests 21
    • Merge Requests 21
  • Packages
    • Packages
    • Container Registry
  • External Wiki
    • External Wiki
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Commits
  • Issue Boards
  • CMake
  • CMakeCMake
  • Issues
  • #18321

Closed
Open
Opened Sep 03, 2018 by Alessandro Pezzato@alepez
  • Report abuse
  • New issue
Report abuse New issue

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.

Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
0
Labels
None
Assign labels
  • View project labels
Reference: cmake/cmake#18321