diff --git a/runtime/onert/python/api/CMakeLists.txt b/runtime/onert/python/api/CMakeLists.txt index 376671766a3..24b5c2605b2 100644 --- a/runtime/onert/python/api/CMakeLists.txt +++ b/runtime/onert/python/api/CMakeLists.txt @@ -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") @@ -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