title: Using google tests with CMake/Ctest with the new command gtest_discover_tests
body: <p>I am trying to use googletest with CMake/Ctest. I have several sources files for my tests (each one containing many TEST/TEST_F/... commands) which are located in several directories. I want that the tests related to a given source are executed in the same directory as their source file. Also, I prefer that the build process of a test source file is a test by itself. So I made something like:</p>
  
  <pre><code>file(GLOB_RECURSE test_srcs
       RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
       "tests/*.cpp")
  foreach(test_src ${test_srcs}) 
    get_filename_component(test_dir ${test_src} DIRECTORY)
    get_filename_component(test_exe ${test_src} )NAME_WE)
    add_executable(${test_exe} EXCLUDE_FROM_ALL tests/gtest_main.cpp ${test_src})
    set_target_properties(${test_exe}                                       
      PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${test_dir}                                     
      )
    target_link_libraries(${test_exe} gtest)
    add_test(NAME build_${test_exe} COMMAND "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target ${test_exe})
    set_tests_properties(build_${test_exe} PROPERTIES FIXTURES_SETUP ${test_exe})
    gtest_discover_tests(${test_exe}
      TEST_LIST list
      WORKING_DIRECTORY ${test_dir}
      PROPERTIES DEPENDS build_${test_exe}
      PROPERTIES FIXTURES_REQUIRED ${test_exe}
      )
  endforeach()
  </code></pre>
  
  <p>But it seems that the dependencies I am trying to declare between the tests are not taken into account: the build of the tests does not necessarily occurs before the execution of the underlying tests...</p>
  
  <p>If I use the old <code>gtest_add_tests</code> as in the following instead of <code>gtest_discover_tests</code>, it works:</p>
  
  <pre><code>gtest_add_tests(
    TARGET ${test_exe}
    SOURCES ${test_src}
    WORKING_DIRECTORY ${test_dir}
    TEST_LIST tlist
    )
  set_tests_properties(${tlist} PROPERTIES FIXTURES_REQUIRED ${test_exe})
  </code></pre>
  
  <p>Am I missing something with <code>gtest_discover_tests</code>?</p>