summaryrefslogtreecommitdiffstats
path: root/cmake/modules/Distutils.cmake
diff options
context:
space:
mode:
authorKefu Chai <kchai@redhat.com>2016-05-28 09:44:36 +0200
committerKefu Chai <kchai@redhat.com>2016-06-01 17:49:46 +0200
commitb02aaebc45ba946a5997bae751b695e71ecf1a7e (patch)
tree6cd5cee638cd99923b01efa1f28d84a28e0212a7 /cmake/modules/Distutils.cmake
parentcmake: add ceph_rgw_{json,multi}parser (diff)
downloadceph-b02aaebc45ba946a5997bae751b695e71ecf1a7e.tar.xz
ceph-b02aaebc45ba946a5997bae751b695e71ecf1a7e.zip
cmake: install ceph-{detect-init,disk}
add a cmake module named Distutils.cmake for setting up python modules using setup.py. Signed-off-by: Kefu Chai <kchai@redhat.com>
Diffstat (limited to 'cmake/modules/Distutils.cmake')
-rw-r--r--cmake/modules/Distutils.cmake24
1 files changed, 24 insertions, 0 deletions
diff --git a/cmake/modules/Distutils.cmake b/cmake/modules/Distutils.cmake
new file mode 100644
index 00000000000..4697c87852b
--- /dev/null
+++ b/cmake/modules/Distutils.cmake
@@ -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)