FindPythonLibs¶
在 3.27 版本變更:此模組僅在 policy CMP0148
未設定為 NEW
時可用。
自 3.12 版本起已棄用:請改用 FindPython3
、FindPython2
或 FindPython
。
尋找 python 函式庫
此模組會尋找 Python 是否已安裝,並確定 include 檔案和函式庫的位置。它還會確定函式庫的名稱。此程式碼會設定以下變數
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 版本以及一致版本的 PYTHON_LIBRARIES。