diff options
author | Nikolay Orliuk <virkony@gmail.com> | 2014-02-26 12:47:38 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2014-02-27 13:52:18 (GMT) |
commit | c50325b8e55e55306fbf8bca38128303b82a51a9 (patch) | |
tree | 53d22d877ad91d3b2812ab9bec8a4791112b7955 /Modules | |
parent | 6e6fbb0e436889c93bb64930fda51a1ef32326ae (diff) | |
download | CMake-c50325b8e55e55306fbf8bca38128303b82a51a9.zip CMake-c50325b8e55e55306fbf8bca38128303b82a51a9.tar.gz CMake-c50325b8e55e55306fbf8bca38128303b82a51a9.tar.bz2 |
FindGTest: Optionally detect sources automatically (#14775)
Teach GTEST_ADD_TESTS an "AUTO" option to read the source files from the
SOURCES target property of an executable.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/FindGTest.cmake | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Modules/FindGTest.cmake b/Modules/FindGTest.cmake index c00a750..aa3c235 100644 --- a/Modules/FindGTest.cmake +++ b/Modules/FindGTest.cmake @@ -79,7 +79,7 @@ # extra_args = Pass a list of extra arguments to be passed to # executable enclosed in quotes (or "" for none) # ARGN = A list of source files to search for tests & test -# fixtures. +# fixtures. Or AUTO to find them from executable target. # # # @@ -88,7 +88,7 @@ # Example: # set(FooTestArgs --foo 1 --bar 2) # add_executable(FooTest FooUnitTest.cc) -# GTEST_ADD_TESTS(FooTest "${FooTestArgs}" FooUnitTest.cc) +# GTEST_ADD_TESTS(FooTest "${FooTestArgs}" AUTO) #============================================================================= # Copyright 2009 Kitware, Inc. @@ -111,6 +111,10 @@ function(GTEST_ADD_TESTS executable extra_args) if(NOT ARGN) message(FATAL_ERROR "Missing ARGN: Read the documentation for GTEST_ADD_TESTS") endif() + if(ARGN STREQUAL "AUTO") + # obtain sources used for building that executable + get_property(ARGN TARGET ${executable} PROPERTY SOURCES) + endif() foreach(source ${ARGN}) file(READ "${source}" contents) string(REGEX MATCHALL "TEST_?F?\\(([A-Za-z_0-9 ,]+)\\)" found_tests ${contents}) |