CMake FindPythonInterp deprecated
pdv
pdvisschere at edpnet.be
Wed Nov 27 17:09:44 UTC 2019
find_package(PythonInterp ...) is deprecated since CMake 3.12.
With the current master build on MacOS CMake returns
`Python3_EXECUTABLE=Python3.5` although Python3.7 is selected with macports.
Using the recommended find_package(Python3 ...) CMake returns
`Python3_EXECUTABLE=Python3.7`. (patch included)
Patrick
-------------- next part --------------
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 779d9e932d..5b8b215bb2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -786,22 +786,26 @@ if(GNUWIN32_DIR)
list(APPEND CMAKE_PROGRAM_PATH "${GNUWIN32_DIR}/Python" )
endif()
-# Search for python default version first
-unset(PYTHON_EXECUTABLE CACHE)
-unset(LYX_PYTHON_EXECUTABLE CACHE)
-unset(PYTHON_VERSION_MAJOR)
-unset(PYTHON_VERSION_MINOR)
-unset(PYTHON_VERSION_STRING)
-find_package(PythonInterp 3.5 QUIET)
-if(NOT PYTHONINTERP_FOUND)
- unset(PYTHON_EXECUTABLE CACHE)
- 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()
+# Search for python default version if not yet defined
+if(NOT DEFINED LYX_PYTHON_EXECUTABLE)
+ unset(PYTHON_EXECUTABLE CACHE)
+ 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 QUIET)
+ if(NOT PYTHON_VERSION_STRING VERSION_LESS 2.8)
+ message(FATAL_ERROR "Python interpreter found, but is not suitable")
+ else()
+ set(LYX_PYTHON_EXECUTABLE ${Python2_EXECUTABLE} CACHE FILEPATH "Python to be used by LyX")
+ endif()
+ endif()
-set(LYX_PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE} CACHE FILEPATH "Python to be used by LyX")
+ set(LYX_PYTHON_EXECUTABLE ${Python3_EXECUTABLE} CACHE FILEPATH "Python to be used by LyX")
+endif()
if(LYX_NLS)
find_package(LyXGettext)
More information about the lyx-devel
mailing list