summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
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 /CMakeLists.txt
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>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt25
1 files changed, 16 insertions, 9 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7cca31ec3..dab4cfdf7 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)