[Lldb-commits] [lldb] fc6f15d - [lldb/CMake] Only auto-enable Python when SWIG is found
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Tue Jan 7 21:58:54 PST 2020
Author: Jonas Devlieghere
Date: 2020-01-07T21:57:32-08:00
New Revision: fc6f15d4d2c4a051c8e31fe4de0bfaf9d3535f6e
URL: https://github.com/llvm/llvm-project/commit/fc6f15d4d2c4a051c8e31fe4de0bfaf9d3535f6e
DIFF: https://github.com/llvm/llvm-project/commit/fc6f15d4d2c4a051c8e31fe4de0bfaf9d3535f6e.diff
LOG: [lldb/CMake] Only auto-enable Python when SWIG is found
As correctly pointed out by Martin on the mailing list, Python should
only be auto-enabled if SWIG is found as well. This moves the logic of
finding SWIG into FindPythonInterpAndLibs to make that possible.
To make diagnosing easier I've included a status message to convey why
Python support is disabled.
Added:
Modified:
lldb/cmake/modules/FindPythonInterpAndLibs.cmake
lldb/scripts/CMakeLists.txt
Removed:
################################################################################
diff --git a/lldb/cmake/modules/FindPythonInterpAndLibs.cmake b/lldb/cmake/modules/FindPythonInterpAndLibs.cmake
index fcbf0212d72b..858622541015 100644
--- a/lldb/cmake/modules/FindPythonInterpAndLibs.cmake
+++ b/lldb/cmake/modules/FindPythonInterpAndLibs.cmake
@@ -4,40 +4,47 @@
#
# Find the python interpreter and libraries as a whole.
-if(PYTHON_LIBRARIES AND PYTHON_INCLUDE_DIRS AND PYTHON_EXECUTABLE)
+if(PYTHON_LIBRARIES AND PYTHON_INCLUDE_DIRS AND PYTHON_EXECUTABLE AND SWIG_EXECUTABLE)
set(PYTHONINTERPANDLIBS_FOUND TRUE)
else()
- if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
- find_package(Python3 COMPONENTS Interpreter Development QUIET)
- if (Python3_FOUND AND Python3_Interpreter_FOUND)
- set(PYTHON_LIBRARIES ${Python3_LIBRARIES})
- set(PYTHON_INCLUDE_DIRS ${Python3_INCLUDE_DIRS})
- set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
- mark_as_advanced(
- PYTHON_LIBRARIES
- PYTHON_INCLUDE_DIRS
- PYTHON_EXECUTABLE)
- endif()
- else()
- find_package(PythonInterp QUIET)
- find_package(PythonLibs QUIET)
- if(PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND)
- if (NOT CMAKE_CROSSCOMPILING)
- string(REPLACE "." ";" pythonlibs_version_list ${PYTHONLIBS_VERSION_STRING})
- list(GET pythonlibs_version_list 0 pythonlibs_major)
- list(GET pythonlibs_version_list 1 pythonlibs_minor)
+ find_package(SWIG 2.0 QUIET)
+ if (SWIG_FOUND)
+ if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
+ find_package(Python3 COMPONENTS Interpreter Development QUIET)
+ if (Python3_FOUND AND Python3_Interpreter_FOUND)
+ set(PYTHON_LIBRARIES ${Python3_LIBRARIES})
+ set(PYTHON_INCLUDE_DIRS ${Python3_INCLUDE_DIRS})
+ set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
+ mark_as_advanced(
+ PYTHON_LIBRARIES
+ PYTHON_INCLUDE_DIRS
+ PYTHON_EXECUTABLE
+ SWIG_EXECUTABLE)
+ endif()
+ else()
+ find_package(PythonInterp QUIET)
+ find_package(PythonLibs QUIET)
+ if(PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND AND SWIG_FOUND)
+ if (NOT CMAKE_CROSSCOMPILING)
+ string(REPLACE "." ";" pythonlibs_version_list ${PYTHONLIBS_VERSION_STRING})
+ list(GET pythonlibs_version_list 0 pythonlibs_major)
+ list(GET pythonlibs_version_list 1 pythonlibs_minor)
- # Ignore the patch version. Some versions of macOS report a
diff erent
- # patch version for the system provided interpreter and libraries.
- if (CMAKE_CROSSCOMPILING OR (PYTHON_VERSION_MAJOR VERSION_EQUAL pythonlibs_major AND
- PYTHON_VERSION_MINOR VERSION_EQUAL pythonlibs_minor))
- mark_as_advanced(
- PYTHON_LIBRARIES
- PYTHON_INCLUDE_DIRS
- PYTHON_EXECUTABLE)
+ # Ignore the patch version. Some versions of macOS report a
diff erent
+ # patch version for the system provided interpreter and libraries.
+ if (CMAKE_CROSSCOMPILING OR (PYTHON_VERSION_MAJOR VERSION_EQUAL pythonlibs_major AND
+ PYTHON_VERSION_MINOR VERSION_EQUAL pythonlibs_minor))
+ mark_as_advanced(
+ PYTHON_LIBRARIES
+ PYTHON_INCLUDE_DIRS
+ PYTHON_EXECUTABLE
+ SWIG_EXECUTABLE)
+ endif()
endif()
endif()
endif()
+ else()
+ message(STATUS "SWIG 2 or later is required for Python support in LLDB but could not be found")
endif()
include(FindPackageHandleStandardArgs)
@@ -47,5 +54,6 @@ else()
REQUIRED_VARS
PYTHON_LIBRARIES
PYTHON_INCLUDE_DIRS
- PYTHON_EXECUTABLE)
+ PYTHON_EXECUTABLE
+ SWIG_EXECUTABLE)
endif()
diff --git a/lldb/scripts/CMakeLists.txt b/lldb/scripts/CMakeLists.txt
index 8fa4e5f78916..515c63293bc2 100644
--- a/lldb/scripts/CMakeLists.txt
+++ b/lldb/scripts/CMakeLists.txt
@@ -15,12 +15,6 @@ if(LLDB_BUILD_FRAMEWORK)
set(framework_arg --framework --target-platform Darwin)
endif()
-find_package(SWIG REQUIRED)
-set(SWIG_MIN_VERSION "2.0.0")
-if (${SWIG_VERSION} VERSION_LESS ${SWIG_MIN_VERSION})
- message(FATAL_ERROR "LLDB requires swig ${SWIG_MIN_VERSION}, your version is ${SWIG_VERSION}.")
-endif()
-
if(APPLE)
set(DARWIN_EXTRAS "-D__APPLE__")
else()
@@ -38,7 +32,6 @@ set(SWIG_COMMON_FLAGS
-outdir ${CMAKE_CURRENT_BINARY_DIR}
)
-
if (LLDB_ENABLE_PYTHON)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/LLDBWrapPython.cpp
More information about the lldb-commits
mailing list