Merge pull request #11015 from tchaikov/wip-optional-py3

cmake: make py3 a nice-to-have

Reviewed-by: Willem Jan Withagen <wjw@digiware.nl>
Reviewed-by: Josh Durgin <jdurgin@redhat.com>
This commit is contained in:
Kefu Chai 2016-09-09 10:55:24 +08:00 committed by GitHub
commit 1b163c802c
4 changed files with 23 additions and 4 deletions

View File

@ -672,6 +672,7 @@ cmake .. \
-DCMAKE_INSTALL_MANDIR=%{_mandir} \
-DCMAKE_INSTALL_DOCDIR=%{_docdir}/ceph \
-DWITH_MANPAGE=ON \
-DWITH_PYTHON3=ON \
-DWITH_SYSTEMD=ON \
%if 0%{?rhel} && ! 0%{?centos}
-DWITH_SUBMAN=ON \

2
debian/rules vendored
View File

@ -5,7 +5,7 @@ export DESTDIR=$(CURDIR)/debian/tmp
export DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
extraopts += -DUSE_CRYPTOPP=OFF -DWITH_OCF=ON -DWITH_LTTNG=ON
extraopts += -DUSE_CRYPTOPP=OFF -DWITH_OCF=ON -DWITH_LTTNG=ON -DWITH_PYTHON3=ON
extraopts += -DWITH_CEPHFS_JAVA=ON
# assumes that ceph is exmpt from multiarch support, so we override the libdir.
extraopts += -DCMAKE_INSTALL_LIBDIR=/usr/lib

View File

@ -200,8 +200,20 @@ endif()
# Python stuff
find_package(PythonInterp 2 REQUIRED)
find_package(PythonLibs 2 REQUIRED)
find_package(Python3Interp 3 REQUIRED)
find_package(Python3Libs 3 REQUIRED)
option(WITH_PYTHON3 "build python3 bindings" "CHECK")
if(WITH_PYTHON3 MATCHES "check|CHECK")
find_package(Python3Interp 3 QUIET)
find_package(Python3Libs 3 QUIET)
if(PYTHON3INTERP_FOUND AND PYTHON3LIBS_FOUND)
set(WITH_PYTHON3 ON)
else()
set(WITH_PYTHON3 OFF)
endif()
elseif(WITH_PYTHON3)
find_package(Python3Interp 3 REQUIRED)
find_package(Python3Libs 3 REQUIRED)
endif()
if(HAVE_XIO)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I${XIO_INCLUDE_DIR}")

View File

@ -2,7 +2,13 @@ include(Distutils)
set(CYTHON_MODULE_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cython_modules)
foreach(python_version 3 2) # Keep the default version last
# Keep the default version last
if(WITH_PYTHON3)
set(py_vers 3)
endif()
list(APPEND py_vers 2)
foreach(python_version ${py_vers})
if(${python_version} EQUAL 2)
set(PYTHON_VERSION "")
else(${python_version} EQUAL 2)