CMakeLists.txt 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # Find each subdirectory containing a CMakeLists.txt file, and include
  2. # it. This avoids the need to manually list which libraries in Boost
  3. # have CMakeLists.txt files.
  4. # return a list of directories that we should add_subdirectory()
  5. macro(BOOST_COLLECT_SUBPROJECT_DIRECTORY_NAMES varname filename)
  6. file(GLOB BOOST_LIBRARY_CMAKE_FILES
  7. RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*/${filename}")
  8. foreach(BOOST_LIB_CMAKE_FILE ${BOOST_LIBRARY_CMAKE_FILES})
  9. get_filename_component(BOOST_LIB_DIR ${BOOST_LIB_CMAKE_FILE} PATH)
  10. set(${varname} ${${varname}} ${BOOST_LIB_DIR})
  11. endforeach(BOOST_LIB_CMAKE_FILE ${BOOST_LIBRARY_CMAKE_FILES})
  12. endmacro(BOOST_COLLECT_SUBPROJECT_DIRECTORY_NAMES varname)
  13. macro(ADD_SUBDIRECTORIES prefix)
  14. foreach(subdir ${ARGN})
  15. message(STATUS "${prefix}${subdir}")
  16. add_subdirectory(${subdir})
  17. endforeach(subdir ${ARGN})
  18. endmacro(ADD_SUBDIRECTORIES prefix)
  19. # Find all of the subdirectories with .cmake files in them. These are
  20. # the libraries with dependencies.
  21. boost_collect_subproject_directory_names(BOOST_MODULE_DIRS "module.cmake")
  22. foreach(subdir ${BOOST_MODULE_DIRS})
  23. include("${CMAKE_CURRENT_SOURCE_DIR}/${subdir}/module.cmake")
  24. endforeach(subdir)
  25. # Find all of the subdirectories with CMakeLists.txt files in
  26. # them. This contains all of the Boost libraries.
  27. boost_collect_subproject_directory_names(BOOST_SUBPROJECT_DIRS "CMakeLists.txt")
  28. # Add all of the Boost projects in reverse topological order, so that
  29. # a library's dependencies show up before the library itself.
  30. set(CPACK_INSTALL_CMAKE_COMPONENTS_ALL)
  31. list(SORT BOOST_SUBPROJECT_DIRS)
  32. topological_sort(BOOST_SUBPROJECT_DIRS BOOST_ _DEPENDS)
  33. add_subdirectories(" + " ${BOOST_SUBPROJECT_DIRS})
  34. # Write out a GraphViz file containing inter-library dependencies.
  35. set(BOOST_DEPENDENCY_GRAPHVIZ_FILE "${Boost_BINARY_DIR}/dependencies.dot")
  36. file(WRITE ${BOOST_DEPENDENCY_GRAPHVIZ_FILE} "digraph boost {\n")
  37. foreach(SUBDIR ${BOOST_SUBPROJECT_DIRS})
  38. string(TOUPPER "BOOST_${SUBDIR}_DEPENDS" DEPENDS_VAR)
  39. if(DEFINED ${DEPENDS_VAR})
  40. foreach(DEP ${${DEPENDS_VAR}})
  41. file(APPEND ${BOOST_DEPENDENCY_GRAPHVIZ_FILE}
  42. " \"${SUBDIR}\" -> \"${DEP}\";\n")
  43. endforeach()
  44. endif()
  45. endforeach()
  46. file(APPEND ${BOOST_DEPENDENCY_GRAPHVIZ_FILE} "}\n")
粤ICP备19079148号