summaryrefslogtreecommitdiff
path: root/src/bindings
diff options
context:
space:
mode:
authorMathias Preiner <mathias.preiner@gmail.com>2018-09-12 11:10:01 -0700
committerMathias Preiner <mathias.preiner@gmail.com>2018-09-22 16:30:59 -0700
commit479aebfc657eb9bc90fad550f51ec3b3d2efec76 (patch)
treeea4f7ff7b016d59954f57ec333e553655e64cdac /src/bindings
parent2c68c3e9009d7c893f92b7023c2122c763e697ca (diff)
cmake: Add make install rule.
Diffstat (limited to 'src/bindings')
-rw-r--r--src/bindings/CMakeLists.txt4
-rw-r--r--src/bindings/python/CMakeLists.txt26
2 files changed, 29 insertions, 1 deletions
diff --git a/src/bindings/CMakeLists.txt b/src/bindings/CMakeLists.txt
index a9032b0d9..1c62ecd58 100644
--- a/src/bindings/CMakeLists.txt
+++ b/src/bindings/CMakeLists.txt
@@ -1,3 +1,7 @@
+if(NOT ENABLE_SHARED)
+ message(FATAL_ERROR "Can't build language bindings for static CVC4 build.")
+endif()
+
find_package(SWIG 3.0.0 REQUIRED)
include(${SWIG_USE_FILE})
diff --git a/src/bindings/python/CMakeLists.txt b/src/bindings/python/CMakeLists.txt
index 2c2c50126..44d64fb29 100644
--- a/src/bindings/python/CMakeLists.txt
+++ b/src/bindings/python/CMakeLists.txt
@@ -1,4 +1,10 @@
-find_package(PythonLibs REQUIRED)
+# Make sure that interpreter and libraries have a compatible version.
+# Note: We use the Python interpreter to determine the install path for Python
+# modules. If the interpreter and library have different version, the module
+# will be installed for the wrong Python version. Hence, we require the library
+# version to match the Python interpreter's version.
+find_package(PythonLibs
+ ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} REQUIRED)
include_directories(${PYTHON_INCLUDE_DIRS})
set(SWIG_MODULE_CVC4_EXTRA_DEPS cvc4 cvc4parser)
@@ -17,3 +23,21 @@ else()
swig_add_library(CVC4 LANGUAGE Python SOURCES ${CVC4_SWIG_INTERFACE})
endif()
swig_link_libraries(CVC4 cvc4 cvc4parser ${PYTHON_LIBRARIES})
+
+
+# Install Python bindings to the corresponding python-*/site-packages
+# directory. Lookup Python module directory and store path in
+# PYTHON_MODULE_PATH.
+execute_process(COMMAND
+ ${PYTHON_EXECUTABLE} -c
+ "from distutils.sysconfig import get_python_lib;\
+ print(get_python_lib(plat_specific=True,\
+ prefix='${CMAKE_INSTALL_PREFIX}'))"
+ OUTPUT_VARIABLE PYTHON_MODULE_PATH
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+# Copy _CVC4.so and CVC4.py to PYTHON_MODULE_PATH
+install(TARGETS ${SWIG_MODULE_CVC4_REAL_NAME}
+ DESTINATION ${PYTHON_MODULE_PATH})
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/CVC4.py
+ DESTINATION ${PYTHON_MODULE_PATH})
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback