2016-06-01 17:50:21 +00:00
|
|
|
include(CMakeParseArguments)
|
2016-05-28 07:44:36 +00:00
|
|
|
|
2016-06-01 17:50:21 +00:00
|
|
|
function(distutils_install_module name)
|
2017-07-20 20:54:37 +00:00
|
|
|
set(py_srcs setup.py README.rst requirements.txt test-requirements.txt bin ${name})
|
2016-05-28 07:44:36 +00:00
|
|
|
foreach(src ${py_srcs})
|
2017-07-20 20:54:37 +00:00
|
|
|
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${src})
|
|
|
|
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})
|
|
|
|
endif()
|
2016-05-28 07:44:36 +00:00
|
|
|
endforeach()
|
|
|
|
add_custom_target(${name}-clone ALL
|
|
|
|
DEPENDS ${py_clone})
|
2016-06-01 17:50:21 +00:00
|
|
|
cmake_parse_arguments(DU "" INSTALL_SCRIPT "" ${ARGN})
|
|
|
|
install(CODE "
|
2016-07-04 03:10:49 +00:00
|
|
|
set(options --prefix=${CMAKE_INSTALL_PREFIX})
|
2016-06-01 17:50:21 +00:00
|
|
|
if(DEFINED ENV{DESTDIR})
|
|
|
|
if(EXISTS /etc/debian_version)
|
|
|
|
list(APPEND options --install-layout=deb)
|
|
|
|
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(
|
2016-07-13 12:57:30 +00:00
|
|
|
COMMAND ${PYTHON${PYTHON_VERSION}_EXECUTABLE}
|
2016-06-01 17:50:21 +00:00
|
|
|
setup.py install \${options}
|
|
|
|
WORKING_DIRECTORY \"${CMAKE_CURRENT_BINARY_DIR}\")")
|
2016-05-28 07:44:36 +00:00
|
|
|
endfunction(distutils_install_module)
|
2016-06-01 05:38:05 +00:00
|
|
|
|
|
|
|
function(distutils_add_cython_module name src)
|
|
|
|
get_property(compiler_launcher GLOBAL PROPERTY RULE_LAUNCH_COMPILE)
|
|
|
|
get_property(link_launcher GLOBAL PROPERTY RULE_LAUNCH_LINK)
|
|
|
|
set(PY_CC \"${compiler_launcher} ${CMAKE_C_COMPILER}\")
|
|
|
|
set(PY_CXX \"${compiler_launcher} ${CMAKE_CXX_COMPILER}\")
|
|
|
|
set(PY_LDSHARED \"${link_launcher} ${CMAKE_C_COMPILER} -shared\")
|
|
|
|
add_custom_target(${name} ALL
|
|
|
|
COMMAND
|
|
|
|
env
|
|
|
|
CC=${PY_CC}
|
|
|
|
CXX=${PY_CXX}
|
|
|
|
LDSHARED=${PY_LDSHARED}
|
2016-11-08 20:43:26 +00:00
|
|
|
OPT=\"-DNDEBUG -g -fwrapv -O2 -w\"
|
2016-06-01 05:38:05 +00:00
|
|
|
LDFLAGS=-L${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
|
|
|
|
CYTHON_BUILD_DIR=${CMAKE_CURRENT_BINARY_DIR}
|
2016-06-13 18:17:09 +00:00
|
|
|
CEPH_LIBDIR=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
|
2016-11-08 20:43:26 +00:00
|
|
|
CFLAGS=\"-iquote${CMAKE_SOURCE_DIR}/src/include -w\"
|
2016-07-13 12:57:30 +00:00
|
|
|
${PYTHON${PYTHON_VERSION}_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/setup.py
|
|
|
|
build --verbose --build-base ${CYTHON_MODULE_DIR}
|
|
|
|
--build-platlib ${CYTHON_MODULE_DIR}/lib.${PYTHON${PYTHON_VERSION}_VERSION_MAJOR}
|
2016-06-01 05:38:05 +00:00
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
DEPENDS ${src})
|
|
|
|
endfunction(distutils_add_cython_module)
|
|
|
|
|
|
|
|
function(distutils_install_cython_module name)
|
|
|
|
install(CODE "
|
2016-07-04 03:26:28 +00:00
|
|
|
set(options --prefix=${CMAKE_INSTALL_PREFIX})
|
2016-06-01 05:38:05 +00:00
|
|
|
if(DEFINED ENV{DESTDIR})
|
|
|
|
if(EXISTS /etc/debian_version)
|
2016-07-04 03:26:28 +00:00
|
|
|
list(APPEND options --install-layout=deb)
|
2016-06-01 05:38:05 +00:00
|
|
|
endif()
|
2016-07-04 03:26:28 +00:00
|
|
|
list(APPEND options --root=\$ENV{DESTDIR})
|
2016-06-01 05:38:05 +00:00
|
|
|
else()
|
2016-07-04 03:26:28 +00:00
|
|
|
list(APPEND options --root=/)
|
2016-06-01 05:38:05 +00:00
|
|
|
endif()
|
|
|
|
execute_process(
|
|
|
|
COMMAND env
|
|
|
|
CYTHON_BUILD_DIR=${CMAKE_CURRENT_BINARY_DIR}
|
2016-06-13 18:17:09 +00:00
|
|
|
CEPH_LIBDIR=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
|
2016-07-08 06:57:41 +00:00
|
|
|
CC=${CMAKE_C_COMPILER}
|
2016-07-09 15:36:14 +00:00
|
|
|
CPPFLAGS=\"-iquote${CMAKE_SOURCE_DIR}/src/include\"
|
|
|
|
LDFLAGS=\"-L${CMAKE_LIBRARY_OUTPUT_DIRECTORY}\"
|
2016-07-13 12:57:30 +00:00
|
|
|
${PYTHON${PYTHON_VERSION}_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/setup.py
|
|
|
|
build --verbose --build-base ${CYTHON_MODULE_DIR}
|
|
|
|
--build-platlib ${CYTHON_MODULE_DIR}/lib.${PYTHON${PYTHON_VERSION}_VERSION_MAJOR}
|
2016-07-09 04:58:33 +00:00
|
|
|
build_ext --cython-c-in-temp --build-temp ${CMAKE_CURRENT_BINARY_DIR} --cython-include-dirs ${PROJECT_SOURCE_DIR}/src/pybind/rados
|
2016-07-08 06:57:41 +00:00
|
|
|
install \${options} --single-version-externally-managed --record /dev/null
|
|
|
|
egg_info --egg-base ${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
--verbose
|
2016-06-01 05:38:05 +00:00
|
|
|
WORKING_DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}\"
|
|
|
|
RESULT_VARIABLE install_res)
|
|
|
|
if(NOT \"\${install_res}\" STREQUAL 0)
|
|
|
|
message(FATAL_ERROR \"Failed to build and install ${name} python module\")
|
|
|
|
endif()
|
|
|
|
")
|
|
|
|
endfunction(distutils_install_cython_module)
|