I updated to using the CMAKE_CONFIGURE_DEPENDS.  I have attached a patch
that has both commits in it.  Let me know if there are any other issues.

Zak

On Mon, Mar 14, 2016 at 10:58 AM, Brad King <[email protected]> wrote:

> On 03/11/2016 12:00 PM, Zak Eckert wrote:
> > + configure_file(${source} ${source}.out COPYONLY)
>
> Thanks.  Please try using CMAKE_CONFIGURE_DEPENDS instead:
>
>   https://cmake.org/cmake/help/v3.5/prop_dir/CMAKE_CONFIGURE_DEPENDS.html
>
> It should be something like:
>
>   set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${source})
>
> Thanks,
> -Brad
>
>
From 34114d973372f3380b6aed29c62a6e47f6642546 Mon Sep 17 00:00:00 2001
From: GodricSeer <[email protected]>
Date: Fri, 11 Mar 2016 11:23:32 -0500
Subject: [PATCH 1/2] Eliminated need to rerun cmake when changing tests

By configuring each test source file with COPYONLY this adds a dependency between the make target rebuild_cache and all of the test source files parsed by gtest_add_tests.  Now whenever those files are changed, cmake will automatically rerun to include any new/remove any deleted tests.
---
 Modules/FindGTest.cmake |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Modules/FindGTest.cmake b/Modules/FindGTest.cmake
index ca49e4a..9f5ddbe 100644
--- a/Modules/FindGTest.cmake
+++ b/Modules/FindGTest.cmake
@@ -82,8 +82,7 @@
 #   ``AUTO`` to find them from executable target
 #
 # 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
-# re-run CMake after adding or removing tests or test fixtures.
+# an executable for each test and test fixture.
 #
 # 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_test_type_regex "(TYPED_TEST|TEST_?[FP]?)")
     foreach(source ${ARGN})
+        configure_file(${source} ${source}.out COPYONLY)
         file(READ "${source}" contents)
         string(REGEX MATCHALL "${gtest_test_type_regex} *\\(([A-Za-z_0-9 ,]+)\\)" found_tests ${contents})
         foreach(hit ${found_tests})
-- 
1.7.1


From 9eaa569f0190d353bd695029b2491e05988b60eb Mon Sep 17 00:00:00 2001
From: Zak Eckert <[email protected]>
Date: Tue, 15 Mar 2016 14:50:27 -0400
Subject: [PATCH 2/2] Updated to use CMAKE_CONFIGURE_DEPENDS

Changed from using configure_file to force cmake to rebuild on a file
change to adding the source to the CMAKE_CONFIGURE_DEPENDS, which avoids
the copying of the file.
---
 Modules/FindGTest.cmake |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/Modules/FindGTest.cmake b/Modules/FindGTest.cmake
index 9f5ddbe..29ca3e3 100644
--- a/Modules/FindGTest.cmake
+++ b/Modules/FindGTest.cmake
@@ -118,7 +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_test_type_regex "(TYPED_TEST|TEST_?[FP]?)")
     foreach(source ${ARGN})
-        configure_file(${source} ${source}.out COPYONLY)
+	set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${source})
         file(READ "${source}" contents)
         string(REGEX MATCHALL "${gtest_test_type_regex} *\\(([A-Za-z_0-9 ,]+)\\)" found_tests ${contents})
         foreach(hit ${found_tests})
-- 
1.7.1

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Reply via email to