擅长:python、mysql、java
<p>下面是我们过去使用python <code>2.7</code>所做的,但它可能适用于<code>3+</code>。我们通过从cmake运行python获得python库的完整路径</p>
<pre><code>add_subdirectory(pybind11)
find_package(Python3 COMPONENTS Interpreter Development)
FIND_PACKAGE(PythonLibs "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}" REQUIRED)
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import sys; from distutils.sysconfig import get_python_lib; print(get_python_lib().split(sys.prefix)[-1][1:])"
OUTPUT_VARIABLE PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE)
</code></pre>
<p>*为python3编辑</p>