Merge topic 'FindGTest-depends'

a5d3d003 FindGTest: Automatically re-run cmake when tests change
This commit is contained in:
Brad King 2016-03-16 09:08:03 -04:00 committed by CMake Topic Stage
commit 6e24546cae
2 changed files with 8 additions and 2 deletions

View File

@ -0,0 +1,6 @@
FindGTest-depends
-----------------
* The :module:`FindGTest` module ``gtest_add_tests`` function now causes
CMake to automatically re-run when test sources change so that they
can be re-scanned.

View File

@ -82,8 +82,7 @@
# ``AUTO`` to find them from executable target # ``AUTO`` to find them from executable target
# #
# However, note that this macro will slow down your tests by running # However, note that this macro will slow down your tests by running
# an executable for each test and test fixture. You will also have to # an executable for each test and test fixture.
# re-run CMake after adding or removing tests or test fixtures.
# #
# Example usage:: # Example usage::
# #
@ -119,6 +118,7 @@ function(GTEST_ADD_TESTS executable extra_args)
set(gtest_case_name_regex ".*\\( *([A-Za-z_0-9]+) *, *([A-Za-z_0-9]+) *\\).*") set(gtest_case_name_regex ".*\\( *([A-Za-z_0-9]+) *, *([A-Za-z_0-9]+) *\\).*")
set(gtest_test_type_regex "(TYPED_TEST|TEST_?[FP]?)") set(gtest_test_type_regex "(TYPED_TEST|TEST_?[FP]?)")
foreach(source ${ARGN}) foreach(source ${ARGN})
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${source})
file(READ "${source}" contents) file(READ "${source}" contents)
string(REGEX MATCHALL "${gtest_test_type_regex} *\\(([A-Za-z_0-9 ,]+)\\)" found_tests ${contents}) string(REGEX MATCHALL "${gtest_test_type_regex} *\\(([A-Za-z_0-9 ,]+)\\)" found_tests ${contents})
foreach(hit ${found_tests}) foreach(hit ${found_tests})