From c4a87843308ace6f24a05be73c9c96cc1c2aa6a1 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Thu, 2 Jun 2016 01:50:21 +0800 Subject: [PATCH] cmake: install ceph-disk to /usr/sbin * add keyword "INSTALL_SCRIPT" to distutils_install_module(), so we can override the install path of ceph-disk script. * refactor the Distutils.cmake module a little bit, the ${option} variable out lives the CODE snipplet. so we need to reset it at the beginning. Signed-off-by: Kefu Chai --- cmake/modules/Distutils.cmake | 35 ++++++++++++++++++++++------------- src/ceph-disk/CMakeLists.txt | 3 ++- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/cmake/modules/Distutils.cmake b/cmake/modules/Distutils.cmake index b4c678b208c1a..07e6a0ff50a52 100644 --- a/cmake/modules/Distutils.cmake +++ b/cmake/modules/Distutils.cmake @@ -1,13 +1,6 @@ -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() +include(CMakeParseArguments) +function(distutils_install_module name) 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}) @@ -18,9 +11,24 @@ function(distutils_install_module name) 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}\")") + cmake_parse_arguments(DU "" INSTALL_SCRIPT "" ${ARGN}) + install(CODE " + set(options) + if(DEFINED ENV{DESTDIR}) + if(EXISTS /etc/debian_version) + list(APPEND options --install-layout=deb) + else() + list(APPEND options --prefix=/usr) + endif() + list(APPEND options --root=\$ENV{DESTDIR}) + if(NOT \"${DU_INSTALL_SCRIPT}\" STREQUAL \"\") + list(APPEND options --install-script=${DU_INSTALL_SCRIPT}) + endif() + endif() + execute_process( + COMMAND ${PYTHON_EXECUTABLE} + setup.py install \${options} + WORKING_DIRECTORY \"${CMAKE_CURRENT_BINARY_DIR}\")") endfunction(distutils_install_module) function(distutils_add_cython_module name src) @@ -46,10 +54,11 @@ endfunction(distutils_add_cython_module) function(distutils_install_cython_module name) install(CODE " - set(options --prefix=/usr) if(DEFINED ENV{DESTDIR}) if(EXISTS /etc/debian_version) set(options --install-layout=deb) + else() + set(options --prefix=/usr) endif() set(root --root=\$ENV{DESTDIR}) else() diff --git a/src/ceph-disk/CMakeLists.txt b/src/ceph-disk/CMakeLists.txt index 9c91f18c9f889..a7a7a3376feb9 100644 --- a/src/ceph-disk/CMakeLists.txt +++ b/src/ceph-disk/CMakeLists.txt @@ -8,4 +8,5 @@ add_custom_target(ceph-disk COMMENT "ceph-disk is being created") include(Distutils) -distutils_install_module(ceph_disk) +distutils_install_module(ceph_disk + INSTALL_SCRIPT /usr/sbin)