cmake: Build Python 3 binding
Build python3 binding when -Denable-python3-bindings=true is given.
@@ -50,6 +50,8 @@ option(CSP_USE_XTEA "eXtended TEA block cipher" ON)
option(CSP_USE_PROMISC "Promiscious mode" ON)
option(CSP_USE_DEDUP "Packet deduplication" ON)
+option(enable-python3-bindings "Build Python3 binding")
+
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(CSP_POSIX 1)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Zephyr")
@@ -82,4 +84,13 @@ target_compile_options(libcsp PRIVATE ${CSP_C_ARGS})
add_subdirectory(src)
add_subdirectory(examples)
+if(${enable-python3-bindings})
+ find_package(Python COMPONENTS Development.Module)
+ if(Python_Development.Module_FOUND)
+ Python_add_library(libcsp_py3 src/bindings/python/pycsp.c WITH_SOABI)
+ target_include_directories(libcsp_py3 PRIVATE ${csp_inc})
+ target_link_libraries(libcsp_py3 PRIVATE libcsp)
+ endif()
+endif()
+
configure_file(csp_autoconfig.h.in csp_autoconfig.h)
