JDevlieghere created this revision.
JDevlieghere added reviewers: zturner, stella.stamenova, labath, sgraenitz.
Herald added subscribers: lldb-commits, abidh, mgorny.
Herald added a project: LLDB.
Both FindPythonInterp and FindPythonLibs do two things, they'll set some
variables (PYTHON_LIBRARIES, PYTHON_INCLUDE_DIRS) and update the cached
variables (PYTHON_LIBRARY, PYTHON_INCLUDE_DIR) that are also used to specify a
custom python installation.
I believe the canonical way to do this is to use the PYTHON_LIBRARIES and
PYTHON_INCLUDE_DIRS variables instead of the cached ones. However, since the
cached variables are accessible from the cache and GUI, this is a lot less
confusing when you're trying to debug why a variable did or didn't get the
value you expected. Furthermore, as far as I can tell, the implementation uses
the cached variables to set their LIBRARIES/DIRS counterparts. This is also the
reason this works today even though we mix-and-match.
Repository:
rLLDB LLDB
https://reviews.llvm.org/D59968
Files:
lldb/cmake/modules/LLDBConfig.cmake
lldb/scripts/CMakeLists.txt
lldb/scripts/Python/modules/readline/CMakeLists.txt
lldb/source/Utility/CMakeLists.txt
Index: lldb/source/Utility/CMakeLists.txt
===================================================================
--- lldb/source/Utility/CMakeLists.txt
+++ lldb/source/Utility/CMakeLists.txt
@@ -27,7 +27,7 @@
endif()
if (NOT LLDB_DISABLE_PYTHON AND NOT LLVM_BUILD_STATIC)
- list(APPEND LLDB_SYSTEM_LIBS ${PYTHON_LIBRARIES})
+ list(APPEND LLDB_SYSTEM_LIBS ${PYTHON_LIBRARY})
endif()
list(APPEND LLDB_SYSTEM_LIBS ${system_libs})
Index: lldb/scripts/Python/modules/readline/CMakeLists.txt
===================================================================
--- lldb/scripts/Python/modules/readline/CMakeLists.txt
+++ lldb/scripts/Python/modules/readline/CMakeLists.txt
@@ -1,6 +1,5 @@
# FIXME: if a non-standard version of python is requested, the cmake macro
# below will need Python_ADDITIONAL_VERSIONS set in order to find it.
-include(FindPythonInterp)
SET(PYTHON_DIRECTORY python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages)
# Build the readline python module
Index: lldb/scripts/CMakeLists.txt
===================================================================
--- lldb/scripts/CMakeLists.txt
+++ lldb/scripts/CMakeLists.txt
@@ -9,8 +9,6 @@
${LLDB_SOURCE_DIR}/include/lldb/lldb-versioning.h
)
-include(FindPythonInterp)
-
if(LLDB_BUILD_FRAMEWORK)
set(framework_arg --framework --target-platform Darwin)
endif()
Index: lldb/cmake/modules/LLDBConfig.cmake
===================================================================
--- lldb/cmake/modules/LLDBConfig.cmake
+++ lldb/cmake/modules/LLDBConfig.cmake
@@ -135,10 +135,10 @@
return()
endif()
- file(TO_CMAKE_PATH "${PYTHON_HOME}/Include" PYTHON_INCLUDE_DIRS)
+ file(TO_CMAKE_PATH "${PYTHON_HOME}/Include" PYTHON_INCLUDE_DIR)
- if(EXISTS "${PYTHON_INCLUDE_DIRS}/patchlevel.h")
- file(STRINGS "${PYTHON_INCLUDE_DIRS}/patchlevel.h" python_version_str
+ if(EXISTS "${PYTHON_INCLUDE_DIR}/patchlevel.h")
+ file(STRINGS "${PYTHON_INCLUDE_DIR}/patchlevel.h" python_version_str
REGEX "^#define[ \t]+PY_VERSION[ \t]+\"[^\"]+\"")
string(REGEX REPLACE "^#define[ \t]+PY_VERSION[ \t]+\"([^\"+]+)[+]?\".*" "\\1"
PYTHONLIBS_VERSION_STRING "${python_version_str}")
@@ -146,7 +146,7 @@
string(REGEX REPLACE "([0-9]+)[.]([0-9]+)[.][0-9]+" "python\\1\\2" PYTHONLIBS_BASE_NAME "${PYTHONLIBS_VERSION_STRING}")
unset(python_version_str)
else()
- message("Unable to find ${PYTHON_INCLUDE_DIRS}/patchlevel.h, Python installation is corrupt.")
+ message("Unable to find ${PYTHON_INCLUDE_DIR}/patchlevel.h, Python installation is corrupt.")
message("Python support will be disabled for this build.")
set(LLDB_DISABLE_PYTHON 1 PARENT_SCOPE)
return()
@@ -225,12 +225,12 @@
set (PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE} PARENT_SCOPE)
set (PYTHON_LIBRARY ${PYTHON_LIBRARY} PARENT_SCOPE)
set (PYTHON_DLL ${PYTHON_DLL} PARENT_SCOPE)
- set (PYTHON_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS} PARENT_SCOPE)
+ set (PYTHON_INCLUDE_DIR ${PYTHON_INCLUDE_DIR} PARENT_SCOPE)
message("-- LLDB Found PythonExecutable: ${PYTHON_RELEASE_EXE} and ${PYTHON_DEBUG_EXE}")
message("-- LLDB Found PythonLibs: ${PYTHON_RELEASE_LIB} and ${PYTHON_DEBUG_LIB}")
message("-- LLDB Found PythonDLL: ${PYTHON_RELEASE_DLL} and ${PYTHON_DEBUG_DLL}")
- message("-- LLDB Found PythonIncludeDirs: ${PYTHON_INCLUDE_DIRS}")
+ message("-- LLDB Found PythonIncludeDirs: ${PYTHON_INCLUDE_DIR}")
endfunction(find_python_libs_windows)
if (NOT LLDB_DISABLE_PYTHON)
@@ -243,17 +243,19 @@
add_definitions( -DLLDB_PYTHON_HOME="${LLDB_PYTHON_HOME}" )
endif()
else()
- find_package(PythonLibs REQUIRED)
+ include(FindPythonInterp)
+ include(FindPythonLibs)
endif()
-
- if (PYTHON_INCLUDE_DIRS)
- include_directories(${PYTHON_INCLUDE_DIRS})
+
+ if (PYTHON_INCLUDE_DIR)
+ include_directories(${PYTHON_INCLUDE_DIR})
endif()
endif()
if (LLDB_DISABLE_PYTHON)
- unset(PYTHON_INCLUDE_DIRS)
+ unset(PYTHON_INCLUDE_DIR)
unset(PYTHON_LIBRARY)
+ unset(PYTHON_EXECUTABLE)
add_definitions( -DLLDB_DISABLE_PYTHON )
endif()
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits