]> granicus.if.org Git - clang/commitdiff
libclang: add install/distribution targets for python
authorSaleem Abdulrasool <compnerd@compnerd.org>
Mon, 20 Aug 2018 22:50:18 +0000 (22:50 +0000)
committerSaleem Abdulrasool <compnerd@compnerd.org>
Mon, 20 Aug 2018 22:50:18 +0000 (22:50 +0000)
Add installation support for the python bindings for libclang.  Add an
additional CMake configuration variable to enumerate the python versions for
which the bindings should be installed.  This allows for a LLVM/clang
distribution to distribute the python bindings for libclang as part of the
image.  Because the python versions need to be explicitly stated by the user,
the default image remains unchanged.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340228 91177308-0d34-0410-b5e6-96231b3b80d8

CMakeLists.txt
tools/libclang/CMakeLists.txt

index 52b8819394994bcc2a8c050cf01ef4fd46c1c523..7e2762b6d5f1a7e162670b8f3937764775d6c8bf 100644 (file)
@@ -279,6 +279,9 @@ endif()
 set(CLANG_VENDOR_UTI "org.llvm.clang" CACHE STRING
   "Vendor-specific uti.")
 
+set(CLANG_PYTHON_BINDINGS_VERSIONS "" CACHE STRING
+    "Python versions to install libclang python bindings for")
+
 # The libdir suffix must exactly match whatever LLVM's configuration used.
 set(CLANG_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}")
 
index e539c8308e756e2519eace01e0ef597a313add1e..729d5560b658292e1b8652c8e1e36712c53dce6a 100644 (file)
@@ -151,3 +151,22 @@ if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
   add_llvm_install_targets(install-libclang-headers
                            COMPONENT libclang-headers)
 endif()
+
+# Create a target to install the python bindings to make them easier to
+# distribute.  Since the bindings are over libclang, which is installed
+# unbundled to the clang version, follow suit.
+foreach(PythonVersion ${CLANG_PYTHON_BINDINGS_VERSIONS})
+  install(DIRECTORY
+            ${CMAKE_CURRENT_SOURCE_DIR}/../../bindings/python/clang
+          COMPONENT
+            libclang-python-bindings
+          DESTINATION
+            "lib${LLVM_LIBDIR_SUFFIX}/python${PythonVersion}/site-packages")
+endforeach()
+if(NOT CMAKE_CONFIGURATION_TYPES)
+  add_custom_target(libclang-python-bindings)
+  add_llvm_install_targets(install-libclang-python-bindings
+                           COMPONENT
+                             libclang-python-bindings)
+endif()
+