From: Ali Maredia Date: Thu, 3 Mar 2016 17:05:18 +0000 (-0500) Subject: cmake: Cython modules building with cmake X-Git-Tag: v10.1.1~77^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f02f1d17a64190a393802c98a86bf760214a91a2;p=ceph.git cmake: Cython modules building with cmake Signed-off-by: Ali Maredia --- diff --git a/CMakeLists.txt b/CMakeLists.txt index bb9e28b67116f..3391b4294b51c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,6 +48,11 @@ include(CheckIncludeFiles) include(CheckIncludeFileCXX) include(CheckFunctionExists) +#put all the libs and binaries in one place +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) + CHECK_FUNCTION_EXISTS(fallocate CEPH_HAVE_FALLOCATE) CHECK_FUNCTION_EXISTS(posix_fadvise HAVE_POSIX_FADVISE) CHECK_FUNCTION_EXISTS(posix_fallocate HAVE_POSIX_FALLOCATE) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a032662776a73..168842baafc2f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -524,6 +524,8 @@ install(TARGETS rados librados-config DESTINATION bin) install(DIRECTORY ${CMAKE_SOURCE_DIR}/src/pybind/ DESTINATION ${PYTHON_INSTDIR}) +add_subdirectory(pybind) + ## dencoder set(dencoder_srcs test/encoding/ceph_dencoder.cc @@ -883,25 +885,25 @@ target_link_libraries(ceph-authtool global ${EXTRALIBS} ${CRYPTO_LIBS}) install(TARGETS ceph-authtool DESTINATION bin) configure_file(${CMAKE_SOURCE_DIR}/src/ceph-coverage.in - ${CMAKE_BINARY_DIR}/ceph-coverage @ONLY) + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ceph-coverage @ONLY) configure_file(${CMAKE_SOURCE_DIR}/src/ceph-debugpack.in - ${CMAKE_BINARY_DIR}/ceph-debugpack @ONLY) + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ceph-debugpack @ONLY) configure_file(${CMAKE_SOURCE_DIR}/src/ceph.in - ${CMAKE_BINARY_DIR}/ceph @ONLY) + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ceph @ONLY) configure_file(${CMAKE_SOURCE_DIR}/src/ceph-crush-location.in - ${CMAKE_BINARY_DIR}/ceph-crush-location @ONLY) + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ceph-crush-location @ONLY) configure_file(${CMAKE_SOURCE_DIR}/src/init-ceph.in - ${CMAKE_BINARY_DIR}/init-ceph @ONLY) + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/init-ceph @ONLY) install(PROGRAMS - ${CMAKE_BINARY_DIR}/ceph - ${CMAKE_BINARY_DIR}/ceph-debugpack - ${CMAKE_BINARY_DIR}/ceph-coverage - ${CMAKE_BINARY_DIR}/init-ceph + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ceph + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ceph-debugpack + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ceph-coverage + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/init-ceph ${CMAKE_SOURCE_DIR}/src/ceph-run ${CMAKE_SOURCE_DIR}/src/vstart.sh ${CMAKE_SOURCE_DIR}/src/ceph-clsinfo @@ -1313,6 +1315,7 @@ add_custom_target(vstart DEPENDS add_custom_target(cephfs_testing DEPENDS vstart rados + cython_modules cephfs cls_cephfs ceph-fuse diff --git a/src/ceph.in b/src/ceph.in index 79c226351253e..7fa4ebca0c6e4 100755 --- a/src/ceph.in +++ b/src/ceph.in @@ -98,7 +98,7 @@ elif os.path.exists(os.path.join(os.getcwd(), "CMakeCache.txt")) \ # Developer mode, but in a cmake build dir instead of the src dir lib_path = os.path.join(os.getcwd(), "src") pybind_path = os.path.join(src_path, "src", "pybind") - pythonlib_path = os.path.join(src_path, "src", get_pythonlib_dir()) + pythonlib_path = os.path.join(os.getcwd(), "../src/pybind", get_pythonlib_dir()) respawn_in_path(lib_path, pybind_path, pythonlib_path) sys.path.insert(0, os.path.join(MYDIR, pybind_path)) diff --git a/src/pybind/CMakeLists.txt b/src/pybind/CMakeLists.txt new file mode 100644 index 0000000000000..5fbbc7f6518b2 --- /dev/null +++ b/src/pybind/CMakeLists.txt @@ -0,0 +1,8 @@ +set(CYTHON_MODULE_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cython_modules) + +add_subdirectory(rados) +add_subdirectory(rbd) +add_subdirectory(cephfs) + +add_custom_target(cython_modules ALL + DEPENDS cython_rados cython_cephfs cython_rbd) diff --git a/src/pybind/cephfs/CMakeLists.txt b/src/pybind/cephfs/CMakeLists.txt new file mode 100644 index 0000000000000..91d36ceaa9d5e --- /dev/null +++ b/src/pybind/cephfs/CMakeLists.txt @@ -0,0 +1,9 @@ +add_custom_target(cython_cephfs + COMMAND + LDFLAGS=-L${CMAKE_LIBRARY_OUTPUT_DIRECTORY} + CYTHON_BUILD_DIR=${CMAKE_BINARY_DIR}/src/pybind/cephfs + CFLAGS=\"-I${CMAKE_SOURCE_DIR}/src -I${CMAKE_BINARY_DIR}/include -I${CMAKE_SOURCE_DIR}/src/include -std=c++11\" + 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) + diff --git a/src/pybind/cephfs/setup.py b/src/pybind/cephfs/setup.py index cf29229dc3c33..73488eb8c5434 100755 --- a/src/pybind/cephfs/setup.py +++ b/src/pybind/cephfs/setup.py @@ -42,7 +42,8 @@ setup( ext_modules = cythonize([ Extension("cephfs", ["cephfs.pyx"], - libraries=["cephfs"] + libraries=["cephfs"], + language="c++" ) ], build_dir=os.environ.get("CYTHON_BUILD_DIR", None), include_path=[ os.path.join(os.path.dirname(__file__), "..", "rados")] diff --git a/src/pybind/rados/CMakeLists.txt b/src/pybind/rados/CMakeLists.txt new file mode 100644 index 0000000000000..3b2cd38ff38e5 --- /dev/null +++ b/src/pybind/rados/CMakeLists.txt @@ -0,0 +1,9 @@ +add_custom_target(cython_rados + COMMAND + LDFLAGS=-L${CMAKE_LIBRARY_OUTPUT_DIRECTORY} + CYTHON_BUILD_DIR=${CMAKE_BINARY_DIR}/src/pybind/rados + CFLAGS=\"-I${CMAKE_SOURCE_DIR}/src/include -std=c++11\" + 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) + diff --git a/src/pybind/rados/setup.py b/src/pybind/rados/setup.py index 6a7b9bd4ca91e..2b0f0b6077cae 100755 --- a/src/pybind/rados/setup.py +++ b/src/pybind/rados/setup.py @@ -42,7 +42,8 @@ setup( ext_modules = cythonize([ Extension("rados", ["rados.pyx"], - libraries=["rados"] + libraries=["rados"], + language="c++" ) ], build_dir=os.environ.get("CYTHON_BUILD_DIR", None)), cmdclass={ diff --git a/src/pybind/rbd/CMakeLists.txt b/src/pybind/rbd/CMakeLists.txt new file mode 100644 index 0000000000000..b5881530e0498 --- /dev/null +++ b/src/pybind/rbd/CMakeLists.txt @@ -0,0 +1,9 @@ +add_custom_target(cython_rbd + COMMAND + LDFLAGS=-L${CMAKE_LIBRARY_OUTPUT_DIRECTORY} + CYTHON_BUILD_DIR=${CMAKE_BINARY_DIR}/src/pybind/rbd + CFLAGS=\"-I${CMAKE_SOURCE_DIR}/src/include -std=c++11\" + 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) + diff --git a/src/pybind/rbd/setup.py b/src/pybind/rbd/setup.py index ec2f3a2ca19aa..7ca00b4f59e85 100755 --- a/src/pybind/rbd/setup.py +++ b/src/pybind/rbd/setup.py @@ -42,7 +42,8 @@ setup( ext_modules = cythonize([ Extension("rbd", ["rbd.pyx"], - libraries=["rbd"] + libraries=["rbd"], + language="c++" ) ], build_dir=os.environ.get("CYTHON_BUILD_DIR", None), include_path=[ os.path.join(os.path.dirname(__file__), "..", "rados")]