From 9e45edaab20793c5da8613a881ac24b492006012 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 23 Jan 2018 12:58:10 +0800 Subject: [PATCH] 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 --- CMakeLists.txt | 12 +++++++++--- src/CMakeLists.txt | 2 +- src/include/config-h.in.cmake | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d44d5759242..3c0d55dc784 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2a337fa7402..9651c75041f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -744,7 +744,7 @@ if (WITH_MGR) $) 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) diff --git a/src/include/config-h.in.cmake b/src/include/config-h.in.cmake index 0fc3086c8f1..ea1ebd8c22c 100644 --- a/src/include/config-h.in.cmake +++ b/src/include/config-h.in.cmake @@ -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