Make Python binding compilation optional.
Change-Id: I85485c5220c34085598fd8f790dc718c0321c041
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2d22d91..86b3b81 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,7 +2,7 @@
project(CPERParse)
include(FetchContent)
include(GoogleTest)
-if (NOT CMAKE_CROSSCOMPILING)
+if (BUILD_PYTHON_LIBS)
include(FindSWIG)
include(UseSWIG)
find_package(PythonLibs 3 REQUIRED)
@@ -92,7 +92,7 @@
#gtest_discover_tests(cper-tests WORKING_DIRECTORY bin/)
# Generate Python bindings with SWIG.
-if (NOT CMAKE_CROSSCOMPILING)
+if (BUILD_PYTHON_LIBS)
include_directories(cperparse_pylib ${PYTHON_INCLUDE_PATH} ${CMAKE_CURRENT_SOURCE_DIR})
swig_add_library(cperparse_pylib
TYPE STATIC
diff --git a/README.md b/README.md
index 463bab0..339a0e4 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,7 @@
- `FindSWIG`
- `UseSWIG`
-You should also have Python3 and associated libraries installed for the purposes of building the Python bindings.
+If you are building the Python bindings, you should also have Python3 and associated libraries installed for the purposes of building the Python bindings.
## Building
This project uses CMake (>=3.10). To build for native architecture, simply run:
@@ -16,7 +16,7 @@
cmake .
make
```
-A static library file for the parsing library will be written to `lib/`, and test executables will be written to `bin/`.
+A static library file for the parsing library will be written to `lib/`, and test executables will be written to `bin/`. To build the Python bindings in addition to all C libraries, add the argument `-DBUILD_PYTHON_LIBS` to your `cmake` command.
### Cross Compilation
To cross compile for ARM/AArch64 architecture from x86, instead use the below commands (ensure `cmake clean .` beforehand).