]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: fix build WITH_SYSTEM_BOOST=ON 23510/head
authorKefu Chai <kchai@redhat.com>
Thu, 9 Aug 2018 06:07:10 +0000 (14:07 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 9 Aug 2018 10:57:04 +0000 (18:57 +0800)
FindBoost.cmake from upstream cmake now finds python libraries like

find_package(Boost 1.67 python36)

and it export targets like Boost::python36

but we are still linking against Boost::python, so to be compatible
with FindBoost.cmake, we need to update BuildBoost.cmake and
mgr/CMakeLists.txt accordingly. in other words, to export
Boost::python36 and to link Boost::python36.

Signed-off-by: Kefu Chai <kchai@redhat.com>
CMakeLists.txt
cmake/modules/BuildBoost.cmake
src/mgr/CMakeLists.txt

index 67d258f21ad71d229964de35bd107816fbd64e96..4199cd5c1a34df531c12f69df2b2606a69ca24af 100644 (file)
@@ -485,6 +485,7 @@ if(WITH_MGR)
   set(MGR_PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE})
   set(MGR_PYTHON_LIBRARIES ${PYTHON_LIBRARIES})
   set(MGR_PYTHON_VERSION_MAJOR ${PYTHON_VERSION_MAJOR})
+  set(MGR_PYTHON_VERSION_MINOR ${PYTHON_VERSION_MINOR})
   # Boost dependency check deferred to Boost section
 endif(WITH_MGR)
 
@@ -597,7 +598,8 @@ set(BOOST_COMPONENTS
 set(BOOST_HEADER_COMPONENTS container)
 
 if(WITH_MGR)
-       list(APPEND BOOST_COMPONENTS python)
+  list(APPEND BOOST_COMPONENTS
+    python${MGR_PYTHON_VERSION_MAJOR}${MGR_PYTHON_VERSION_MINOR})
 endif()
 if(WITH_BOOST_CONTEXT)
   list(APPEND BOOST_COMPONENTS context coroutine)
index 1ed21cb896ef55d5625c94e948e21934a6e6a775..f46cc0d485375e8d1bbcc77f336541107ec0474a 100644 (file)
@@ -65,9 +65,20 @@ function(do_build_boost version)
   set(BOOST_CXXFLAGS "-fPIC -w") # check on arm, etc <---XXX
   list(APPEND boost_features "cxxflags=${BOOST_CXXFLAGS}")
 
-  list(FIND Boost_BUILD_COMPONENTS "python" with_python)
-  list_replace(Boost_BUILD_COMPONENTS "unit_test_framework" "test")
-  string(REPLACE ";" "," boost_with_libs "${Boost_BUILD_COMPONENTS}")
+  set(boost_with_libs)
+  foreach(c ${Boost_BUILD_COMPONENTS})
+    if(c MATCHES "^python([0-9])\$")
+      set(with_python_version "${CMAKE_MATCH_1}")
+      list(APPEND boost_with_libs "python")
+    elseif(c MATCHES "^python([0-9])\\.?([0-9])\$")
+      set(with_python_version "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}")
+      list(APPEND boost_with_libs "python")
+    else()
+      list(APPEND boost_with_libs ${c})
+    endif()
+  endforeach()
+  list_replace(boost_with_libs "unit_test_framework" "test")
+  string(REPLACE ";" "," boost_with_libs "${boost_with_libs}")
   # build b2 and prepare the project-config.jam for boost
   set(configure_command
     ./bootstrap.sh --prefix=<INSTALL_DIR>
@@ -97,12 +108,12 @@ function(do_build_boost version)
     " : "
     " : ${CMAKE_CXX_COMPILER}"
     " ;\n")
-  if(with_python GREATER -1)
-    set(python_ver ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})
+  if(with_python_version)
+    find_package(PythonLibs ${with_python_version} QUIET REQUIRED)
     string(REPLACE ";" " " python_includes "${PYTHON_INCLUDE_DIRS}")
     file(APPEND ${user_config}
       "using python"
-      " : ${python_ver}"
+      " : ${with_python_version}"
       " : ${PYTHON_EXECUTABLE}"
       " : ${python_includes}"
       " : ${PYTHON_LIBRARIES}"
@@ -111,12 +122,8 @@ function(do_build_boost version)
   list(APPEND b2 --user-config=${user_config})
 
   list(APPEND b2 toolset=${toolset})
-  if(with_python GREATER -1)
-    if(NOT PYTHONLIBS_FOUND)
-      message(FATAL_ERROR "Please call find_package(PythonLibs) first for building "
-        "Boost.Python")
-    endif()
-    list(APPEND b2 python=${python_ver})
+  if(with_python_version)
+    list(APPEND b2 python=${with_python_version})
   endif()
 
   set(build_command
@@ -197,17 +204,15 @@ macro(build_boost version)
       add_library(Boost::${c} SHARED IMPORTED)
     endif()
     add_dependencies(Boost::${c} Boost)
-    if(c STREQUAL python)
-      set(buildid "${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}")
-    else()
-      set(buildid "")
+    if(c MATCHES "^python")
+      set(c "python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}")
     endif()
     if(Boost_USE_STATIC_LIBS)
       set(Boost_${upper_c}_LIBRARY
-        ${install_dir}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}boost_${c}${buildid}${CMAKE_STATIC_LIBRARY_SUFFIX})
+        ${install_dir}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}boost_${c}${CMAKE_STATIC_LIBRARY_SUFFIX})
     else()
       set(Boost_${upper_c}_LIBRARY
-        ${install_dir}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}boost_${c}${buildid}${CMAKE_SHARED_LIBRARY_SUFFIX})
+        ${install_dir}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}boost_${c}${CMAKE_SHARED_LIBRARY_SUFFIX})
     endif()
     unset(buildid)
     set_target_properties(Boost::${c} PROPERTIES
index 3ed9a960d519f23239667c91396dd2676f90cb87..925d02d0f99d725031c96243cccfb37f893f2dc0 100644 (file)
@@ -24,7 +24,8 @@ target_include_directories(ceph-mgr SYSTEM PRIVATE "${PYTHON_INCLUDE_DIRS}")
 target_link_libraries(ceph-mgr
   osdc client heap_profiler
   global-static ceph-common
-  Boost::python ${MGR_PYTHON_LIBRARIES} ${CMAKE_DL_LIBS})
+  Boost::python${MGR_PYTHON_VERSION_MAJOR}${MGR_PYTHON_VERSION_MINOR}
+  ${MGR_PYTHON_LIBRARIES} ${CMAKE_DL_LIBS})
 set_target_properties(ceph-mgr PROPERTIES
   POSITION_INDEPENDENT_CODE ${EXE_LINKER_USE_PIE})
 install(TARGETS ceph-mgr DESTINATION bin)