pybind / cmake_example

Example pybind11 module built with a CMake-based build system
Other
606 stars 215 forks source link

how to build with arm-linux-gcc #160

Closed Layty closed 8 months ago

Layty commented 8 months ago

my host is x86-ubuntu, I need to build with my nxp-imx6ul with pybind.

I have build python for ubuntu and arm-board(nxp), then I want to build pybind, I Use this example, set the arm-linux-gcc for this project, so how to set python path( ubuntu and arm-python) to pybind11?

or how to change the cmakelist

Layty commented 8 months ago

fix it cmake_minimum_required(VERSION 3.4...3.18) project(cmake_example)

set(PYTHON_EXECUTABLE "/work/pyBuild/MyPython/Python-3.12.0.arm/build.arm//bin/python3") set(MY_TARGET_PYTHON_INCLUDE_DIRS "/work/pyBuild/MyPython/Python-3.12.0.arm/build.arm/include/python3.12") set(PYTHON_INCLUDE_DIRS ${MY_TARGET_PYTHON_INCLUDE_DIRS} CACHE INTERNAL "Cross python include path") set(PYTHONLIBS_FOUND TRUE CACHE INTERNAL "") set(PYTHON_MODULE_EXTENSION ".so" CACHE INTERNAL "Cross python lib extension") set(PYTHON_MODULE_PREFIX "") add_subdirectory(pybind11)

pybind11_add_module(cmake_example src/main.cpp)

target_compile_definitions(cmake_example PRIVATE VERSION_INFO=${EXAMPLE_VERSION_INFO})