From 9600aa4557d1494658a45168220e1e97197a48ce Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Thu, 11 Dec 2014 13:28:29 -0800 Subject: cmake: use cmake builtin python module This removes a bunch of code that we rolled for finding python interpreters, and uses the cmake builtins. Signed-off-by: Dylan Baker Reviewed-by: Jose Fonseca --- CMakeLists.txt | 22 +++------------------- cmake/Modules/PiglitFindMako.cmake | 2 +- cmake/piglit_dispatch.cmake | 2 +- generated_tests/CMakeLists.txt | 2 +- 4 files changed, 6 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 301222240..ac4ba1b34 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -187,28 +187,12 @@ IF(PIGLIT_BUILD_GLX_TESTS) pkg_check_modules(GLPROTO REQUIRED glproto) ENDIF() -# Check for presence of Python 2.7 or greater. -foreach(python_cmd python2 python) - execute_process( - COMMAND ${python_cmd} -c "import sys; assert '2.7' <= sys.version < '3'" - OUTPUT_QUIET - ERROR_QUIET - RESULT_VARIABLE python_version_check_error_code) - if(python_version_check_error_code EQUAL 0) - set(python ${python_cmd}) - break() - endif(python_version_check_error_code EQUAL 0) -endforeach(python_cmd) - -if(NOT DEFINED python) - message(FATAL_ERROR "python version 2.7 required") -endif(NOT DEFINED python) - +FIND_PACKAGE(PythonInterp 2.7 REQUIRED) include(PiglitFindMako) # Require numpy execute_process( - COMMAND ${python} -c "import numpy" + COMMAND ${PYTHON_EXECUTABLE} -c "import numpy" OUTPUT_QUIET ERROR_QUIET RESULT_VARIABLE import_numpy_error_code) @@ -507,7 +491,7 @@ set (CPACK_PACKAGE_VERSION_MINOR "0") # Use current date in YYYYMMDD format as patch number execute_process ( - COMMAND ${python} -c "import time, sys; sys.stdout.write(time.strftime('%Y%m%d'))" + COMMAND ${PYTHON_EXECUTABLE} -c "import time, sys; sys.stdout.write(time.strftime('%Y%m%d'))" OUTPUT_VARIABLE CPACK_PACKAGE_VERSION_PATCH ) diff --git a/cmake/Modules/PiglitFindMako.cmake b/cmake/Modules/PiglitFindMako.cmake index eaca60180..0637d30df 100644 --- a/cmake/Modules/PiglitFindMako.cmake +++ b/cmake/Modules/PiglitFindMako.cmake @@ -57,7 +57,7 @@ if(MAKO_VERSION VERSION_LESS MAKO_REQUIRED_VERSION) set(MAKO_VERSION "MAKO_VERSION-NOTFOUND") execute_process( - COMMAND ${python} -c "${__MAKO_CHECK_VERSION_PY}" + COMMAND ${PYTHON_EXECUTABLE} -c "${__MAKO_CHECK_VERSION_PY}" OUTPUT_VARIABLE __MAKO_ACTUAL_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_VARIABLE __MAKO_STDERR diff --git a/cmake/piglit_dispatch.cmake b/cmake/piglit_dispatch.cmake index 93d6a3a2b..f685900ef 100644 --- a/cmake/piglit_dispatch.cmake +++ b/cmake/piglit_dispatch.cmake @@ -43,7 +43,7 @@ set(piglit_dispatch_gen_depends add_custom_command( OUTPUT ${piglit_dispatch_gen_outputs} DEPENDS ${piglit_dispatch_gen_depends} - COMMAND ${python} ${piglit_dispatch_gen_script} --out-dir ${piglit_dispatch_gen_output_dir} + COMMAND ${PYTHON_EXECUTABLE} ${piglit_dispatch_gen_script} --out-dir ${piglit_dispatch_gen_output_dir} ) add_custom_target(piglit_dispatch_gen diff --git a/generated_tests/CMakeLists.txt b/generated_tests/CMakeLists.txt index 57beb3e77..46617a6bd 100644 --- a/generated_tests/CMakeLists.txt +++ b/generated_tests/CMakeLists.txt @@ -13,7 +13,7 @@ function(piglit_make_generated_tests file_list generator_script) # during the build. add_custom_command( OUTPUT ${file_list} - COMMAND ${python} ${CMAKE_CURRENT_SOURCE_DIR}/${generator_script} > ${file_list} + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${generator_script} > ${file_list} DEPENDS ${generator_script} ${ARGN} VERBATIM) endfunction(piglit_make_generated_tests custom_target generator_script) -- cgit v1.2.3