Skip to content

Commit

Permalink
cmake: install ceph-disk to /usr/sbin
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
tchaikov committed Jun 4, 2016
1 parent ac8c40f commit c4a8784
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
35 changes: 22 additions & 13 deletions cmake/modules/Distutils.cmake
Original file line number Diff line number Diff line change
@@ -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})
Expand All @@ -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)
Expand All @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion src/ceph-disk/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit c4a8784

Please sign in to comment.