diff options
author | Kefu Chai <kchai@redhat.com> | 2016-06-01 07:38:05 +0200 |
---|---|---|
committer | Kefu Chai <kchai@redhat.com> | 2016-06-01 17:50:05 +0200 |
commit | bbf51e15621ab1261f22e5ec8e53df10a0018566 (patch) | |
tree | 4c2a1e4e6126a32b75af1d20f265c08de044969f /src/pybind | |
parent | cmake: install compressor plugins into ${pkglibdir/compressor (diff) | |
download | ceph-bbf51e15621ab1261f22e5ec8e53df10a0018566.tar.xz ceph-bbf51e15621ab1261f22e5ec8e53df10a0018566.zip |
cmake: install cython modules
* fix CYTHON_ADD_MODULE() macro. because python_add_module() offered by
FindPythonLibs.cmake creates a target with name of ${name}, which conflicts
with existing targets like "rbd" or "rados". so we can not reuse the
name in ${name}.pyx. and instead, we should specify the target name
explicitly.
* add distutils_install_cython_module() function to build and install
cython modules.
* we can split build and install of cython module, but the install phase
always tries to build the module. so keep it this way. will look at it
later on.
* move the variables initializations into the Distutils.cmake module.
Signed-off-by: Kefu Chai <kchai@redhat.com>
Diffstat (limited to 'src/pybind')
-rw-r--r-- | src/pybind/CMakeLists.txt | 8 | ||||
-rw-r--r-- | src/pybind/cephfs/CMakeLists.txt | 17 | ||||
-rw-r--r-- | src/pybind/rados/CMakeLists.txt | 17 | ||||
-rw-r--r-- | src/pybind/rbd/CMakeLists.txt | 17 |
4 files changed, 12 insertions, 47 deletions
diff --git a/src/pybind/CMakeLists.txt b/src/pybind/CMakeLists.txt index 6a4ba94ebd0..9acea1db921 100644 --- a/src/pybind/CMakeLists.txt +++ b/src/pybind/CMakeLists.txt @@ -1,9 +1,7 @@ +find_package(Cython REQUIRED) +include(Distutils) + set(CYTHON_MODULE_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cython_modules) -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_subdirectory(rados) add_subdirectory(rbd) diff --git a/src/pybind/cephfs/CMakeLists.txt b/src/pybind/cephfs/CMakeLists.txt index 2981a920b27..c3aa6c3d0ff 100644 --- a/src/pybind/cephfs/CMakeLists.txt +++ b/src/pybind/cephfs/CMakeLists.txt @@ -1,14 +1,3 @@ -add_custom_target(cython_cephfs - COMMAND - env - CC=${PY_CC} - CXX=${PY_CXX} - LDSHARED=${PY_LDSHARED} - OPT=\"-DNDEBUG -g -fwrapv -O2 -Wall\" - LDFLAGS=-L${CMAKE_LIBRARY_OUTPUT_DIRECTORY} - CYTHON_BUILD_DIR=${CMAKE_BINARY_DIR}/src/pybind/cephfs - CFLAGS=\"-iquote ${CMAKE_SOURCE_DIR}/src/include\" - python ${CMAKE_SOURCE_DIR}/src/pybind/cephfs/setup.py build --build-base ${CYTHON_MODULE_DIR} --verbose - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/src/pybind/cephfs - DEPENDS rados cephfs) - +distutils_add_cython_module(cython_cephfs ${CMAKE_CURRENT_SOURCE_DIR}/cephfs.pyx) +add_dependencies(cython_cephfs cephfs) +distutils_install_cython_module(cython_cephfs) diff --git a/src/pybind/rados/CMakeLists.txt b/src/pybind/rados/CMakeLists.txt index 8bbe9cef968..5b36e5cc31d 100644 --- a/src/pybind/rados/CMakeLists.txt +++ b/src/pybind/rados/CMakeLists.txt @@ -1,14 +1,3 @@ -add_custom_target(cython_rados - COMMAND - env - CC=${PY_CC} - CXX=${PY_CXX} - LDSHARED=${PY_LDSHARED} - OPT=\"-DNDEBUG -g -fwrapv -O2 -Wall\" - LDFLAGS=-L${CMAKE_LIBRARY_OUTPUT_DIRECTORY} - CYTHON_BUILD_DIR=${CMAKE_BINARY_DIR}/src/pybind/rados - CFLAGS=\"-iquote ${CMAKE_SOURCE_DIR}/src/include\" - python ${CMAKE_SOURCE_DIR}/src/pybind/rados/setup.py build --build-base ${CYTHON_MODULE_DIR} --verbose - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/src/pybind/rados - DEPENDS rados) - +distutils_add_cython_module(cython_rados ${CMAKE_CURRENT_SOURCE_DIR}/rados.pyx) +add_dependencies(cython_rados rados) +distutils_install_cython_module(cython_rados) diff --git a/src/pybind/rbd/CMakeLists.txt b/src/pybind/rbd/CMakeLists.txt index 52400c45004..50a37a0940a 100644 --- a/src/pybind/rbd/CMakeLists.txt +++ b/src/pybind/rbd/CMakeLists.txt @@ -1,14 +1,3 @@ -add_custom_target(cython_rbd - COMMAND - env - CC=${PY_CC} - CXX=${PY_CXX} - LDSHARED=${PY_LDSHARED} - OPT=\"-DNDEBUG -g -fwrapv -O2 -Wall\" - LDFLAGS=-L${CMAKE_LIBRARY_OUTPUT_DIRECTORY} - CYTHON_BUILD_DIR=${CMAKE_BINARY_DIR}/src/pybind/rbd - CFLAGS=\"-iquote ${CMAKE_SOURCE_DIR}/src/include\" - python ${CMAKE_SOURCE_DIR}/src/pybind/rbd/setup.py build --build-base ${CYTHON_MODULE_DIR} --verbose - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/src/pybind/rbd - DEPENDS rbd) - +distutils_add_cython_module(cython_rbd ${CMAKE_CURRENT_SOURCE_DIR}/rbd.pyx) +add_dependencies(cython_rbd rbd) +distutils_install_cython_module(cython_rbd) |