FindPythonLibs¶
變更於版本 3.27: 此模組僅在政策 CMP0148
未設定為 NEW
時可用。
自版本 3.12 起已棄用: 請改用 FindPython3
、FindPython2
或 FindPython
。
尋找 Python 函式庫
此模組會尋找是否已安裝 Python,並決定標頭檔和函式庫的位置。它也會決定函式庫的名稱。此程式碼會設定以下變數
PYTHONLIBS_FOUND - have the Python libs been found
PYTHON_LIBRARIES - path to the python library
PYTHON_INCLUDE_PATH - path to where Python.h is found (deprecated)
PYTHON_INCLUDE_DIRS - path to where Python.h is found
PYTHON_DEBUG_LIBRARIES - path to the debug library (deprecated)
PYTHONLIBS_VERSION_STRING - version of the Python libs found (since CMake 2.8.8)
Python_ADDITIONAL_VERSIONS 變數可用於指定在搜尋 Python 時應考慮的版本號碼列表。您需要在呼叫 find_package(PythonLibs) 之前設定此變數。
如果您想要指定要使用的 Python 安裝,您應該修改以下快取變數
PYTHON_LIBRARY - path to the python library
PYTHON_INCLUDE_DIR - path to where Python.h is found
如果同時呼叫 find_package(PythonInterp)
和 find_package(PythonLibs)
,請先呼叫 find_package(PythonInterp)
,以使用一致版本的 PYTHON_LIBRARIES 取得預設目前作用中的 Python 版本。