[Lldb-commits] [PATCH] D65230: [CMake] Loosen Python version check and ignore patch version

Jonas Devlieghere via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Jul 24 10:43:44 PDT 2019


JDevlieghere created this revision.
JDevlieghere added reviewers: shafik, arphaman, sgraenitz, davide.
JDevlieghere added a project: LLDB.
Herald added subscribers: dexonsmith, mgorny.

Some versions of macOS report a different patch version for the system provided interpreter and libraries.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D65230

Files:
  lldb/cmake/modules/LLDBConfig.cmake


Index: lldb/cmake/modules/LLDBConfig.cmake
===================================================================
--- lldb/cmake/modules/LLDBConfig.cmake
+++ lldb/cmake/modules/LLDBConfig.cmake
@@ -199,9 +199,24 @@
     find_package(PythonLibs REQUIRED)
   endif()
 
-  if (NOT PYTHON_VERSION_STRING VERSION_EQUAL PYTHONLIBS_VERSION_STRING AND
-      NOT CMAKE_CROSSCOMPILING)
-    message(FATAL_ERROR "Found incompatible Python interpreter (${PYTHON_VERSION_STRING}) and Python libraries (${PYTHONLIBS_VERSION_STRING})")
+  if (NOT CMAKE_CROSSCOMPILING)
+    # Manually split PYTHON_VERSION_STRING because find_python_libs_windows
+    # doesn't set PYTHON_VERSION_MAJOR or PYTHON_VERSION_MINOR. Use the LLDB
+    # prefix to not shadow the actual variables.
+    string(REPLACE "." ";" PYTHON_VERSION_LIST ${PYTHON_VERSION_STRING})
+    string(REPLACE "." ";" PYTHONLIBS_VERSION_LIST ${PYTHONLIBS_VERSION_STRING})
+    list(GET PYTHON_VERSION_LIST 0 LLDB_PYTHON_MAJOR)
+    list(GET PYTHON_VERSION_LIST 1 LLDB_PYTHON_MINOR)
+    list(GET PYTHONLIBS_VERSION_LIST 0 LLDB_PYTHONLIBS_MAJOR)
+    list(GET PYTHONLIBS_VERSION_LIST 1 LLDB_PYTHONLIBS_MINOR)
+
+    # Ignore the patch version. Some versions of macOS report a different patch
+    # version for the system provided interpreter and libraries.
+    if (NOT LLDB_PYTHON_MAJOR VERSION_EQUAL LLDB_PYTHONLIBS_MAJOR OR
+        NOT LLDB_PYTHON_MINOR VERSION_EQUAL LLDB_PYTHONLIBS_MINOR)
+      message(FATAL_ERROR "Found incompatible Python interpreter (${LLDB_PYTHON_MAJOR}.${LLDB_PYTHON_MINOR})"
+                          " and Python libraries (${LLDB_PYTHONLIBS_MAJOR}.${LLDB_PYTHONLIBS_MINOR})")
+    endif()
   endif()
 
   if (PYTHON_INCLUDE_DIR)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65230.211559.patch
Type: text/x-patch
Size: 1704 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190724/9b78d20f/attachment-0001.bin>


More information about the lldb-commits mailing list