CMake 之 Find Python3
如果没有指定COMPONENTS,则假定Interpreter。
如果指定了Development组件,则意味着包含子组件 Development.Module 和 Development.Embed。
为了确保组件Interpreter, Compiler, Development(或其子组件之一)和NumPy之间的版本一致,同时指定所有组件:
find_package (Python3 COMPONENTS Interpreter Development)
此模块仅适用于Python的第3版。此模块可以与FindPython2模块同时使用,以使用两个Python版本。
重要的var有:
- Python3_FOUND
- Python3_EXECUTABLE
- Python3_INCLUDE_DIRS
- Python3_LINK_OPTIONS
- Python3_LIBRARIES
- Python3_LIBRARY_DIRS
- Python3_VERSION
- Python3_VERSION_MAJOR
- Python3_VERSION_MINOR
- Python3_VERSION_PATCH
- Python3_NumPy_FOUND
- Python3_NumPy_INCLUDE_DIRS
- Python3_NumPy_VERSION
ros 的CMakeList.txt中加入如下即可
target_link_libraries(${PROJECT_NAME}_node
${Python3_LIBRARIES}
${catkin_LIBRARIES}
)