Generate Python bindings on build.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 05a6879..f9cbe6d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,10 @@
cmake_minimum_required(VERSION 3.10)
include(FetchContent)
include(GoogleTest)
+include(FindSWIG)
+include(UseSWIG)
+find_package(PythonLibs 3 REQUIRED)
+find_package(PythonInterp ${PYTHONLIBS_VERSION_STRING} REQUIRED)
project(CPERParse)
# GoogleTest requires at least C++14.
@@ -76,4 +80,18 @@
add_custom_command(TARGET cper-convert POST_BUILD COMMAND cp -r specification/json/* bin/specification)
# Add tests to GoogleTest.
-#gtest_discover_tests(cper-tests WORKING_DIRECTORY bin/)
\ No newline at end of file
+gtest_discover_tests(cper-tests WORKING_DIRECTORY bin/)
+
+# Generate Python bindings with SWIG.
+include_directories(cperparse_pylib ${PYTHON_INCLUDE_PATH} ${CMAKE_CURRENT_SOURCE_DIR})
+swig_add_library(cperparse_pylib
+ TYPE STATIC
+ LANGUAGE python
+ SOURCES cper-parse.i
+ OUTPUT_DIR lib/
+)
+swig_link_libraries(cperparse_pylib
+ cper-parse
+ json-c
+ ${PYTHON_LIBRARIES}
+)
\ No newline at end of file