Skip to content

GoogleTest: Optimize gtest_discover_tests

Steffen Seckler requested to merge SteffenSeckler/cmake:master into master

gtest_discover_tests took multiple minutes if many tests are present.

This behavior was caused by a repeated addition to the variable script using:

set(script "${script}${NAME}(${_args})\n" PARENT_SCOPE)

in the module file GoogleTestAddTests.cmake

This MR changes the following:

  • The variable script is flushed to ${CTEST_FILE} if the variable becomes too large.
  • The buffer tests_buffer is introduced for the variable tests. This buffer gets flushed into tests once it becomes too large.
  • cmake_minimum_required(VERSION ${CMAKE_VERSION}) is added at the beginning of the script.
  • The usage of set() to append to a string is replaced with string(APPEND ...)

For timing tests see below.

Topic-rename: GoogleTest-optimize

Edited by Brad King

Merge request reports