]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: build ceph-mgr with specified version of python
authorKefu Chai <kchai@redhat.com>
Tue, 23 Jan 2018 04:58:10 +0000 (12:58 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 26 Jan 2018 12:24:54 +0000 (20:24 +0800)
* 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>
CMakeLists.txt
src/CMakeLists.txt
src/include/config-h.in.cmake

index d44d5759242a044330eb357acda77bac6d2f66c7..3c0d55dc784d251f161a228d2c1b7d2664dcdc77 100644 (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)
 
index 2a337fa740270a25d14f1bd381c34abcb8d6fe96..9651c75041f81dff2040522b2ef0236e869742f2 100644 (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)
 
index 0fc3086c8f12e7da4616a9c6bda6b913054e46cc..ea1ebd8c22cdb07e91706c68ab258a715b6726a7 100644 (file)
 /* 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