]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: add implicit dependencies between boost libs 20616/head
authorKefu Chai <kchai@redhat.com>
Tue, 27 Feb 2018 13:11:10 +0000 (21:11 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 27 Feb 2018 13:26:42 +0000 (21:26 +0800)
so the dependencies can be included when linking against the one which
depends on them. for example, libboost_filesystem depends on
libboost_system, if we don't link against the latter, linker will bail
out when linking an executable using Boost::filesystem.

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

index e71f389e0f6a5d40b79751f01ac3823a5d8b6c16..12105575cb2fa68a52caccf23e606e65611e1088 100644 (file)
@@ -168,6 +168,12 @@ function(do_build_boost version)
     PREFIX "${boost_root_dir}")
 endfunction()
 
+set(Boost_context_DEPENDENCIES thread chrono system date_time)
+set(Boost_coroutine_DEPENDENCIES context system)
+set(Boost_filesystem_DEPENDENCIES system)
+set(Boost_iostreams_DEPENDENCIES regex)
+set(Boost_thread_DEPENDENCIES chrono system date_time atomic)
+
 macro(build_boost version)
   do_build_boost(${version} ${ARGN})
   ExternalProject_Get_Property(Boost install_dir)
@@ -177,6 +183,16 @@ macro(build_boost version)
   # target
   file(MAKE_DIRECTORY ${Boost_INCLUDE_DIRS})
   cmake_parse_arguments(Boost_BUILD "" "" COMPONENTS ${ARGN})
+  foreach(c ${Boost_BUILD_COMPONENTS})
+    list(APPEND components ${c})
+    if(Boost_${c}_DEPENDENCIES)
+      list(APPEND components ${Boost_${c}_DEPENDENCIES})
+      list(REMOVE_DUPLICATES components)
+    endif()
+  endforeach()
+  set(Boost_BUILD_COMPONENTS ${components})
+  unset(components)
+
   foreach(c ${Boost_BUILD_COMPONENTS})
     string(TOUPPER ${c} upper_c)
     if(Boost_USE_STATIC_LIBS)
@@ -204,6 +220,16 @@ macro(build_boost version)
       IMPORTED_LOCATION "${Boost_${upper_c}_LIBRARY}")
     list(APPEND Boost_LIBRARIES ${Boost_${upper_c}_LIBRARY})
   endforeach()
+  foreach(c ${Boost_BUILD_COMPONENTS})
+    if(Boost_${c}_DEPENDENCIES)
+      foreach(dep ${Boost_${c}_DEPENDENCIES})
+        list(APPEND dependencies Boost::${dep})
+      endforeach()
+      set_target_properties(Boost::${c} PROPERTIES
+        INTERFACE_LINK_LIBRARIES "${dependencies}")
+      unset(dependencies)
+    endif()
+  endforeach()
 
   # for header-only libraries
   if(CMAKE_VERSION VERSION_LESS 3.3)