[Piglit] [Patch v2 1/3] CMake: use cmake builtin python module

Dylan Baker baker.dylan.c at gmail.com
Mon Dec 15 10:56:46 PST 2014


This removes a bunch of code that we rolled for finding python
interpreters, and uses the cmake builtins.

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 CMakeLists.txt                     | 23 ++++-------------------
 cmake/Modules/PiglitFindMako.cmake |  2 +-
 cmake/piglit_dispatch.cmake        |  2 +-
 generated_tests/CMakeLists.txt     |  2 +-
 4 files changed, 7 insertions(+), 22 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2f15971..ba48ea7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -171,28 +171,13 @@ IF(PIGLIT_BUILD_GLX_TESTS)
 	pkg_check_modules(GLPROTO REQUIRED glproto)
 ENDIF()
 
-# Check for presence of Python 2.6 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.x (where x >= 6) required")
-endif(NOT DEFINED python)
-
+# Check for presence of Python 2.7 or greater.
+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)
@@ -491,7 +476,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 eaca601..0637d30 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 93d6a3a..f685900 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 6c8eaf9..8e7b02a 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)
-- 
2.2.0



More information about the Piglit mailing list