[Piglit] [PATCH 13/13] cmake: use PythonInterp package and update version.

Kenney Phillis kphillisjr at gmail.com
Thu Oct 31 15:48:09 CET 2013


The find_package(PythonInterp) for cmake version 2.8.6 and newer is
capable of properly handling multiple versions of python. This is
extremely useful on mixed systems where a person may have Python2 and
Python3 installed side by side.
---
 CMakeLists.txt |   27 ++++++++++-----------------
 1 file changed, 10 insertions(+), 17 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b70ae1d..a542f80 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 2.6)
+cmake_minimum_required(VERSION 2.8.6)
 
 list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules")
 
@@ -12,7 +12,8 @@ INCLUDE (FindPkgConfig)
 project (piglit)
 
 find_package(X11)
-
+#Find Python 2.6 interpreter.
+find_package(PythonInterp 2.6 REQUIRED)
 
 option(PIGLIT_BUILD_GL_TESTS "Build tests for OpenGL" ON)
 option(PIGLIT_BUILD_GLES1_TESTS "Build tests for OpenGL ES1" OFF)
@@ -181,22 +182,11 @@ 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.6' <= 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)
+if(NOT PYTHONINTERP_FOUND)
 	message(FATAL_ERROR "python version 2.x (where x >= 6) required")
-endif(NOT DEFINED python)
+endif(NOT PYTHONINTERP_FOUND)
+
+set(python ${PYTHON_EXECUTABLE})
 
 # Check for the presence of several python packages, which are needed to build
 # generated tests.
@@ -208,6 +198,9 @@ execute_process(
 if(NOT import_numpy_error_code EQUAL 0)
 	message(FATAL_ERROR "numpy python module not found")
 endif(NOT import_numpy_error_code EQUAL 0)
+
+# Check for the presence of python packages, which are needed to build
+# html results output.
 execute_process(
 	COMMAND ${python} -c "from mako.template import Template"
 	OUTPUT_QUIET
-- 
1.7.9.5



More information about the Piglit mailing list