如何在编译需要 python3 的文件时包含 DIRS 和库?



我正在尝试安装Cmake的软件,在其Makefile.config文件中有两行用于包含python 3库,例如

# Uncomment to use Python 3 (default is Python 2)
# PYTHON_LIBRARIES := boost_python3 python3.5m
# PYTHON_INCLUDE := /usr/include/python3.5m 
#                 /usr/lib/python3.5/dist-packages/numpy/core/include

如何在制作时导出这些行? 对于第一行PYTHON_INCLUDE我只知道

export CPLUS_INCLUDE_PATH=/usr/include/python3.5/

其他线路呢?

CMakeLists.txt使用中:

find_package(PythonLibs 3 REQUIRED)
include_directories(${PYTHON_INCLUDE_DIRS})
target_link_libraries(<your-target> ${PYTHON_LIBRARIES})

搜索python使用标准的CMake模块FindPythonLibs。


如果在搜索 Python 时出现 CMake 错误,请尝试谷歌 - 关于堆栈溢出有几个问题。

最新更新