cmake: build ceph-mgr with specified version of python

* add an option named "MGR_PYTHON_VERSION", so we can build ceph-mgr
  which use py3 for running plugins
* also drop the line to specify the "Python_ADDITIONAL_VERSIONS", because
  2.7 is listed by all the the FindPythonInterp and FindPythonLibs in
  cmake 2.8.12 and up.
* use ${MGR_PYTHON_EXECUTABLE} for holding the path to the python
  interpreter used by mgr. because this variable might be overwritten by
  "find_package(PythonInterp 2 REQUIRED)" when checking for building env
  of pybinding for python2.

Signed-off-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
Kefu Chai 2018-01-23 12:58:10 +08:00
parent 8b21ba9242
commit 9e45edaab2
3 changed files with 11 additions and 5 deletions

View File

@ -440,9 +440,15 @@ option(WITH_CEPHFS "CephFS is enabled" ON)
#option for Mgr
option(WITH_MGR "ceph-mgr is enabled" ON)
if(WITH_MGR)
set(Python_ADDITIONAL_VERSIONS 2.7)
find_package(PythonInterp 2.7 REQUIRED)
find_package(PythonLibs 2.7 REQUIRED)
# Please specify 3 or 3.[0-7] if you want to build with python3 support.
# FindPyhonInterp and FindPythonLibs think they belong to different families.
set(MGR_PYTHON_VERSION "2.7" CACHE
STRING "minimal required version of python runtime for running mgr plugins. ")
find_package(PythonInterp ${MGR_PYTHON_VERSION} REQUIRED)
find_package(PythonLibs ${MGR_PYTHON_VERSION} REQUIRED)
set(MGR_PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE})
set(MGR_PYTHON_LIBRARIES ${PYTHON_LIBRARIES})
set(MGR_PYTHON_VERSION_MAJOR ${PYTHON_VERSION_MAJOR})
# Boost dependency check deferred to Boost section
endif(WITH_MGR)

View File

@ -744,7 +744,7 @@ if (WITH_MGR)
$<TARGET_OBJECTS:heap_profiler_objs>)
target_include_directories(ceph-mgr SYSTEM PRIVATE "${PYTHON_INCLUDE_DIRS}")
target_link_libraries(ceph-mgr osdc client global-static ceph-common
Boost::python ${PYTHON_LIBRARIES} ${BLKID_LIBRARIES} ${CMAKE_DL_LIBS} ${ALLOC_LIBS})
Boost::python ${MGR_PYTHON_LIBRARIES} ${BLKID_LIBRARIES} ${CMAKE_DL_LIBS} ${ALLOC_LIBS})
install(TARGETS ceph-mgr DESTINATION bin)
endif (WITH_MGR)

View File

@ -322,7 +322,7 @@
/* Define if endian type is little endian */
#cmakedefine CEPH_LITTLE_ENDIAN
#cmakedefine PYTHON_EXECUTABLE "@PYTHON_EXECUTABLE@"
#cmakedefine PYTHON_EXECUTABLE "@MGR_PYTHON_EXECUTABLE@"
/* Define to 1 if you have the `getprogname' function. */
#cmakedefine HAVE_GETPROGNAME 1