summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Berry <stereotype441@gmail.com>2011-08-06 16:26:21 -0700
committerPaul Berry <stereotype441@gmail.com>2011-08-09 10:05:51 -0700
commit7a8d9b00ea8b7611cb3f79b0431a26a691fa3645 (patch)
tree18f59cadc50a22e6a2ffbd041c6b83feeac2c28f
parent15d5588e502e5c4123fff030486a1a3c0217e973 (diff)
Fix test generation on Arch Linux.
On Arch Linux, "python" means Python 3.x, and Python 2.x is called "python2". The test generation code requires Python 2.x. In many other distributions, "python" refers to Python 2.x. This patch adds logic to the toplevel CMakeLists that checks both "python2" and "python" to see which one is Python 2.x, and once it is found, sets the cmake variable ${python} to point to it. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
-rw-r--r--CMakeLists.txt25
-rw-r--r--generated_tests/CMakeLists.txt4
2 files changed, 18 insertions, 11 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7cca31ec..dab4cfdf 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,19 +14,26 @@ find_package(PNG REQUIRED)
find_package(X11)
# Check for presence of Python 2.6 or greater.
-execute_process(
- COMMAND python -c "import sys; assert sys.version >= '2.6'"
- OUTPUT_QUIET
- ERROR_QUIET
- RESULT_VARIABLE python_version_check_error_code)
-if(NOT python_version_check_error_code EQUAL 0)
- message(FATAL_ERROR "python version 2.6 or greater required")
-endif(NOT python_version_check_error_code EQUAL 0)
+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)
+ message(FATAL_ERROR "python version 2.x (where x >= 6) required")
+endif(NOT DEFINED python)
# Check for the presence of numpy, which is needed to build generated
# tests.
execute_process(
- COMMAND python -c "import numpy"
+ COMMAND ${python} -c "import numpy"
OUTPUT_QUIET
ERROR_QUIET
RESULT_VARIABLE import_numpy_error_code)
diff --git a/generated_tests/CMakeLists.txt b/generated_tests/CMakeLists.txt
index 79e2a01f..e3ff3860 100644
--- a/generated_tests/CMakeLists.txt
+++ b/generated_tests/CMakeLists.txt
@@ -3,7 +3,7 @@
set(gen_builtin_uniform
${CMAKE_CURRENT_SOURCE_DIR}/gen_builtin_uniform_tests.py)
execute_process(
- COMMAND python ${gen_builtin_uniform} --names-only
+ COMMAND ${python} ${gen_builtin_uniform} --names-only
OUTPUT_VARIABLE builtin_uniform_tests
RESULT_VARIABLE builtin_uniform_tests_result)
if(NOT builtin_uniform_tests_result EQUAL 0)
@@ -14,7 +14,7 @@ string(REPLACE "\n" ";" builtin_uniform_tests ${builtin_uniform_tests})
# Add a custom command which executes gen_builtin_uniform_tests.py
# during the build.
add_custom_command(OUTPUT ${builtin_uniform_tests}
- COMMAND python ${gen_builtin_uniform}
+ COMMAND ${python} ${gen_builtin_uniform}
DEPENDS gen_builtin_uniform_tests.py builtin_function.py
VERBATIM)