]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
cmake: add WITH_GTEST_PARALLEL option
authorKefu Chai <kchai@redhat.com>
Fri, 15 Jun 2018 05:54:31 +0000 (13:54 +0800)
committerErwan Velu <erwan@redhat.com>
Fri, 15 Jun 2018 13:55:15 +0000 (15:55 +0200)
and remove src/test/gtest-parallel submodule, because gtest-parallel is
only useful for running tests. and not all end-users are interested in
running test not to mention running them in parallel. so, to avoid
including gtest-parallel scripts in the dist tarball. it'd be better to
make it optional, and an external project.

Signed-off-by: Kefu Chai <kchai@redhat.com>
cmake/modules/AddCephTest.cmake

index 7442ea922ece6d81e737b2d27983e456d54aab30..d3dc81fc1933e2e0c42c14f35d5e52c4a4b22c38 100644 (file)
@@ -23,12 +23,26 @@ function(add_ceph_test test_name test_path)
     PROPERTY TIMEOUT 3600)
 endfunction()
 
+option(WITH_GTEST_PARALLEL "Enable running gtest based tests in parallel" OFF)
+if(WITH_GTEST_PARALLEL)
+  include(ExternalProject)
+  ExternalProject_Add(gtest-parallel_ext
+    SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/gtest-parallel
+    GIT_REPOSITORY "https://github.com/google/gtest-parallel.git"
+    GIT_TAG "master"
+    CONFIGURE_COMMAND ""
+    BUILD_COMMAND ""
+    INSTALL_COMMAND "")
+  add_dependencies(tests gtest-parallel_ext)
+endif()
+
 #sets uniform compiler flags and link libraries
 function(add_ceph_unittest unittest_name)
   set(UNITTEST "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${unittest_name}")
   # If the second argument is "parallel", it means we want a parallel run
-  if("${ARGV1}" STREQUAL "parallel")
-    set(UNITTEST ${CMAKE_SOURCE_DIR}/src/test/gtest-parallel/gtest-parallel ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${unittest_name})
+  if(WITH_GTEST_PARALLEL AND "${ARGV1}" STREQUAL "parallel")
+    ExternalProject_Get_Property(gtest-parallel_ext source_dir)
+    set(UNITTEST ${source_dir}/gtest-parallel ${UNITTEST})
   endif()
   add_ceph_test(${unittest_name} "${UNITTEST}")
   target_link_libraries(${unittest_name} ${UNITTEST_LIBS})