forked from Samsung/ONE
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
37 lines (29 loc) · 1.21 KB
/
CMakeLists.txt
File metadata and controls
37 lines (29 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
if(NOT BUILD_PYTHON_BINDING)
return()
endif(NOT BUILD_PYTHON_BINDING)
# CMakeLists.txt
# refer to https://github.com/Samsung/ONE/issues/11368
# Tell pybind11 where the target python installation is
#
# 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")
# Disable pybind11 python search mechanism
set(PYTHONLIBS_FOUND TRUE CACHE INTERNAL "")
# Install pybind11
nnfw_find_package(Pybind11 REQUIRED)
if(NOT Pybind11_FOUND)
message(STATUS "Build onert/python: FAILED (Pybind11 is missing)")
return()
endif()
# Add the Python module
file(GLOB_RECURSE NNFW_API_PYBIND_SOURCES "src/*.cc")
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)
target_link_libraries(nnfw_api_pybind PRIVATE nnfw_common nnfw_coverage)
# Install the Python module
install(TARGETS nnfw_api_pybind DESTINATION lib)