]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: find python2 interpreter for gtest-parallel 22931/head
authorKefu Chai <kchai@redhat.com>
Sat, 7 Jul 2018 09:10:23 +0000 (17:10 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 9 Jul 2018 13:09:18 +0000 (21:09 +0800)
gtest-parallel only supports python2 at this moment, so find it
a python2 interpreter if it is enabled.

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

index d3dc81fc1933e2e0c42c14f35d5e52c4a4b22c38..c48155b3bb77e8280847f34335647bf114be4279 100644 (file)
@@ -25,15 +25,19 @@ endfunction()
 
 option(WITH_GTEST_PARALLEL "Enable running gtest based tests in parallel" OFF)
 if(WITH_GTEST_PARALLEL)
+  set(gtest_parallel_source_dir ${CMAKE_CURRENT_BINARY_DIR}/gtest-parallel)
   include(ExternalProject)
   ExternalProject_Add(gtest-parallel_ext
-    SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/gtest-parallel
+    SOURCE_DIR "${gtest_parallel_source_dir}"
     GIT_REPOSITORY "https://github.com/google/gtest-parallel.git"
     GIT_TAG "master"
     CONFIGURE_COMMAND ""
     BUILD_COMMAND ""
     INSTALL_COMMAND "")
   add_dependencies(tests gtest-parallel_ext)
+  find_package(PythonInterp 2.7 REQUIRED)
+  set(GTEST_PARALLEL_COMMAND
+    ${PYTHON_EXECUTABLE} ${gtest_parallel_source_dir}/gtest-parallel)
 endif()
 
 #sets uniform compiler flags and link libraries
@@ -41,8 +45,7 @@ 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(WITH_GTEST_PARALLEL AND "${ARGV1}" STREQUAL "parallel")
-    ExternalProject_Get_Property(gtest-parallel_ext source_dir)
-    set(UNITTEST ${source_dir}/gtest-parallel ${UNITTEST})
+    set(UNITTEST ${GTEST_PARALLEL_COMMAND} ${UNITTEST})
   endif()
   add_ceph_test(${unittest_name} "${UNITTEST}")
   target_link_libraries(${unittest_name} ${UNITTEST_LIBS})