[Lldb-commits] [lldb] r357282 - [Cmake] Unify python variables
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Fri Mar 29 10:35:42 PDT 2019
Author: jdevlieghere
Date: Fri Mar 29 10:35:42 2019
New Revision: 357282
URL: http://llvm.org/viewvc/llvm-project?rev=357282&view=rev
Log:
[Cmake] Unify python variables
FindPythonInterp and FindPythonLibs do two things, they set some
variables (PYTHON_LIBRARIES, PYTHON_INCLUDE_DIRS) and update the cached
variables (PYTHON_LIBRARY, PYTHON_INCLUDE_DIR) which 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.
Differential revision: https://reviews.llvm.org/D59968
Modified:
lldb/trunk/cmake/modules/LLDBConfig.cmake
lldb/trunk/scripts/CMakeLists.txt
lldb/trunk/source/Utility/CMakeLists.txt
Modified: lldb/trunk/cmake/modules/LLDBConfig.cmake
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/LLDBConfig.cmake?rev=357282&r1=357281&r2=357282&view=diff
==============================================================================
--- lldb/trunk/cmake/modules/LLDBConfig.cmake (original)
+++ lldb/trunk/cmake/modules/LLDBConfig.cmake Fri Mar 29 10:35:42 2019
@@ -135,10 +135,10 @@ function(find_python_libs_windows)
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 @@ function(find_python_libs_windows)
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 @@ function(find_python_libs_windows)
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 @@ if (NOT LLDB_DISABLE_PYTHON)
add_definitions( -DLLDB_PYTHON_HOME="${LLDB_PYTHON_HOME}" )
endif()
else()
- find_package(PythonLibs REQUIRED)
+ find_package(PythonInterp)
+ find_package(PythonLibs)
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()
Modified: lldb/trunk/scripts/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/CMakeLists.txt?rev=357282&r1=357281&r2=357282&view=diff
==============================================================================
--- lldb/trunk/scripts/CMakeLists.txt (original)
+++ lldb/trunk/scripts/CMakeLists.txt Fri Mar 29 10:35:42 2019
@@ -9,8 +9,6 @@ set(SWIG_HEADERS
${LLDB_SOURCE_DIR}/include/lldb/lldb-versioning.h
)
-include(FindPythonInterp)
-
if(LLDB_BUILD_FRAMEWORK)
set(framework_arg --framework --target-platform Darwin)
endif()
Modified: lldb/trunk/source/Utility/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/CMakeLists.txt?rev=357282&r1=357281&r2=357282&view=diff
==============================================================================
--- lldb/trunk/source/Utility/CMakeLists.txt (original)
+++ lldb/trunk/source/Utility/CMakeLists.txt Fri Mar 29 10:35:42 2019
@@ -27,7 +27,7 @@ if(Backtrace_FOUND)
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})
More information about the lldb-commits
mailing list