From 423ca5764e0c2f063a7c8245608f92588cbb71f3 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sat, 7 Jul 2018 17:10:23 +0800 Subject: [PATCH] cmake: find python2 interpreter for gtest-parallel gtest-parallel only supports python2 at this moment, so find it a python2 interpreter if it is enabled. Signed-off-by: Kefu Chai --- cmake/modules/AddCephTest.cmake | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cmake/modules/AddCephTest.cmake b/cmake/modules/AddCephTest.cmake index d3dc81fc1933e..c48155b3bb77e 100644 --- a/cmake/modules/AddCephTest.cmake +++ b/cmake/modules/AddCephTest.cmake @@ -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}) -- 2.39.5