2020-01-07 00:49:36 +08:00
|
|
|
#.rst:
|
2020-08-17 23:47:52 +08:00
|
|
|
# FindPythonAndSwig
|
2020-01-07 00:49:36 +08:00
|
|
|
# -----------
|
|
|
|
#
|
|
|
|
# Find the python interpreter and libraries as a whole.
|
|
|
|
|
2020-06-10 05:09:42 +08:00
|
|
|
macro(FindPython3)
|
|
|
|
# Use PYTHON_HOME as a hint to find Python 3.
|
|
|
|
set(Python3_ROOT_DIR "${PYTHON_HOME}")
|
|
|
|
find_package(Python3 COMPONENTS Interpreter Development)
|
|
|
|
if(Python3_FOUND AND Python3_Interpreter_FOUND)
|
|
|
|
|
|
|
|
# The install name for the Python 3 framework in Xcode is relative to
|
|
|
|
# the framework's location and not the dylib itself.
|
|
|
|
#
|
|
|
|
# @rpath/Python3.framework/Versions/3.x/Python3
|
|
|
|
#
|
|
|
|
# This means that we need to compute the path to the Python3.framework
|
|
|
|
# and use that as the RPATH instead of the usual dylib's directory.
|
|
|
|
#
|
|
|
|
# The check below shouldn't match Homebrew's Python framework as it is
|
|
|
|
# called Python.framework instead of Python3.framework.
|
|
|
|
if (APPLE AND Python3_LIBRARIES MATCHES "Python3.framework")
|
|
|
|
string(FIND "${Python3_LIBRARIES}" "Python3.framework" python_framework_pos)
|
2020-08-17 23:47:52 +08:00
|
|
|
string(SUBSTRING "${Python3_LIBRARIES}" "0" ${python_framework_pos} Python3_RPATH)
|
2020-06-10 05:09:42 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
set(PYTHON3_FOUND TRUE)
|
|
|
|
mark_as_advanced(
|
2020-08-17 23:47:52 +08:00
|
|
|
Python3_LIBRARIES
|
|
|
|
Python3_INCLUDE_DIRS
|
|
|
|
Python3_EXECUTABLE
|
|
|
|
Python3_RPATH
|
2020-06-10 05:09:42 +08:00
|
|
|
SWIG_EXECUTABLE)
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2020-08-17 23:47:52 +08:00
|
|
|
if(Python3_LIBRARIES AND Python3_INCLUDE_DIRS AND Python3_EXECUTABLE AND SWIG_EXECUTABLE)
|
|
|
|
set(PYTHONANDSWIG_FOUND TRUE)
|
2020-01-07 00:49:36 +08:00
|
|
|
else()
|
[lldb/cmake] Enable more verbose find_package output.
Summary:
The purpose of this patch is to make identifying missing dependencies clearer to the user.
`find_package` will report if a package is not found, that output, combined with the exiting
status message, is clearer than not having the additional verbosity.
If the SWIG dependency is required {LLDB_ENABLE_PYTHON, LLDB_ENABLE_LUA}
and SWIG is not available, fail the configuration step. Terminate the
configure early rather than later with a clear error message.
We could possibly modify:
`llvm-project/lldb/cmake/modules/FindPythonInterpAndLibs.cmake`
However, the patch here seems clear in my opinion.
Reviewers: aadsm, hhb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: labath, jrm, mgorny, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D74917
2020-02-22 02:33:35 +08:00
|
|
|
find_package(SWIG 2.0)
|
2020-01-08 13:53:33 +08:00
|
|
|
if (SWIG_FOUND)
|
2020-07-28 03:30:09 +08:00
|
|
|
FindPython3()
|
2020-01-08 13:53:33 +08:00
|
|
|
else()
|
|
|
|
message(STATUS "SWIG 2 or later is required for Python support in LLDB but could not be found")
|
2020-01-07 00:49:36 +08:00
|
|
|
endif()
|
|
|
|
|
2020-10-07 22:36:32 +08:00
|
|
|
get_property(MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
|
|
|
if ("${Python3_VERSION}" VERSION_GREATER_EQUAL "3.7" AND
|
|
|
|
"${SWIG_VERSION}" VERSION_LESS "4.0" AND WIN32 AND (
|
2020-10-21 22:23:54 +08:00
|
|
|
${MULTI_CONFIG} OR (uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")))
|
2020-10-07 22:36:32 +08:00
|
|
|
# Technically this can happen with non-Windows builds too, but we are not
|
|
|
|
# able to detect whether Python was built with assertions, and only Windows
|
|
|
|
# has the requirement that Debug LLDB must use Debug Python.
|
|
|
|
message(WARNING "Debug builds of LLDB are likely to be unusable due to "
|
|
|
|
"<https://github.com/swig/swig/issues/1321>. Please use SWIG >= 4.0.")
|
|
|
|
endif()
|
|
|
|
|
2020-01-07 00:49:36 +08:00
|
|
|
include(FindPackageHandleStandardArgs)
|
2020-08-17 23:47:52 +08:00
|
|
|
find_package_handle_standard_args(PythonAndSwig
|
2020-01-07 00:49:36 +08:00
|
|
|
FOUND_VAR
|
2020-08-17 23:47:52 +08:00
|
|
|
PYTHONANDSWIG_FOUND
|
2020-01-07 00:49:36 +08:00
|
|
|
REQUIRED_VARS
|
2020-08-17 23:47:52 +08:00
|
|
|
Python3_LIBRARIES
|
|
|
|
Python3_INCLUDE_DIRS
|
|
|
|
Python3_EXECUTABLE
|
2020-01-08 13:53:33 +08:00
|
|
|
SWIG_EXECUTABLE)
|
2020-01-07 00:49:36 +08:00
|
|
|
endif()
|