5 # Find the python interpreter and libraries as a whole.
8 # Use PYTHON_HOME as a hint to find Python 3.
9 set(Python3_ROOT_DIR "${PYTHON_HOME}")
10 find_package(Python3 COMPONENTS Interpreter Development)
11 if(Python3_FOUND AND Python3_Interpreter_FOUND)
13 # The install name for the Python 3 framework in Xcode is relative to
14 # the framework's location and not the dylib itself.
16 # @rpath/Python3.framework/Versions/3.x/Python3
18 # This means that we need to compute the path to the Python3.framework
19 # and use that as the RPATH instead of the usual dylib's directory.
21 # The check below shouldn't match Homebrew's Python framework as it is
22 # called Python.framework instead of Python3.framework.
23 if (APPLE AND Python3_LIBRARIES MATCHES "Python3.framework")
24 string(FIND "${Python3_LIBRARIES}" "Python3.framework" python_framework_pos)
25 string(SUBSTRING "${Python3_LIBRARIES}" "0" ${python_framework_pos} Python3_RPATH)
28 set(PYTHON3_FOUND TRUE)
37 if(Python3_LIBRARIES AND Python3_INCLUDE_DIRS AND Python3_EXECUTABLE AND LLDB_ENABLE_SWIG)
38 set(PYTHONANDSWIG_FOUND TRUE)
43 message(STATUS "SWIG 3 or later is required for Python support in LLDB but could not be found")
46 get_property(MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
47 if ("${Python3_VERSION}" VERSION_GREATER_EQUAL "3.7" AND
48 "${SWIG_VERSION}" VERSION_LESS "4.0" AND WIN32 AND (
49 ${MULTI_CONFIG} OR (uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")))
50 # Technically this can happen with non-Windows builds too, but we are not
51 # able to detect whether Python was built with assertions, and only Windows
52 # has the requirement that Debug LLDB must use Debug Python.
53 message(WARNING "Debug builds of LLDB are likely to be unusable due to "
54 "<https://github.com/swig/swig/issues/1321>. Please use SWIG >= 4.0.")
57 include(FindPackageHandleStandardArgs)
58 find_package_handle_standard_args(PythonAndSwig