]> git.lyx.org Git - features.git/commitdiff
Cmake build: Consider for cmake versions <= 3.12 while searching for python
authorKornel Benko <kornel@lyx.org>
Thu, 28 Nov 2019 20:51:47 +0000 (21:51 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 18 Jun 2020 13:48:46 +0000 (15:48 +0200)
This partially reverts d17dfe6f

CMakeLists.txt

index 52290e8e36d4c352bcc7363def7fb6fadc81483f..12b81a6d6376e5049d7cde97c20ad346ef0cf3dc 100644 (file)
@@ -792,16 +792,27 @@ unset(LYX_PYTHON_EXECUTABLE CACHE)
 unset(PYTHON_VERSION_MAJOR)
 unset(PYTHON_VERSION_MINOR)
 unset(PYTHON_VERSION_STRING)
-find_package(Python3 3.5 QUIET)
-if(NOT Python3_Interpreter_FOUND)
-  unset(PYTHON_EXECUTABLE CACHE)
-  find_package(Python2 2.0 REQUIRED)
-  if(NOT PYTHON_VERSION_STRING VERSION_LESS 2.8)
-    message(FATAL_ERROR "Python interpreter found, but is not suitable")
+if (CMAKE_VERSION VERSION_LESS "3.13")
+  find_package(PythonInterp 3.5 QUIET)
+  if(NOT PYTHONINTERP_FOUND)
+    find_package(PythonInterp 2.0 REQUIRED)
+    if(NOT PYTHON_VERSION_STRING VERSION_LESS 2.8)
+      message(FATAL_ERROR "Python interpreter found, but is not suitable")
+    endif()
   endif()
-  set(LYX_PYTHON_EXECUTABLE ${Python2_EXECUTABLE} CACHE FILEPATH "Python to be used by LyX")
+  set(LYX_PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE} CACHE FILEPATH "Python to be used by LyX")
 else()
-  set(LYX_PYTHON_EXECUTABLE ${Python3_EXECUTABLE} CACHE FILEPATH "Python to be used by LyX")
+  find_package(Python3 3.5 QUIET)
+  if(NOT Python3_Interpreter_FOUND)
+    unset(PYTHON_EXECUTABLE CACHE)
+    find_package(Python2 2.0 REQUIRED)
+    if(NOT PYTHON_VERSION_STRING VERSION_LESS 2.8)
+      message(FATAL_ERROR "Python interpreter found, but is not suitable")
+    endif()
+    set(LYX_PYTHON_EXECUTABLE ${Python2_EXECUTABLE} CACHE FILEPATH "Python to be used by LyX")
+  else()
+    set(LYX_PYTHON_EXECUTABLE ${Python3_EXECUTABLE} CACHE FILEPATH "Python to be used by LyX")
+  endif()
 endif()
 
 if(LYX_NLS)