Skip to content

Commit

Permalink
[onert/python] Fix build issue on cross build (#11755)
Browse files Browse the repository at this point in the history
This commit resolves python binding API build issue on cross build.

ONE-DCO-1.0-Signed-off-by: Hyeongseok Oh <[email protected]>
  • Loading branch information
hseok-oh authored and Seunghui98 committed Oct 25, 2023
1 parent 00805f4 commit 6225c61
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions runtime/onert/python/api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@

# refer to https://github.com/Samsung/ONE/issues/11368

if(CMAKE_CROSSCOMPILING)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY "Set to find packages only in cross root path by force")
endif()

find_package(Python COMPONENTS Interpreter Development)

# Tell pybind11 where the target python installation is
set(PYTHON_INCLUDE_DIRS ${Python_INCLUDE_DIRS} CACHE INTERNAL "Cross python include path")
set(PYTHON_LIBRARIES ${Python_LIBRARIES} CACHE INTERNAL "Cross python include path")
#
# FindPythonLibs is deprecated since 3.12, and recommand to use FindPython.
# But on cross compile, FindPython is not working for target environment
# For workaround, use PythonLibs
find_package(PythonLibs REQUIRED)
set(PYTHON_MODULE_PREFIX "lib" CACHE INTERNAL "Cross python lib prefix")
set(PYTHON_MODULE_EXTENSION ".so" CACHE INTERNAL "Cross python lib extension")

Expand All @@ -26,12 +23,8 @@ endif()

# Add the Python module
file(GLOB_RECURSE NNFW_API_PYBIND_SOURCES "src/*.cc")
add_library(nnfw_api_pybind MODULE ${NNFW_API_PYBIND_SOURCES})

# Add the nnfw api and Pybind11 header
target_include_directories(nnfw_api_pybind PRIVATE ${pybind11_SOURCE_DIR}/include)
target_include_directories(nnfw_api_pybind PRIVATE ${PYTHON_INCLUDE_DIRS})
target_include_directories(nnfw_api_pybind PRIVATE include ../../api/include)
pybind11_add_module(nnfw_api_pybind ${NNFW_API_PYBIND_SOURCES})
target_include_directories(nnfw_api_pybind PRIVATE include)
target_link_libraries(nnfw_api_pybind PRIVATE nnfw-dev)

# Install the Python module
Expand Down

0 comments on commit 6225c61

Please sign in to comment.