]> granicus.if.org Git - libevent/commitdiff
cmake: fix finding python2, and check that it is really 2
authorAzat Khuzhin <a3at.mail@gmail.com>
Sun, 30 Oct 2016 08:19:43 +0000 (11:19 +0300)
committerAzat Khuzhin <a3at.mail@gmail.com>
Sun, 30 Oct 2016 23:25:43 +0000 (02:25 +0300)
python version check removed in a4d044c0cd97f68b4b3dde414b83d609719d33d7
("cmake: use PYTHON_EXECUTABLE to find python2"), but in
bcb990ab7cf4921c2c30a1aa4fcb4c0131fffe94 ("cmake/win32: fix running
regress, but fixing finding python2 interpreter") we set
PYTHON_EXECUTABLE only if it exists.

CMakeLists.txt

index ec647fd291231e03b89397eaca7b57bdda6609c8..1b7a36a2ede3e0873f8ef202d4e23503447480b8 100644 (file)
@@ -943,14 +943,18 @@ if (NOT EVENT__DISABLE_TESTS)
     #
     if (NOT EVENT__DISABLE_REGRESS)
 
-        # (We require python to generate the regress tests)
-        find_program(FIND_PYTHON2 python2)
-        if (FIND_PYTHON2)
-            set(PYTHON_EXECUTABLE "python2")
-        endif()
+        # (We require python2 to generate the regress tests)
+        foreach (PY python2.6 python2.7 python2)
+            unset(FIND_PYTHON2 CACHE)
+            find_program(FIND_PYTHON2 ${PY})
+            if (FIND_PYTHON2)
+                set(PYTHON_EXECUTABLE "${PY}")
+                break()
+            endif()
+        endforeach()
         find_package(PythonInterp)
 
-        if (PYTHONINTERP_FOUND)
+        if (PYTHONINTERP_FOUND AND PYTHON_VERSION_STRING VERSION_LESS "3.0.0")
             set(__FOUND_USABLE_PYTHON 1)
         endif()