]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: install ceph-disk to /usr/sbin
authorKefu Chai <kchai@redhat.com>
Wed, 1 Jun 2016 17:50:21 +0000 (01:50 +0800)
committerKefu Chai <kchai@redhat.com>
Sat, 4 Jun 2016 01:37:33 +0000 (09:37 +0800)
* 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 <kchai@redhat.com>
cmake/modules/Distutils.cmake
src/ceph-disk/CMakeLists.txt

index b4c678b208c1a326541f20b39096cc54507a20cd..07e6a0ff50a526fb9a92abe95ce9073639f2b114 100644 (file)
@@ -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()
index 9c91f18c9f889be5fe1196b6016ad94b6ec4cc08..a7a7a3376feb922657bbac841d3baa467fc10945 100644 (file)
@@ -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)