]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: install ceph-{detect-init,disk}
authorKefu Chai <kchai@redhat.com>
Sat, 28 May 2016 07:44:36 +0000 (15:44 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 1 Jun 2016 15:49:46 +0000 (23:49 +0800)
add a cmake module named Distutils.cmake for setting up python modules
using setup.py.

Signed-off-by: Kefu Chai <kchai@redhat.com>
cmake/modules/Distutils.cmake [new file with mode: 0644]
src/ceph-detect-init/CMakeLists.txt
src/ceph-disk/CMakeLists.txt

diff --git a/cmake/modules/Distutils.cmake b/cmake/modules/Distutils.cmake
new file mode 100644 (file)
index 0000000..4697c87
--- /dev/null
@@ -0,0 +1,24 @@
+function(distutils_install_module name)
+  if(DEFINED ENV{DESTDIR})
+    get_filename_component(debian_version /etc/debian_version ABSOLUTE)
+    if(EXISTS ${debian_version})
+      set(options "--install-layout=deb")
+    else()
+      set(options "--prefix=/usr")
+    endif()
+  endif()
+
+  set(py_srcs setup.py README.rst requirements.txt test-requirements.txt ${name})
+  foreach(src ${py_srcs})
+    list(APPEND py_clone ${CMAKE_CURRENT_BINARY_DIR}/${src})
+    add_custom_command(
+      OUTPUT ${src}
+      DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${src}
+      COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_SOURCE_DIR}/${src} ${src})
+  endforeach()
+  add_custom_target(${name}-clone ALL
+    DEPENDS ${py_clone})
+  install(CODE
+    "execute_process(COMMAND ${PYTHON_EXECUTABLE} setup.py install ${options} --root=$DESTDIR
+                   WORKING_DIRECTORY \"${CMAKE_CURRENT_BINARY_DIR}\")")
+endfunction(distutils_install_module)
index 8cefcb16c247a3ddc38eccdcfa48bbb170c2c28e..d7e0f5b7b83086d11ebbf909c28b830c66e55826 100644 (file)
@@ -6,3 +6,6 @@ add_custom_target(ceph-detect-init
   ${CEPH_DETECT_INIT_VIRTUALENV}/bin/pip install --no-index --use-wheel --find-links=file:${CMAKE_SOURCE_DIR}/src/ceph-detect-init/wheelhouse -e .
   WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/src/ceph-detect-init
   COMMENT "ceph-detect-init is being created")
+
+include(Distutils)
+distutils_install_module(ceph_detect_init)
index 025f6dbe3ec0eab6d3b699ce2a033ed1926ad0d4..9c91f18c9f889be5fe1196b6016ad94b6ec4cc08 100644 (file)
@@ -6,3 +6,6 @@ add_custom_target(ceph-disk
   ${CEPH_DISK_VIRTUALENV}/bin/pip install --no-index --use-wheel --find-links=file:${CMAKE_SOURCE_DIR}/src/ceph-disk/wheelhouse -e .
   WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/src/ceph-disk
   COMMENT "ceph-disk is being created")
+
+include(Distutils)
+distutils_install_module(ceph_disk)